Upload Tizen:Base source
[framework/base/util-linux-ng.git] / misc-utils / uuidd.rc
1 #! /bin/sh -e
2 ### BEGIN INIT INFO
3 # Provides:          uuidd
4 # Required-Start:    $time $local_fs
5 # Required-Stop:     $time $local_fs
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: uuidd daemon
9 # Description:       Init script for the uuid generation daemon
10 ### END INIT INFO
11 #
12 # Author:       "Theodore Ts'o" <tytso@mit.edu>
13 #
14 set -e
15
16 # libuuid is able to execute the uuid daemon on-demand -- in such a case
17 # the daemon binary must be setuid to an unprivileged user (e.g. uuidd:uuidd).
18 #                                                    [-- kzak Jun 2009]
19 UUIDD_ON_DEMAND_ONLY="no"
20
21 PATH=/bin:/usr/bin:/sbin:/usr/sbin
22 DAEMON=/usr/sbin/uuidd
23 UUIDD_USER=uuidd
24 UUIDD_GROUP=uuidd
25 UUIDD_DIR=/var/run/uuidd
26 PIDFILE=$UUIDD_DIR/uuidd.pid
27
28 test -x $DAEMON || exit 0
29
30 . /lib/lsb/init-functions
31
32 case "$1" in
33   start)
34         log_daemon_msg "Starting uuid generator" "uuidd"
35         if ! test -d $UUIDD_DIR; then
36                 mkdir -p $UUIDD_DIR
37                 chown -R $UUIDD_USER:$UUIDD_GROUP $UUIDD_DIR
38         fi
39         if test "$UUIDD_ON_DEMAND_ONLY" = yes; then
40                 echo -n "(on demand only)"
41         else
42                 start_daemon -p $PIDFILE $DAEMON
43         fi
44         log_end_msg $?
45     ;;
46   stop)
47         log_daemon_msg "Stopping uuidd generator" "uuidd"
48         killproc -p $PIDFILE $DAEMON
49         log_end_msg $?
50     ;;
51   status)
52         if pidofproc -p $PIDFILE $DAEMON >& /dev/null ; then
53             echo "$DAEMON is running";
54             exit 0;
55         else
56             echo "$DAEMON is NOT running";
57             if test -f $PIDFILE; then exit 2; fi
58             exit 3;
59         fi
60     ;;
61   force-reload|restart)
62     $0 stop
63     $0 start
64     ;;
65   *)
66     echo "Usage: /etc/init.d/uuidd {start|stop|restart|force-reload}"
67     exit 1
68     ;;
69 esac
70
71 exit 0