redhat: do not overwite the server CellServDB
[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         if [ -h /usr/vice/etc/CellServDB ]; then
17                 rm -f /usr/vice/etc/CellServDB
18         fi
19         echo -n $"Updating CellServDB: "
20         cat /usr/vice/etc/CellServDB.local /usr/vice/etc/CellServDB.dist > \
21         /usr/vice/etc/CellServDB
22         chmod 644 /usr/vice/etc/CellServDB
23         echo
24         echo -n $"Starting openafs-client: "
25         if [ -e /var/lock/subsys/openafs-client ] ; then
26                 echo -n $"cannot start openafs-client: already running"
27                 failure $"cannot start openafs-client: already running"
28                 echo
29                 return 1
30         fi
31         modprobe openafs
32         RETVAL=$?
33         if [ $RETVAL -ne 0 ] ; then
34                 echo -n $"failed to load openafs kernel module."
35                 failure $"failed to load openafs kernel module."
36                 echo
37                 return $RETVAL
38         fi
39         /usr/vice/etc/afsd $AFSD_ARGS
40         RETVAL=$?
41         echo
42         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/openafs-client
43         [ $RETVAL -eq 0 ] && [ "$AFS_POST_INIT" ] && $AFS_POST_INIT
44         return $RETVAL
45 }
46
47 stop() {
48         echo -n $"Stopping openafs-client: "
49         if [ ! -e /var/lock/subsys/openafs-client ] ; then
50                 echo -n $"cannot stop openafs-client: not running"
51                 failure $"cannot stop openafs-client: not running"
52                 echo
53                 return 1
54         fi
55         umount /afs
56         RETVAL=$?
57         echo
58         if [ $RETVAL -eq 0 ] ; then
59                 rmmod openafs
60                 RETVAL=$?
61         fi
62         if [ $RETVAL -eq 0 ] ; then
63                 rm -f /var/lock/subsys/openafs-client
64         fi
65         return $RETVAL
66 }
67
68 rhstatus() {
69         status afsd
70         return $?
71 }
72
73 restart() {
74         stop || exit
75         start
76 }
77
78 case "$1" in
79   start)
80         start
81         ;;
82   stop)
83         stop
84         ;;
85   restart)
86         restart
87         ;;
88   status)
89         rhstatus
90         exit $?
91         ;;
92   condrestart)
93         [ -f /var/lock/subsys/openafs-client ] && restart || :
94         ;;
95   *)
96         echo $"Usage: $0 {start|stop|status|restart|condrestart}"
97         exit 1
98 esac