caaf89095b446d298206f553b41db6fb4190fbad
[openafs.git] / src / packaging / RedHat / openafs-client.init
1 #!/bin/bash
2 #
3 # openafs-client        Start/Stop the OpenAFS Client
4 #
5 # chkconfig: 2345 50 50
6 # description: OpenAFS is a distributed filesystem.
7 # Should-Start: dkms
8 #
9 # $Revision$
10
11 [ -f /etc/init.d/functions ] && . /etc/init.d/functions
12 [ -f /etc/sysconfig/openafs ] && . /etc/sysconfig/openafs
13
14
15 start() {
16         echo -n $"Updating CellServDB: "
17         cat /usr/vice/etc/CellServDB.local /usr/vice/etc/CellServDB.dist > \
18                /usr/vice/etc/CellServDB
19         chmod 644 /usr/vice/etc/CellServDB
20         echo
21         echo -n $"Starting openafs-client: "
22         if [ -e /var/lock/subsys/openafs-client ] ; then
23                 echo -n $"cannot start openafs-client: already running"
24                 failure $"cannot start openafs-client: already running"
25                 echo
26                 return 1
27         fi
28         modprobe openafs
29         RETVAL=$?
30         if [ $RETVAL -ne 0 ] ; then
31                 echo -n $"failed to load openafs kernel module."
32                 failure $"failed to load openafs kernel module."
33                 echo
34                 return $RETVAL
35         fi
36         /usr/vice/etc/afsd $AFSD_ARGS
37         RETVAL=$?
38         echo
39         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/openafs-client
40         [ $RETVAL -eq 0 ] && [ "$AFS_POST_INIT" ] && $AFS_POST_INIT
41         return $RETVAL
42 }
43
44 stop() {
45         echo -n $"Stopping openafs-client: "
46         if [ ! -e /var/lock/subsys/openafs-client ] ; then
47                 echo -n $"cannot stop openafs-client: not running"
48                 failure $"cannot stop openafs-client: not running"
49                 echo
50                 return 1
51         fi
52         umount /afs
53         RETVAL=$?
54         echo
55         if [ $RETVAL -eq 0 ] ; then
56                 rmmod openafs
57                 RETVAL=$?
58         fi
59         if [ $RETVAL -eq 0 ] ; then
60                 rm -f /var/lock/subsys/openafs-client
61         fi
62         return $RETVAL
63 }
64
65 rhstatus() {
66         status afsd
67         return $?
68 }
69
70 restart() {
71         stop || exit
72         start
73 }
74
75 case "$1" in
76   start)
77         start
78         ;;
79   stop)
80         stop
81         ;;
82   restart)
83         restart
84         ;;
85   status)
86         rhstatus
87         exit $?
88         ;;
89   condrestart)
90         [ -f /var/lock/subsys/openafs-client ] && restart || :
91         ;;
92   *)
93         echo $"Usage: $0 {start|stop|status|restart|condrestart}"
94         exit 1
95 esac