/[irc-logger]/trunk/etc/init.d/irc-logger
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/etc/init.d/irc-logger

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (hide annotations)
Fri Jun 8 12:06:48 2007 UTC (14 years, 6 months ago) by dpavlin
File size: 4321 byte(s)
fix binary (er, script?) name
1 dpavlin 47 #! /bin/sh
2     ### BEGIN INIT INFO
3     # Provides: irc-logger
4     # Required-Start: $local_fs $remote_fs
5     # Required-Stop: $local_fs $remote_fs
6     # Default-Start: 2 3 4 5
7     # Default-Stop: 0 1 6
8     # Short-Description: Example initscript
9     # Description: This file should be used to construct scripts to be
10     # placed in /etc/init.d.
11     ### END INIT INFO
12    
13     # Author: Dobrica Pavlinusic <dpavlin@rot13.org>
14    
15     # Do NOT "set -e"
16    
17     IRC_LOG=/home/dpavlin/irc/irc-logger.log
18     IRC_USER=dpavlin
19    
20     # rotate log
21     test -e "$LOG" && mv "$LOG" "$LOG.`date +%Y%m%dT%H:%M:%S`"
22    
23     # PATH should only include /usr/* if it runs after the mountnfs.sh script
24     PATH=/sbin:/usr/sbin:/bin:/usr/bin
25     DESC="IRC channel logger"
26     NAME=irc-logger
27     DAEMON=/usr/local/bin/irc-logger.pl
28     #DAEMON_ARGS="--options args"
29     DAEMON_ARGS=" --log $IRC_LOG"
30     PIDFILE=/var/run/$NAME.pid
31     SCRIPTNAME=/etc/init.d/$NAME
32    
33     # Exit if the package is not installed
34     [ -x "$DAEMON" ] || exit 0
35    
36     # Read configuration variable file if it is present
37     [ -r /etc/default/$NAME ] && . /etc/default/$NAME
38    
39     # Load the VERBOSE setting and other rcS variables
40     . /lib/init/vars.sh
41    
42     # Define LSB log_* functions.
43     # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
44     . /lib/lsb/init-functions
45    
46     #
47     # Function that starts the daemon/service
48     #
49     do_start()
50     {
51     # Return
52     # 0 if daemon has been started
53     # 1 if daemon was already running
54     # 2 if daemon could not be started
55     start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
56     || return 1
57     start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
58     --chuid $IRC_USER \
59     --make-pidfile --background \
60     -- $DAEMON_ARGS \
61     || return 2
62     # Add code here, if necessary, that waits for the process to be ready
63     # to handle requests from services started subsequently which depend
64     # on this one. As a last resort, sleep for some time.
65     }
66    
67     #
68     # Function that stops the daemon/service
69     #
70     do_stop()
71     {
72     # Return
73     # 0 if daemon has been stopped
74     # 1 if daemon was already stopped
75     # 2 if daemon could not be stopped
76     # other if a failure occurred
77     start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
78     RETVAL="$?"
79     [ "$RETVAL" = 2 ] && return 2
80     # Wait for children to finish too if this is a daemon that forks
81     # and if the daemon is only ever run from this initscript.
82     # If the above conditions are not satisfied then add some other code
83     # that waits for the process to drop all resources that could be
84     # needed by services started subsequently. A last resort is to
85     # sleep for some time.
86     start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
87     [ "$?" = 2 ] && return 2
88 dpavlin 62 killall irc-logger.pl
89 dpavlin 47 # Many daemons don't delete their pidfiles when they exit.
90     rm -f $PIDFILE
91     return "$RETVAL"
92     }
93    
94     #
95     # Function that sends a SIGHUP to the daemon/service
96     #
97     do_reload() {
98     #
99     # If the daemon can reload its configuration without
100     # restarting (for example, when it is sent a SIGHUP),
101     # then implement that here.
102     #
103     start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
104     return 0
105     }
106    
107     case "$1" in
108     start)
109     [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
110     do_start
111     case "$?" in
112     0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
113     2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
114     esac
115     ;;
116     stop)
117     [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
118     do_stop
119     case "$?" in
120     0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
121     2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
122     esac
123     ;;
124     #reload|force-reload)
125     #
126     # If do_reload() is not implemented then leave this commented out
127     # and leave 'force-reload' as an alias for 'restart'.
128     #
129     #log_daemon_msg "Reloading $DESC" "$NAME"
130     #do_reload
131     #log_end_msg $?
132     #;;
133     restart|force-reload)
134     #
135     # If the "reload" option is implemented then remove the
136     # 'force-reload' alias
137     #
138     log_daemon_msg "Restarting $DESC" "$NAME"
139     do_stop
140     case "$?" in
141     0|1)
142     do_start
143     case "$?" in
144     0) log_end_msg 0 ;;
145     1) log_end_msg 1 ;; # Old process is still running
146     *) log_end_msg 1 ;; # Failed to start
147     esac
148     ;;
149     *)
150     # Failed to stop
151     log_end_msg 1
152     ;;
153     esac
154     ;;
155     *)
156     #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
157     echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
158     exit 3
159     ;;
160     esac
161    
162     :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26