s4: remove unused dbwrap code
[jra/samba/.git] / source4 / cluster / ctdb / packaging / RHEL / setup / ctdb.init
1 #!/bin/sh
2 #
3 # chkconfig: - 90 36
4 # description: Starts and stops the clustered tdb daemon
5 #
6 # pidfile: /var/run/ctdbd/ctdbd.pid
7
8 # Source function library.
9 if [ -f /etc/init.d/functions ] ; then
10   . /etc/init.d/functions
11 elif [ -f /etc/rc.d/init.d/functions ] ; then
12   . /etc/rc.d/init.d/functions
13 else
14   exit 0
15 fi
16
17 # Avoid using root's TMPDIR
18 unset TMPDIR
19
20 # Source networking configuration.
21 . /etc/sysconfig/network
22
23 CTDB_OPTIONS=""
24
25 # pull in admin specified config 
26 if [ -f /etc/sysconfig/ctdb ]; then
27    . /etc/sysconfig/ctdb 
28 fi
29
30 # Check that networking is up.
31 [ ${NETWORKING} = "no" ] && exit 0
32
33 # build up CTDB_OPTIONS variable
34 [ -z "$LOGFILE" ]          || CTDB_OPTIONS="$CTDB_OPTIONS --logfile=$LOGFILE"
35 [ -z "$NODES" ]            || CTDB_OPTIONS="$CTDB_OPTIONS --nlist=$NODES"
36 [ -z "$CTDB_SOCKET" ]      || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET"
37 [ -z "$PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$PUBLIC_ADDRESSES"
38 [ -z "$PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$PUBLIC_INTERFACE"
39 [ -z "$DBDIR" ]            || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$DBDIR"
40 [ -z "$EVENT_SCRIPT" ]     || CTDB_OPTIONS="$CTDB_OPTIONS --event-script $EVENT_SCRIPT"
41 [ -z "$TRANSPORT" ]        || CTDB_OPTIONS="$CTDB_OPTIONS --transport $TRANSPORT"
42 [ -z "$DEBUGLEVEL" ]       || CTDB_OPTIONS="$CTDB_OPTIONS -d $DEBUGLEVEL"
43
44 start() {
45         echo -n $"Starting ctdbd services: "
46         daemon ctdbd $CTDB_OPTIONS
47         RETVAL=$?
48         echo
49         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || \
50            RETVAL=1
51         return $RETVAL
52 }       
53
54 stop() {
55         echo -n $"Shutting down ctdbd services: "
56         ctdb shutdown
57         RETVAL=$?
58         echo
59         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
60         echo ""
61         return $RETVAL
62 }       
63
64 restart() {
65         stop
66         start
67 }       
68
69 rhstatus() {
70         ctdb status
71         if [ $? -ne 0 ] ; then
72                 return 1
73         fi
74 }       
75
76
77 # Allow status as non-root.
78 if [ "$1" = status ]; then
79        rhstatus
80        exit $?
81 fi
82
83 case "$1" in
84   start)
85         start
86         ;;
87   stop)
88         stop
89         ;;
90   restart)
91         restart
92         ;;
93   status)
94         rhstatus
95         ;;
96   condrestart)
97         [ -f /var/lock/subsys/ctdb ] && restart || :
98         ;;
99   *)
100         echo $"Usage: $0 {start|stop|restart|status|condrestart}"
101         exit 1
102 esac
103
104 exit $?