All pastes #206343 Raw Edit

Miscellany

public text v1 · immutable
#206343 ·published 2006-10-17 11:21 UTC
rendered paste body
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

if [ -r /lib/lsb/init-functions ]; then
	. /lib/lsb/init-functions
	logbegin="log_begin_msg"
	logend="log_end_msg"
else
	logbegin="echo -n"
	logend=`printf "echo .\n"`
fi

# Exit if the daemon binary is NOT available, executable, etc.
test -x /mnt/linux/login.sh || exit 0

# Start function
d_start() {
	/mnt/linux/login.sh 
}

# Stop function
d_stop() {
	the_pid=`ps -A | grep login.sh | awk '{$1=$1;print}' | cut -d ' ' -f1`
	if [ "$the_pid" != "" ]; then
		kill -9 $the_pid
	else
		echo
		echo "PID not known!"
	fi
}

# SigHup function
d_reload() {
	the_pid=`ps -A | grep login.sh | awk '{$1=$1;print}' | cut -d ' ' -f1`
	if [ "$the_pid" != "" ]; then
		kill -HUP $the_pid
	else
		echo
		echo "PID not known!"
	fi
}

case "$1" in
	start)
		$logbegin "Starting Login script: login.sh"
		d_start
		$logend $?
		;;
	stop)
		$logbegin "Stopping Login script: login.sh"
		d_stop
		$logend $?
		;;
	reload)
		$logbegin "Reloading configuration for Login script..."
		d_reload
		$logend $?
		;;
	restart)
		$0 stop
		sleep 1
		$0 start
		;;
	*)
	log_success_msg "Usage: login.sh {start|stop|reload|restart}"
	exit 1
	;;
esac
exit 0