rc

Add a shutdown script and backup system using rsync

Author
Maarten 'Vngngdn' Vangeneugden
Date
March 10, 2017, 6:54 p.m.
Hash
6262999b3f27180389f3bdb7fa516c310177cf7d
Parent
8863f956d9f6ab6759e8af147dbacb5e3f029a40
Modified files
.zlogin
shutdown.sh

.zlogin

3 additions and 0 deletions.

View changes Hide changes
1
1
2
2
# by pulling all changes in the repositories:
3
3
echo -e "Updating all repositories...\n"
4
4
cd ~/Repositories
5
5
for directory in */ ; do
6
6
	cd $directory
7
7
	git pull
8
8
	cd ..  # Returning to Repositories
9
9
done
10
10
11
11
cd ~  # Return to home
12
12
13
13
# Start X
+
14
rsync -a -P --delete -e ssh maarten@maartenv.be:/home/maarten/Documenten/Onderwijs ~/University &> /dev/null
+
15
+
16
# Start X
14
17
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
15
18
  exec startx
16
19
fi

shutdown.sh

38 additions and 0 deletions.

View changes Hide changes
+
1
# whether the repositories are handled properly, and aborts if there is still
+
2
# work to be done. Of course, it can be overridden anytime by manually issuing
+
3
# the shutdown command.
+
4
# This script is made to work with i3, because it uses the i3-nagbar to send
+
5
# messages to the user.
+
6
+
7
readyForShutdown=true
+
8
+
9
echo -e "Checking all repositories for outstanding commits...\n"
+
10
cd ~/Repositories
+
11
for directory in */ ; do
+
12
	cd $directory
+
13
    files="$(git status -s)"
+
14
    if [ "${files:0:2}" == " M" ]; then
+
15
        i3-nagbar -t warning -m "Repository $directory has uncommitted modifications!"
+
16
        readyForShutdown=false
+
17
        break
+
18
    else
+
19
        git push  # Pushing the changes to the upstream repo if applicable
+
20
    fi
+
21
	cd ..  # Returning to Repositories
+
22
done
+
23
+
24
cd ~  # Return to home
+
25
+
26
if [ "$readyForShutdown" == true ]; then
+
27
    echo -e "Synchronizing remaining university data...\n"
+
28
    rsync -a -P --delete -e ssh ~/University maarten@maartenv.be:/home/maarten/Documenten/Onderwijs &> /dev/null
+
29
fi
+
30
+
31
+
32
+
33
if [ "$readyForShutdown" == true ]; then
+
34
    # All set!
+
35
    echo -e "Normally, it would shut down now!\n"
+
36
    #shutdown now
+
37
fi
+
38