sshd - svc - Simple service scripts and examples, to be used everywhere.
 (HTM) git clone git://r-36.net/svc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       sshd (516B)
       ---
            1 #!/bin/sh
            2 
            3 SERVICE="sshd"
            4 
            5 [ -e "/bin/svc.d/default/$SERVICE" ] && . "/bin/svc.d/default/$SERVICE"
            6 
            7 BIN=""
            8 for p in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin;
            9 do
           10         if [ -x "$p/$SERVICE" ];
           11         then
           12                 BIN="$p/$SERVICE"
           13                 break
           14         fi
           15 done
           16 [ -z "$BIN" ] && exit 1
           17 
           18 PID=$(pidof -o %PPID $BIN)
           19 
           20 case $1 in
           21         -s)
           22                 ssh-keygen -A
           23                 [ -d /var/empty ] || mkdir -p /var/empty
           24                 [ -z "$PID" ] && $BIN $PARAMS;
           25                 ;;
           26         -k)
           27                 [ -n "$PID" ] && kill -9 $PID &> /dev/null;
           28                 ;;
           29         *)
           30                 echo "usage: $0 -s|-k"
           31                 exit 1
           32 esac
           33