fixscripts
authorstephen
Mon, 21 Jun 2010 12:27:32 +0100
changeset 28 960ad5dd216e
parent 27 d42e3f15c91d
child 29 08c7354af189
fixscripts
sleeprtc.sh
stopproc.sh
--- a/sleeprtc.sh	Mon Jun 21 11:46:51 2010 +0100
+++ b/sleeprtc.sh	Mon Jun 21 12:27:32 2010 +0100
@@ -14,7 +14,7 @@
 #
 timenow=`date +"%H:%M"`
 #
-if [ $timenow \> "22:00" ]
+if [ $timenow \> $hourtowake ]
 then
     timetowake=`date -d "tomorrow $hourtowake" +"%s"`
 else
--- a/stopproc.sh	Mon Jun 21 11:46:51 2010 +0100
+++ b/stopproc.sh	Mon Jun 21 12:27:32 2010 +0100
@@ -7,6 +7,8 @@
 /etc/init.d/monit stop
 /etc/init.d/dtnN4Cmiddle stop
 /etc/init.d/dtnN4Crecv stop
+/etc/init.d/pushrecv stop
+/etc/init.d/addaccount stop
 /etc/init.d/dtn stop
 /etc/init.d/apache2 stop
 /etc/init.d/cron stop
@@ -15,3 +17,36 @@
 
 echo "`date` stopproc: unmounting /data" >> /var/log/logrtc.log
 /bin/umount /data
+
+# check if the umount worked
+checkdata=`mount | grep data`
+if [ "$checkdata" != "" ]
+then
+	echo "`date` Someone still messing with /data" >>/var/log/logrtc.log
+	# crap something up, ask anyone with an open handle to kill
+	# themselves
+	pids=`lsof | grep /data | awk '{print $2}' | sort | uniq`
+	for pid in $pids
+	do
+		echo "`date` asking $pid to close" >>/var/log/logrtc.log
+		kill -5 $pid
+	done
+	# give them a chance for last rites
+	sleep 5
+fi
+
+checkdata=`mount | grep data`
+if [ "$checkdata" != "" ]
+then
+	# crap something still up, kill 'em dead
+	echo "`date` Someone still stubbornly messing with /data" >>/var/log/logrtc.log
+	pids=`lsof | grep /data | awk '{print $2}' | sort | uniq`
+	for pid in $pids
+	do
+		echo "`date` forcing $pid to die" >>/var/log/logrtc.log
+		kill -9 $pid
+	done
+	# give them a chance for last rites
+	sleep 5
+fi
+