#! /bin/sh # # /sbin/init.d/psion # . /etc/rc.config # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. test $link = $base && START_PSION=yes test "$START_PSION" = yes || exit 0 test -f @prefix@/sbin/ncpd || exit 0 test -f @prefix@/sbin/plpnfsd || exit 0 test -f @prefix@/sbin/plpprintd || exit 0 # The echo return value for success (defined in /etc/rc.config). showresult() { test RETVAL -eq 0 && echo -e $rc_done || echo -e $rc_failed } showstatus() { ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. checkproc @prefix@/sbin/$1 && \ echo -n "$1 running " || \ echo -n "No running $1 " } start() { echo "Starting Psion support ..." RETVAL=0 if test "$START_NCPD" = "yes" ; then echo -n " ncpd: " /sbin/startproc @prefix@/sbin/ncpd $NCPD_ARGS RETVAL=$? showresult fi if test "$START_PLPNFSD" = "yes" ; then echo -n " plpnfsd: " /sbin/startproc @prefix@/sbin/plpnfsd $PLPNFSD_ARGS RETVAL=$? showresult fi if test "$START_PLPPRINTD" = "yes" ; then echo -n " plpprintd: " /sbin/startproc @prefix@/sbin/plpprintd $PLPPRINTD_ARGS RETVAL=$? showresult fi return $RETVAL } stop() { echo "Stopping Psion support ..." if test "$START_PLPNFSD" = "yes" ; then echo -n " plpnfsd: " /bin/killproc -HUP plpnfsd WAIT=5 while test $WAIT -gt 0 ; do test -z "`pidof plpnfsd`" && break; sleep 1 # allow plpnfsd flushing it's cache WAIT=`expr $WAIT - 1` done test -z "`pidof plpnfsd`" || killproc plpnfsd RETVAL=$? showresult fi if test "$START_PLPPRINTD" = "yes" ; then echo -n " plpprintd: " /sbin/killproc -TERM plpprintd RETVAL=$? showresult fi if test "$START_NCPD" = "yes" ; then echo -n " ncpd: " /sbin/killproc -TERM ncpd RETVAL=$? showresult fi return $RETVAL } case "$1" in start) start ;; stop) stop ;; reload|restart) ## If first returns OK call the second, if first or ## second command fails, set echo return value. $0 stop && $0 start || return=$rc_failed ;; status) echo -n "Checking for Psion support: " showstatus ncpd showstatus plpnfsd showstatus plpprintd ;; *) echo "Usage: $0 {start|stop|status|restart}" exit 1 ;; esac # Inform the caller not only verbosely and set an exit status. test "$return" = "$rc_done" || exit 1 exit 0