ad340a6ca10f3fda9a4c6f323020e24a2b1e7485
[openafs.git] / src / packaging / RedHat / openafs-server.init
1 #!/bin/bash
2 #
3 # openafs-server        Start/Stop the OpenAFS Server
4 #
5 # chkconfig: 2345 49 51
6 # description: OpenAFS is a distributed filesystem.
7 #
8 # $Revision$
9
10 [ -f /etc/init.d/functions ] && . /etc/init.d/functions
11 [ -f /etc/sysconfig/openafs ] && . /etc/sysconfig/openafs
12
13
14 start() {
15         echo -n $"Starting openafs-server: "
16         if [ -e /var/lock/subsys/openafs-server ] ; then
17                 echo -n $"cannot start openafs-server: already running"
18                 failure $"cannot start openafs-server: already running"
19                 echo
20                 return 1
21         fi
22         /usr/afs/bin/bosserver $BOSSERVER_ARGS
23         RETVAL=$?
24         echo
25         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/openafs-server
26         return $RETVAL
27 }
28
29 stop() {
30         echo -n $"Stopping openafs-server: "
31         if [ ! -e /var/lock/subsys/openafs-server ] ; then
32                 echo -n $"cannot stop openafs-server: not running"
33                 failure $"cannot stop openafs-server: not running"
34                 echo
35                 return 1
36         fi
37         /usr/bin/bos shutdown localhost -wait -localauth
38         RETVAL=$?
39         if [ $RETVAL -ne 0 ] ; then
40                 echo -n $"failed to shutdown OpenAFS"
41                 failure $"failed to shutdown OpenAFS"
42                 echo
43                 return $RETVAL
44         fi
45         killproc bosserver
46         RETVAL=$?
47         echo
48         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/openafs-server
49         return $RETVAL
50 }
51
52 rhstatus() {
53         status bosserver
54 }
55
56 restart() {
57         stop || exit
58         start
59 }
60
61 case "$1" in
62   start)
63         start
64         ;;
65   stop)
66         stop
67         ;;
68   restart)
69         restart
70         ;;
71   status)
72         rhstatus
73         ;;
74   condrestart)
75         if [ "x$AFS_USE_BINARY_RESTART" = "xyes" ]; then
76             # this is what never shows up as
77             if [ `grep -c 'checkbintime 16 0 0 0 0' /usr/afs/local/BosConfig` = 1]; then
78                 [ -f /var/lock/subsys/openafs-server ] && restart || :
79             else
80                 echo $"deferring for newbinary restart"
81             fi
82         else
83             [ -f /var/lock/subsys/openafs-server ] && restart || :
84         fi
85         ;;
86   *)
87         echo $"Usage: $0 {start|stop|status|restart|condrestart}"
88         exit 1
89 esac