redhat-packaging-updates-20061201
[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 #
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 $"Updating CellServDB: "
16         cat /usr/vice/etc/CellServDB.local /usr/vice/etc/CellServDB.dist > \
17                /usr/vice/etc/CellServDB
18         chmod 644 /usr/vice/etc/CellServDB
19         echo
20         echo -n $"Updating SuidCells: "
21         cat /usr/vice/etc/SuidCells.local /usr/vice/etc/SuidCells.dist > \
22                /usr/vice/etc/SuidCells
23         chmod 644 /usr/vice/etc/SuidCells
24         echo
25         echo -n $"Starting openafs-client: "
26         if [ -e /var/lock/subsys/openafs-client ] ; then
27                 echo -n $"cannot start openafs-client: already running"
28                 failure $"cannot start openafs-client: already running"
29                 echo
30                 return 1
31         fi
32         modprobe openafs
33         RETVAL=$?
34         if [ $RETVAL -ne 0 ] ; then
35                 echo -n $"failed to load openafs kernel module."
36                 failure $"failed to load openafs kernel module."
37                 echo
38                 return $RETVAL
39         fi
40         /usr/vice/etc/afsd $AFSD_ARGS
41         RETVAL=$?
42         echo
43         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/openafs-client
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                 rm -f /var/lock/subsys/openafs-client
60                 rmmod openafs
61         fi
62         return $RETVAL
63 }
64
65 rhstatus() {
66         status afsd
67 }
68
69 restart() {
70         stop || exit
71         start
72 }
73
74 case "$1" in
75   start)
76         start
77         ;;
78   stop)
79         stop
80         ;;
81   restart)
82         restart
83         ;;
84   status)
85         rhstatus
86         ;;
87   condrestart)
88         [ -f /var/lock/subsys/openafs-client ] && restart || :
89         ;;
90   *)
91         echo $"Usage: $0 {start|stop|status|restart|condrestart}"
92         exit 1
93 esac