-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncHome
More file actions
executable file
·47 lines (38 loc) · 832 Bytes
/
syncHome
File metadata and controls
executable file
·47 lines (38 loc) · 832 Bytes
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
#!/bin/bash
ME=$(basename $0)
LOCK=/home/michael/.$ME.lock
GO=false
for NET in $(hostname -I)
do
[ $NET == "10.0.0.4" ] && GO=true
[ $NET == "10.0.0.5" ] && GO=true
done
if ! [ $GO = true ]
then
exit
fi
ping -c 1 nas > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "Cannot find nas. Maybe we are not at home!"
exit 1
fi
if [ -e $LOCK ]
then
#echo "Lock exists: $LOCK"
LOCKPID=$(head -1 $LOCK)
#echo LOCKPID = $LOCKPID
if [ ! -z $(ps ax | grep -v grep | grep $LOCKPID | gawk '{print $1}') ]
then
echo "Instance is already running: $LOCKPID"
exit 1
fi
echo "Removing stale lock: $LOCK $LOCKPID"
rm $LOCK
fi
# set up the lock
echo $$ > $LOCK
# go.
nice rsync --delete -avxPe ssh /home/michael/ nas:/common/sync/hourly/mate/ --exclude VMs
# remove the lock
rm $LOCK