Can't Detach from a startup script
I'm trying to run Maple12 from my Debian box. I've hacked a startup
script together that looks like this:
<Beginning of Script>
==============
#! /bin/sh
# Maple 12
# I hacked this script from a copy of the "lisa" start-up script; no
guarantees that it works properly.
# Kent West, 14 June 2007
#
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/Maple_Network_Tools/FLEXlm/lmgrd
OPT=" -c /usr/local/Maple_Network_Tools/activate/Maple12.lic -l
/var/log/maplelicense"
NAME=lmgrd
PIDFILE=/var/run/$NAME.pid
DESC="Maple License Server"
USER=maple
test -f $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon -c $USER --start --quiet --pidfile $PIDFILE
--exec $DAEMON -- $OPT \
> /dev/null
echo $(pidof lmgrd) > $PIDFILE
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
--exec $DAEMON
rm -f $PIDFILE
echo "$NAME."
;;
reload|force-reload)
echo "Reloading $DESC configuration files."
start-stop-daemon --stop --quiet --signal 1 --pidfile $PIDFILE \
--exec $DAEMON
;;
restart)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
--exec $DAEMON
rm -f $PIDFILE
sleep 1
start-stop-daemon -c $USER --start --quiet --pidfile $PIDFILE
--exec $DAEMON -- $OPT \
> /dev/null
echo $(pidof lmgrd) > $PIDFILE
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
============
</End of Script>
Tonight I added in the "-c $USER" piece under the "start" and "restart"
stanzas, because otherwise the deamon was running as root, which is not
recommended by makers of Maple. (I created a user named "maple" and set
the shell to /bin/false; anything else I should do to tighten the
security on that user?)
Before I made this change, I could ssh into the box, run "sudo
/etc/init.d/maplelicense start", and then exit from my ssh session.
Now when I run the script, my ssh session won't let go; it just hangs
after I type "exit". If I ssh in from another shell and run "sudo
/etc/init.d/maplelicense stop", my first ssh session then terminates.
I see from the start-stop-daemon man page that I might can throw in a
"-b" to force a detachment, but is that the correct way to fix my
problem? The man page suggests that this should be a last resort.
Thanks!
--
Kent West <")))><
Westing Peacefully - http://kentwest.blogspot.com
Reply to: