-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.sh
66 lines (56 loc) · 1.33 KB
/
sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/local/bin/bash
# Vula course resource synchroniser
# Version 6.0
# Gianluca Truda
# 20 February 2018
# Fill in the details below
CSC="8139d0af-88f1-492c-9ee6-58f1655428e8"
DIR="/Users/gianlucatruda/Documents/GIANLUCA/Current/resources"
#-------------------------------
DATE="`date '+%Y_%m_%d__%H_%M_%S'`"
TIMEOUTCOUNT=0
NETNAME=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
function SYNC {
clear
echo
echo $DATE
echo
echo Clearing Volumes...
rmdir //Volumes/*
echo
echo Mounting Drives...
osascript -e ' mount volume "https://vula.uct.ac.za/dav/'$CSC'" '
cd /Users/gianlucatruda/Desktop
echo Synchronising…
rsync -avzh --progress //Volumes/$CSC'-1'/* $DIR/csc
# echo Unmounting Drives…
# diskutil unmount //Volumes/$CSC'-1'
echo Sync Complete on $DATE
echo
echo _______________________________
TIMEOUTCOUNT=0
}
function CHECK {
wget -q --spider http://google.com
if [ “$?” == “0” ]
then
echo
echo Active network — $NETNAME
SYNC
elif [ “$?” != “0” ]
then
echo
if [ $TIMEOUTCOUNT -lt 5 ]
then
((TIMEOUTCOUNT+=1))
sleep 60
echo Time Outs: $TIMEOUTCOUNT
CHECK
elif [ $TIMEOUTCOUNT -ge 5 ]
then
echo Network Down on $DATE
echo _______________________________
fi
fi
}
CHECK