Hello everyone,
I have a server where I know I want to start some programs at boot in a screen. I know exaclty what I want them to do.
Code:
at start issue:
su USER -c 'screen -dmS irssi irssi'
at shutdown (or reboot):
su USER -c 'screen -S irssi -X stuff "/quit $(echo -ne "\r")"'
Now I would like to have this run in the "service list and be able to select it using chkconfig.
So I am guessing it will look something like this: (not sure how to write the bold part)
Code:
#!/bin/sh
#
# chkconfig: - 92 35
# description: Starts and stops the IRSSI in \
# detached screen for jacco.
# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 1
fi
# Avoid using root's TMPDIR
unset TMPDIR
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1
RETVAL=0
start() {
KIND="IRSSI"
echo -n $"Starting $KIND services: "
su USER -c 'screen -dmS irssi irssi'
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && succes || failure
RETVAL=1
return $RETVAL
}
stop() {
KIND="IRSSI"
echo -n $"Shutting down $KIND services: "
su USER -c 'screen -S irssi -X stuff "/quit $(echo -ne "\r")"'
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && succes || failure
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo $"Usage: $0 {start|stop}"
exit 2
esac
exit $?
Starting does work in this script but it is reported back as failed ..... stopping does not work (but reports it does)