#!/bin/sh

#########################
## RESTART INIT SCRIPT ##
#########################

## Released under the GNU General Public License (version 2 or above)

## Any lines in this file preceeded by a hash ('#') indicates a comment, and is not read by the interpreter.

#--------------------#
. /etc/profile
LOGFILE="$LOGDIR/$ME.log"
. /tmp/exports
#--------------------#

ls /etc/rc6.d > /tmp/reboot
while read service
do
	loadfile /etc/rc6.d/$service stop
done < /tmp/reboot
case "$LOADER" in
	"ios") print "Returning to the Homebrew Channel in 3 seconds...";;
	"mini") print "Restarting in 3 seconds...";;
esac
ps | grep -v -e "$0" -e "grep" -e "ps" -e "\[" -e "/etc/init/rc1" -e "launcher" -e "/bin/sh -i" -e "init" -e "kickstart" -e "PID" | awk '{ print $1 }' > /tmp/kill
mount | awk '{ print $3 }' | grep -v -e '/$' -e '/proc$' > /tmp/umount
while read kill; do
	kill $kill > /dev/null 2>&1
done < /tmp/kill
while read umount; do
	umount -l $umount > /dev/null 2>&1
done < /tmp/umount
sleep 3
mount -o remount,ro /
umount -l /proc
/etc/reboot -f
