]>
gitweb.pimeys.fr Git - bots/deconnaisseur.git/blob - initscript
3 # Provides: deconnaisseur
4 # Required-Start: $remote_fs $syslog
5 # Required-Stop: $remote_fs $syslog
6 # Default-Start: 2 3 4 5
8 # Short-Description: deconnaisseur, le bot IRC
9 # Description: deconnaisseur est un bot IRC codé par 20-100
10 # Il fait jouer au jeu des déconnaissances
13 # Author: Vincent Le Gallic <legallic@crans.org>
17 # PATH should only include /usr/* if it runs after the mountnfs.sh script
18 PATH
=/sbin
:/usr
/sbin
:/bin
:/usr
/bin
19 DESC
="bot IRC jouant à deconnaissances"
20 PYTHON
=/usr
/bin
/python
21 BASENAME
=deconnaisseur
22 DIRECTORY
=/home
/deconnaisseur
/deconnaisseur
23 SCRIPT
=$DIRECTORY/$BASENAME.py
24 EXEC
="$PYTHON $SCRIPT"
26 SCRIPT_ARGS
="crans --daemon"
28 PIDFILE
=$PIDDIR$BASENAME.pid
29 SCRIPTNAME
=/etc
/init.d
/$BASENAME
32 # Load the VERBOSE setting and other rcS variables
35 # Define LSB log_* functions.
36 # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
37 # and status_of_proc is working.
38 .
/lib
/lsb
/init-functions
42 # Répare /var/run/bots si il était pas bon
44 chown root
:bots
$PIDDIR
48 # To check if the process is running
51 # On récupère le PID (écrit dans ce fichier par le script la dernière fois qu'il a été lancé)
53 # On va voir si le process tourne toujours
54 test -x /proc
/$pid ||
return 1 # aucun process de ce PID ne tourne
55 # On regarde si il a les bons arguments
56 egrep -q ^
$PYTHON /proc
/$pid/cmdline ||
return 1 # il y a bien un process de ce PID, mais ce n'est pas python
57 grep -q $SCRIPT /proc
/$pid/cmdline ||
return 1 # il y a bien un PID, c'est bien python, mais il ne lance pas le bot
73 touch $PIDFILE 2>&1 >/dev
/null
74 chown
$USER:bots
$PIDFILE 2>&1 >/dev
/null
80 echo -n "Failed to read $PIDFILE"
86 # Function that starts the daemon
91 # 0 if daemon has been started
92 # 1 if daemon was already running
93 # 2 if daemon could not be started
98 sudo
-u $USER $PYTHON $SCRIPT $SCRIPT_ARGS
99 [ "$?" = 0 ] ||
return 2
104 # Function that stops the daemon
109 # 0 if daemon has been stopped
110 # 1 if daemon was already stopped
111 # 2 if daemon could not be stopped
112 # other if a failure occurred
130 # Function that sends a SIGHUP to the daemon
134 # 0 if reload has been done
135 # 1 if daemon was not running
136 # 2 if reload could not be achieved
141 [ "$?" = 0 ] ||
return 2
148 # The actual initscript
152 log_daemon_msg
"Starting $DESC" "$BASENAME"
156 1) echo -n " was already running"; log_end_msg
1 ;;
161 log_daemon_msg
"Stopping $DESC" "$BASENAME"
165 1) echo -n " was not running"; log_end_msg
1 ;;
172 log_action_msg
"$BASENAME is running"
174 log_action_msg
"$BASENAME is NOT running"
178 log_daemon_msg
"Reloading $DESC" "$BASENAME"
182 1) echo -n " was not running"; log_end_msg
1 ;;
187 log_daemon_msg
"Restarting $DESC" "$BASENAME"
194 1) log_end_msg
1 ;; # Old process is still running
195 *) log_end_msg
1 ;; # Failed to start
213 log_action_msg
"Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2