source: drbl-hadoop-0.1/drbl-hadoop-mount-disk @ 223

Last change on this file since 223 was 88, checked in by jazz, 16 years ago
  • some tiny updates
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#! /bin/sh
2#
3# skeleton  example file to build /etc/init.d/ scripts.
4#    This file should be used to construct scripts for /etc/init.d.
5#
6#    Written by Miquel van Smoorenburg <miquels@cistron.nl>.
7#    Modified for Debian
8#    by Ian Murdock <imurdock@gnu.ai.mit.edu>.
9#               Further changes by Javier Fernandez-Sanguino <jfs@debian.org>
10#
11# Version:  @(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
12#
13### BEGIN INIT INFO
14# Provides:          drbl-hadoop-mount-disk
15# Required-Start:    $network $local_fs
16# Required-Stop:
17# Should-Start:      $named
18# Should-Stop:
19# Default-Start:     2 3 4 5
20# Default-Stop:      0 1 6
21# Short-Description: mount local disk for Hadoop datanode daemon
22### END INIT INFO
23
24set -e
25
26DISK=/dev/sda1
27MOUNT=/var/lib/hadoop/
28
29if [ -f /etc/default/drbl-hadoop ] ; then
30  . /etc/default/drbl-hadoop
31fi
32
33PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
34NAME=drbl-hadoop-mount-disk
35DESC="mount local disk for Hadoop datanode daemon"
36
37PIDFILE=/var/run/drbl-hadoop.pid
38DODTIME=3                   # Time to wait for the server to die, in seconds
39                            # If this value is set too low you might not
40                            # let some servers to die gracefully and
41                            # 'restart' will not work
42
43start() {
44  if [ ! -x $MOUNT ]; then
45    mkdir -p $MOUNT
46    chown hadoop:hadoop $MOUNT
47  fi
48  mount $DISK $MOUNT
49  touch $PIDFILE
50}
51
52stop() {
53  umount $DISK
54  rm -f $PIDFILE
55}
56
57
58case "$1" in
59  start)
60        echo -n "Starting $DESC: "
61        start
62        if [ -f $PIDFILE ] ; then
63            echo "OK."
64        else
65            echo "ERROR."
66        fi
67  ;;
68  stop)
69        echo -n "Stopping $DESC: "
70        stop
71        if [ ! -f $PIDFILE ] ; then
72            echo "OK."
73        else
74            echo "ERROR."
75        fi
76  ;;
77  force-reload)
78  if [ -f $PIDFILE ] ; then
79    $0 restart
80  fi
81  ;;
82  restart)
83        echo -n "Restarting $DESC: "
84        if [ -f $PIDFILE ] ; then
85    stop
86  fi
87        [ -n "$DODTIME" ] && sleep $DODTIME
88        $0 start
89  ;;
90  status)
91    echo -n "$DISK is "
92    if [ -f $PIDFILE ] ;  then
93        echo "mounted"
94    else
95        echo "not mounted."
96        exit 1
97    fi
98    ;;
99  *)
100  N=/etc/init.d/$NAME
101  echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
102  exit 1
103  ;;
104esac
105
106exit 0
Note: See TracBrowser for help on using the repository browser.