initlog is deprecated. And, autofs is unused by any other part of the system.
[pl_sshd.git] / pl_sshd
1 #!/bin/bash
2 #
3 # Init file for PlanetLab OpenSSH server daemon (copied from standard
4 # sshd init file, minor modifications made).
5 #
6 # chkconfig: 2345 56 25
7 # description: PlanetLab OpenSSH server daemon
8 #
9 # processname: sshd
10 # config: /etc/ssh/ssh_host_key
11 # config: /etc/ssh/ssh_host_key.pub
12 # config: /etc/ssh/ssh_random_seed
13 # config: /etc/ssh/sshd_config
14 # pidfile: /var/run/pl_sshd.pid
15
16 # source function library
17 . /etc/rc.d/init.d/functions
18
19 # pull in sysconfig settings
20 [ -f /etc/sysconfig/pl_sshd ] && . /etc/sysconfig/pl_sshd
21
22 RETVAL=0
23 prog="pl_sshd"
24
25 # Some functions to make the below more readable
26 SSHD=/usr/local/sbin/pl_sshd
27 PID_FILE=/var/run/pl_sshd.pid
28
29 do_restart_sanity_check()
30 {
31         $SSHD -t
32         RETVAL=$?
33         if [ ! "$RETVAL" = 0 ]; then
34                 failure $"Configuration file or keys are invalid"
35                 echo
36         fi
37 }
38
39 start()
40 {
41         echo -n $"Starting $prog:"
42         #initlog -c "$SSHD $OPTIONS" && success || failure
43         $SSHD $OPTIONS && success || failure
44         RETVAL=$?
45         [ "$RETVAL" = 0 ] && touch /var/lock/subsys/pl_sshd
46         echo
47 }
48
49 stop()
50 {
51         echo -n $"Stopping $prog:"
52         killproc $prog -TERM
53         RETVAL=$?
54         [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/pl_sshd
55         echo
56 }
57
58 reload()
59 {
60         echo -n $"Reloading $prog:"
61         killproc $prog -HUP
62         RETVAL=$?
63         echo
64 }
65
66 case "$1" in
67         start)
68                 start
69                 ;;
70         stop)
71                 stop
72                 ;;
73         restart)
74                 stop
75                 start
76                 ;;
77         reload)
78                 reload
79                 ;;
80         condrestart)
81                 if [ -f /var/lock/subsys/pl_sshd ] ; then
82                         do_restart_sanity_check
83                         if [ "$RETVAL" = 0 ] ; then
84                                 stop
85                                 # avoid race
86                                 sleep 3
87                                 start
88                         fi
89                 fi
90                 ;;
91         status)
92                 status pl_sshd
93                 RETVAL=$?
94                 ;;
95         *)
96                 echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
97                 RETVAL=1
98 esac
99 exit $RETVAL