shutdown.sh
1 |
|
2 |
# whether the repositories are handled properly, and aborts if there is still |
3 |
# work to be done. Of course, it can be overridden anytime by manually issuing |
4 |
# the shutdown command. |
5 |
# This script is made to work with i3, because it uses the i3-nagbar to send |
6 |
# messages to the user. |
7 |
|
8 |
readyForShutdown=true |
9 |
|
10 |
echo -e "Checking all repositories for outstanding commits...\n" |
11 |
cd ~/Repositories |
12 |
for directory in */ ; do |
13 |
cd $directory |
14 |
echo -e "Checking $directory...\n" |
15 |
files="$(git status -s)" |
16 |
if [ "${files:0:2}" == " M" ]; then |
17 |
i3-nagbar -t warning -m "Repository $directory has uncommitted modifications!" |
18 |
readyForShutdown=false |
19 |
break |
20 |
else |
21 |
git push # Pushing the changes to the upstream repo if applicable |
22 |
fi |
23 |
cd .. # Returning to Repositories |
24 |
done |
25 |
|
26 |
cd ~ # Return to home |
27 |
|
28 |
if [ "$readyForShutdown" == true ]; then |
29 |
echo -e "Synchronizing remaining university data...\n" |
30 |
rsync -a -P --delete -e ssh ~/University maarten@maartenv.be:/home/maarten/Documenten |
31 |
rsync -a -P --delete -e ssh ~/shared maarten@maartenv.be:/home/maarten/backup |
32 |
# XXX: The receiving server must also have rsync installed! |
33 |
fi |
34 |
|
35 |
|
36 |
|
37 |
if [ "$readyForShutdown" == true ]; then |
38 |
# All set! |
39 |
echo -e "All tasks completed, system will now terminate. Have a furry day. =3\n" |
40 |
sleep 1 # Necessary to let the nice furry pun display long enough OwO |
41 |
shutdown now |
42 |
fi |
43 |