#!/bin/sh # Sample autorun script cd `dirname $0` # Turn on the red LED echo 1 > /sys/class/leds/red/brightness [ -f cuImage.warp ] && warploader -p kernel cuImage.warp [ -f uRamdisk ] && warploader -p root uRamdisk kill_httpd () { local PS=`ps` if echo $PS | fgrep -q lighttpd ; then echo "lighttpd must be shut down" killall lighttpd sleep 5 PS=`ps` if echo $PS | fgrep -q lighhttpd ; then echo "lighttpd will not die" killall -9 lighttpd sleep 5 PS=`ps` if echo $PS | fgrep -q lighttpd ; then echo "It looks like lighttpd is a zombie" fi fi fi } kill_asterisk () { local PS=`ps` if echo $PS | sed -e 's|egrep /bin/asterisk||' | fgrep -q "/bin/asterisk" ; then echo "asterisk must be shut down" killall asterisk killall safe_asterisk sleep 5 PS=`ps` if echo $PS | sed -e 's|egrep /bin/asterisk||' | fgrep -q "/bin/asterisk" ; then echo "asterisk will not die" killall -9 asterisk sleep 5 PS=`ps` if echo $PS | sed -e 's|egrep /bin/asterisk||' | fgrep -q "/bin/asterisk" ; then echo "It looks like asterisk is a zombie" fi fi if echo $PS | fgrep -q safe_asterisk ; then echo "safe_asterisk will not die" killall -9 safe_asterisk sleep 5 PS=`ps` if echo $PS | fgrep -q safe_asterisk ; then echo "It looks like safe_asterisk is a zombie" fi fi fi } unmount_persistent () { if mount | fgrep -q /persistent ; then # In order to unmount all of the persistent partitions, we need to kill off a bunch # of processes killall klogd killall syslogd # The following sed replace will be undone when the system boots back up to it's default state # as /etc/inittab isn't persistent. We can't just kill svscan. You have to first comment # it out of inittab and then kill -HUP 1 to get it to die. We need it dead or we can't # kill supervise. If we can't kill supervise, we can't kill multilog which is holding up # our ability to unmount the persistent partition holding /var sed -e "s|::respawn:/sbin/svscan /service|#::respawn:/sbin/svscan /service|" -i /etc/inittab kill -HUP 1 killall supervise killall multilog kill_httpd kill_asterisk umount /persistent || { logger "Unable to unmount persistent"; return=1; } if mount | fgrep -q /persistent1 ; then umount /persistent1 || { logger "Unable to unmount persistent1"; return=1; } fi if mount | fgrep -q /persistent2 ; then umount /persistent2 || { logger "Unable to unmount persistent2"; return=1; } fi if mount | fgrep -q /persistent3 ; then umount /persistent3 || { logger "Unable to unmount persistent3"; return=1; } fi if [ $return -eq 1 ] ; then return 1; fi fi return 0 } # Persistent is a bit trickier since we must unmount before flashing if [ -f image.jffs2 ] ; then if unmount_persistent; then warploader -p persistent image.jffs2 warploader -p persistent1 image1.jffs2 warploader -p persistent2 image2.jffs2 fi fi # Turn off red led echo 0 > /sys/class/leds/red/brightness