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
67
68
69
|
#!/usr/bin/env bash
. `dirname $0`/../lib/init.sh
. $BASE/lib/common.sh
NODE=$1
if [ "$NODE" == "" ]; then
NODE=$HOST
fi
NODEDIR=$BASE/nodes/$NODE
PKGS=$NODEDIR/pkgs
PIDDIR=$BASE/var/run
#
# Cleanup lock files
#
grep -v '^\s*#' $PKGS | while read pkg
do
PKGDIR=$BASE/pkgs/$pkg
TARGET=`get_value "$PKGDIR/target"`
LOCKFILE=$TARGET/.SYNC-in-Progress-$HOST
PIDFILE=$PIDDIR/sedot-$pkg.pid
if [ -f $LOCKFILE ]; then
CLEANUP=1
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
ps $PID | grep sedot | grep $pkg > /dev/null 2>&1
[ "$?" -eq "0" ] && CLEANUP=0
fi
if [ "$CLEANUP" -eq "1" ]; then
# The process is not running anymore, then cleanup
echo "Removing $LOCKFILE"
rm -f $LOCKFILE
echo "Removing $PIDFILE"
rm -f $PIDFILE
fi
fi
done
#
# Cleanup pid file
#
for pidfile in $PIDDIR/sedot-*.pid
do
PKG=`echo $pidfile | sed 's/.*sedot-\(.*\).pid/\1/'`
PID=`cat $pidfile`
ps $PID | grep sedot | grep $PKG > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
# The process is not running anymore, then cleanup
echo "Removing $pidfile"
rm -f $pidfile
fi
done
echo "done."
|