~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to doc/setup/usrmgt-server.init

  • Committer: Matt Giuca
  • Date: 2009-12-01 04:27:58 UTC
  • mfrom: (1164.2.46 sphinx-docs)
  • Revision ID: matt.giuca@gmail.com-20091201042758-wuxd9bdec00c283i
Merged sphinx-docs branch. This adds Sphinx documentation for the entire IVLE system (for system administrators and developers), and removes all of our random old document files (all either irrelevant, or moved into the Sphinx docs nicely). Currently incomplete, but ready to merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
 
3
 
# Works for Ubuntu. Check before using on other distributions
4
 
 
5
 
### BEGIN INIT INFO
6
 
# Provides:          usrmgt-server
7
 
# Required-Start:    $syslog $networking $urandom
8
 
# Required-Stop:     $syslog
9
 
# Default-Start:     2 3 4 5
10
 
# Default-Stop:      1
11
 
# Short-Description: IVLE user management server
12
 
# Description:       Daemon connecting to the IVLE user management database.
13
 
### END INIT INFO
14
 
 
15
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
16
 
DESC="IVLE user management server"
17
 
NAME=usrmgt-server
18
 
DAEMON=/usr/local/share/ivle/services/$NAME
19
 
PIDFILE=/var/run/$NAME.pid
20
 
SCRIPTNAME=/etc/init.d/usrmgt-server
21
 
 
22
 
# Exit if the daemon does not exist 
23
 
test -f $DAEMON || exit 0
24
 
 
25
 
# Load the VERBOSE setting and other rcS variables
26
 
[ -f /etc/default/rcS ] && . /etc/default/rcS
27
 
 
28
 
# Define LSB log_* functions.
29
 
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
30
 
. /lib/lsb/init-functions
31
 
 
32
 
#
33
 
# Function that starts the daemon/service
34
 
#
35
 
do_start()
36
 
{
37
 
        # Return
38
 
        #   0 if daemon has been started
39
 
        #   1 if daemon was already running
40
 
        #   2 if daemon could not be started
41
 
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null          || return 1
42
 
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON             || return 2
43
 
        # Add code here, if necessary, that waits for the process to be ready
44
 
        # to handle requests from services started subsequently which depend
45
 
        # on this one.  As a last resort, sleep for some time.
46
 
}
47
 
 
48
 
#
49
 
# Function that stops the daemon/service
50
 
#
51
 
do_stop()
52
 
{
53
 
        # Return
54
 
        #   0 if daemon has been stopped
55
 
        #   1 if daemon was already stopped
56
 
        #   2 if daemon could not be stopped
57
 
        #   other if a failure occurred
58
 
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
59
 
        RETVAL="$?"
60
 
        [ "$RETVAL" = 2 ] && return 2
61
 
        # Wait for children to finish too if this is a daemon that forks
62
 
        # and if the daemon is only ever run from this initscript.
63
 
        # If the above conditions are not satisfied then add some other code
64
 
        # that waits for the process to drop all resources that could be
65
 
        # needed by services started subsequently.  A last resort is to
66
 
        # sleep for some time.
67
 
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
68
 
        [ "$?" = 2 ] && return 2
69
 
        # Many daemons don't delete their pidfiles when they exit.
70
 
        rm -f $PIDFILE
71
 
        return "$RETVAL"
72
 
}
73
 
 
74
 
#
75
 
# Function that sends a SIGHUP to the daemon/service
76
 
#
77
 
do_reload() {
78
 
        #
79
 
        # If the daemon can reload its configuration without
80
 
        # restarting (for example, when it is sent a SIGHUP),
81
 
        # then implement that here.
82
 
        #
83
 
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
84
 
        return 0
85
 
}
86
 
 
87
 
case "$1" in
88
 
  start)
89
 
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
90
 
        do_start
91
 
        case "$?" in
92
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
93
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
94
 
        esac
95
 
        ;;
96
 
  stop)
97
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
98
 
        do_stop
99
 
        case "$?" in
100
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
101
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
102
 
        esac
103
 
        ;;
104
 
  #reload|force-reload)
105
 
        #
106
 
        # If do_reload() is not implemented then leave this commented out
107
 
        # and leave 'force-reload' as an alias for 'restart'.
108
 
        #
109
 
        #log_daemon_msg "Reloading $DESC" "$NAME"
110
 
        #do_reload
111
 
        #log_end_msg $?
112
 
        #;;
113
 
  restart|force-reload)
114
 
        #
115
 
        # If the "reload" option is implemented then remove the
116
 
        # 'force-reload' alias
117
 
        #
118
 
        log_daemon_msg "Restarting $DESC" "$NAME"
119
 
        do_stop
120
 
        case "$?" in
121
 
          0|1)
122
 
                do_start
123
 
                case "$?" in
124
 
                        0) log_end_msg 0 ;;
125
 
                        1) log_end_msg 1 ;; # Old process is still running
126
 
                        *) log_end_msg 1 ;; # Failed to start
127
 
                esac
128
 
                ;;
129
 
          *)
130
 
                # Failed to stop
131
 
                log_end_msg 1
132
 
                ;;
133
 
        esac
134
 
        ;;
135
 
  *)
136
 
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
137
 
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
138
 
        exit 3
139
 
        ;;
140
 
esac
141
 
 
142
 
: