Version increased to unfs3_0.9.22+dfsg-1maemo3
[unfs3] / unfs3 / unfsd.init
1 #!/bin/bash
2 # -*- mode: shell-script; coding: UTF-8 -*-
3 #
4 # chkconfig: 235 99 10
5 # description: Start or stop the unfs3 server
6 #
7 ### BEGIN INIT INFO
8 # Provides: unfsd
9 # Required-Start: $network
10 # Required-Stop: $network
11 # Default-Start: 2 3 4 5
12 # Default-Stop: 0 1 6
13 # Description: Start or stop the unfs3 server
14 ### END INIT INFO
15
16 description="unfs3 NFS server"
17 lockfile="/var/lock/subsys/unfsd"
18 pidfile="/var/run/unfsd.pid"
19
20
21 case "$1" in
22     'start')
23         echo "Starting" ${description}
24         /usr/sbin/unfsd -i ${pidfile}
25         RETVAL=$?
26         if [ "${RETVAL}" = "0" ]; then
27             touch ${lockfile} >/dev/null 2>&1
28         fi
29         ;;
30     'stop')
31         echo "Shutting down" ${description}
32         if [ -s ${pidfile} ]; then
33             pid=`cat ${pidfile}`
34             kill -TERM ${pid} 2>/dev/null
35             sleep 2
36             if kill -0 ${pid} 2>/dev/null; then
37                 kill -KILL ${pid}
38             fi
39         fi
40         rm -f ${lockfile} ${pidfile}
41         ;;
42     'status')
43         if [ -s ${pidfile} ]; then
44                 pid=`cat ${pidfile}`
45                 if kill -0 ${pid} 2>/dev/null; then
46                     echo "${description} (pid ${pid}) is running"
47                     RETVAL=0
48                 else
49                     echo "${description} is stopped"
50                     RETVAL=1
51                 fi
52         else
53             echo "${description} is stopped"
54             RETVAL=1
55         fi
56         ;;
57     'restart')
58         /etc/init.d/unfsd stop && /etc/init.d/unfsd start
59         RETVAL=$?
60         ;;
61     'condrestart')
62         [ -f /var/lock/subsys/unfsd ] && /etc/init.d/unfsd stop && /etc/init.d/unfsd start
63         RETVAL=$?
64         ;;
65     *)
66         echo "Usage: $0 {start|stop|restart|condrestart|status}"
67         RETVAL=1
68         ;;
69 esac
70 exit $RETVAL
71