ready for test
authorstephen
Tue, 20 Dec 2016 13:29:30 +0000
changeset 38 648f8a87e709
parent 37 d05ba048cb2d
child 39 b6f3231244dd
ready for test
pbm
stopproc.sh
--- a/pbm	Wed Dec 14 15:51:59 2016 +0000
+++ b/pbm	Tue Dec 20 13:29:30 2016 +0000
@@ -51,6 +51,7 @@
 	#   0 if daemon has been started
 	#   1 if daemon was already running
 	#   2 if daemon could not be started
+	/usr/sbin/ker-on >>/var/log/battery.log
 	start-stop-daemon --start --quiet -m --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
 		|| return 1
 	start-stop-daemon --start -b --quiet -m --pidfile $PIDFILE --exec $DAEMON -- \
@@ -81,6 +82,7 @@
 	# needed by services started subsequently.  A last resort is to
 	# sleep for some time.
 	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+	/usr/sbin/ker-off >>/var/log/battery.log
 	[ "$?" = 2 ] && return 2
 	# Many daemons don't delete their pidfiles when they exit.
 	rm -f $PIDFILE
--- a/stopproc.sh	Wed Dec 14 15:51:59 2016 +0000
+++ b/stopproc.sh	Tue Dec 20 13:29:30 2016 +0000
@@ -3,68 +3,75 @@
 # stopproc.sh
 #
 echo "`date` stopproc: taking down processes" >> /var/log/logrtc.log
-#
-/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
-/etc/init.d/dhcp3-server stop
-/etc/init.d/mysql stop
 
-echo "`date` stopproc: unmounting /data" >> /var/log/logrtc.log
-/bin/umount /data
+# when doing dtn, more to do, for loradtn, nothing specific for now
+DTNNODE="no"
 
-# check if the umount worked
-checkdata=`mount | grep data`
-if [ "$checkdata" != "" ]
+if [ "$DTNNODE" != "no" ]
 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
-		line=`ps -fp $pid | tail -1`
-		echo "`date` $pid is $line" >>/var/log/logrtc.log
-		kill -5 $pid
-	done
-	# give them a chance for last rites
-	sleep 5
-	echo "`date` stopproc: unmounting /data (2nd time)" >> /var/log/logrtc.log
+	#
+	/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
+	/etc/init.d/dhcp3-server stop
+	/etc/init.d/mysql stop
+
+	echo "`date` stopproc: unmounting /data" >> /var/log/logrtc.log
 	/bin/umount /data
 
-fi
+	# 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
+			line=`ps -fp $pid | tail -1`
+			echo "`date` $pid is $line" >>/var/log/logrtc.log
+			kill -5 $pid
+		done
+		# give them a chance for last rites
+		sleep 5
+		echo "`date` stopproc: unmounting /data (2nd time)" >> /var/log/logrtc.log
+		/bin/umount /data
+
+	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
-		line=`ps -fp $pid | tail -1`
-		echo "`date` $pid is $line" >>/var/log/logrtc.log
-		kill -9 $pid
-	done
-	# give them a chance for last rites
-	sleep 5
-	echo "`date` stopproc: unmounting /data (3nd time)" >> /var/log/logrtc.log
-	/bin/umount /data
-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
+			line=`ps -fp $pid | tail -1`
+			echo "`date` $pid is $line" >>/var/log/logrtc.log
+			kill -9 $pid
+		done
+		# give them a chance for last rites
+		sleep 5
+		echo "`date` stopproc: unmounting /data (3nd time)" >> /var/log/logrtc.log
+		/bin/umount /data
+	fi
 
-checkdata=`mount | grep data`
-if [ "$checkdata" != "" ]
-then
-	# really crap. Just reboot
-	echo "`date` Still can't umount /data - rebooting" >>/var/log/logrtc.log
-	/sbin/reboot
+	checkdata=`mount | grep data`
+	if [ "$checkdata" != "" ]
+	then
+		# really crap. Just reboot
+		echo "`date` Still can't umount /data - rebooting" >>/var/log/logrtc.log
+		/sbin/reboot
+	fi
 fi
 
 echo "`date` Finished stopproc.sh" >>/var/log/logrtc.log