Whamcloud - gitweb
- add a helper to call bc with a specified precision
[fs/lustre-release.git] / lustre / scripts / lustre
1 #!/bin/sh
2 #
3 # lustre   This shell script takes care of starting and stopping Lustre
4 #
5 # chkconfig: 345 99 1
6 # description: Lustre Lite network File System.                              \
7 #              This starts both Lustre client and server functions.
8 # processname: lconf
9 # config: /etc/lustre/config.xml
10 # pidfile: /var/run/lustre.pid
11
12 SERVICE=lustre
13 LOCK=/var/lock/subsys/$SERVICE
14
15 : ${LUSTRE_CFG:=/etc/lustre/lustre.cfg}
16 [ -f ${LUSTRE_CFG} ] && . ${LUSTRE_CFG}
17
18 : ${LUSTRE_CONFIG_XML:=/etc/lustre/config.xml}
19 : ${LCONF:=/usr/sbin/lconf}
20 : ${LCONF_START_ARGS:="${LUSTRE_CONFIG_XML}"}
21 : ${LCONF_STOP_ARGS:="--force --cleanup ${LUSTRE_CONFIG_XML}"}
22
23 # Source function library.
24 if [ -f /etc/init.d/functions ] ; then
25    . /etc/init.d/functions
26 fi
27
28 # Source networking configuration.
29 if [ -f /etc/sysconfig/network ] ; then
30    . /etc/sysconfig/network
31 fi
32
33 # Check that networking is up.
34 [ "${NETWORKING}" = "no" ] && exit 0
35
36 [ -x ${LCONF} -a -f ${LUSTRE_CONFIG_XML} ] || exit 0
37
38 # Create /var/lustre directory 
39 # This is used by snmp agent for checking lustre services        \
40 #    status online/offline/online pending/offline pending.
41
42 [ -d ${STATUS_DIR:=/var/lustre} ] || mkdir -p $STATUS_DIR
43 STATUS=${STATUS_DIR}/sysStatus
44
45 start() {
46         echo -n "Starting $SERVICE: "
47         ${LCONF} ${LCONF_START_ARGS}
48         RETVAL=$?
49         echo $SERVICE
50         if [ $RETVAL -eq 0 ]; then
51                touch $LOCK
52               echo "online" >$STATUS
53         else
54               echo "online pending" >$STATUS
55         fi
56 }
57
58 stop() {
59         echo -n "Shutting down $SERVICE: "
60         ${LCONF} ${LCONF_STOP_ARGS}
61         RETVAL=$?
62         echo $SERVICE
63         rm -f $LOCK 
64         if [ $RETVAL -eq 0 ]; then
65               echo "offline" >$STATUS
66         else
67               echo "offline pending" >$STATUS
68         fi
69 }
70
71 restart() {
72         stop
73         start
74 }
75
76 # See how we were called.
77 case "$1" in
78   start)
79         start
80         ;;
81   stop)
82         stop
83         ;;
84   restart)
85         restart
86         ;;
87   status)
88         status $SERVICE
89         ;;
90   *)
91         echo "Usage: $SERVICE {start|stop|restart|status}"
92         exit 1
93 esac
94
95 exit $RETVAL