scripts/runbot
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 30 May 2009 21:58:25 +0200
changeset 39 0ae006af497e
parent 33 56571d34d754
child 42 cb24a67ec3ec
permissions -rwxr-xr-x
fixed some typos in the help screen I have removed some semicolons in the help screen and that's consistent now committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
#!/bin/sh
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     2
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     3
### BEGIN INIT INFO
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     4
# Provides:          mcbot
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     5
# Required-Start:    $remote_fs $syslog
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     6
# Required-Stop:     $remote_fs $syslog
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     7
# Default-Start:     2 3 4 5
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
     8
# Default-Stop:      0 1 6
33
56571d34d754 safe buffers, a memory leak and cleanups
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 31
diff changeset
     9
# Short-Description: IRC BOT mcbot
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    10
# Description:       IRC BOT mcbot
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    11
### END INIT INFO
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    12
31
bbcb8a3366b4 mcbot needs a proper system account
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 27
diff changeset
    13
RUNAS="mcbot"
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
BINARY="mcbot"
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    15
DIRECTORY="/usr/sbin/"
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
LANGUAGE="de_DE.UTF-8"
27
4a2f7a1492ab Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 26
diff changeset
    17
PARAMETER=""
31
bbcb8a3366b4 mcbot needs a proper system account
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 27
diff changeset
    18
LOGFILE="/var/lib/mcbot/mcbot-`date \"+%d-%m-%y\"`.log"
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    19
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    20
[[ ! -x "${DIRECTORY}/${BINARY}" ]] && exit 0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    22
start() {
27
4a2f7a1492ab Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 26
diff changeset
    23
	echo -n " * Starting ${BINARY}"
4a2f7a1492ab Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 26
diff changeset
    24
	su - ${RUNAS} -c "LANG=$LANGUAGE ${DIRECTORY}/${BINARY} ${PARAMETER} &> ${LOGFILE} &"
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    25
	if [ "$?" == 0 ]; then
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    26
		echo " [started]"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    27
	fi
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    28
}
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    29
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    30
stop() {
27
4a2f7a1492ab Lazy EBNF and an improved startscript
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 26
diff changeset
    31
	echo -n " * Stopping ${BINARY}"
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    32
	pid=`pidof ${BINARY}`
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    33
	if [ "$pid" != "" ]; then
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    34
		kill -TERM `pidof ${BINARY}`
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    35
		sleep 5
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    36
	fi
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    37
	echo " [stopped]"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    38
}
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    39
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    40
status() {
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    41
	pid="`pidof ${BINARY}`"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    42
	if [ "$pid" != "" ]; then
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    43
		echo "${BINARY} is started as ${pid}"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    44
	else
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    45
		echo "${BINARY} is not running"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    46
	fi
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    47
}
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    48
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    49
case "$1" in
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    50
	start)
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    51
		start
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    52
	;;
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    53
	stop)
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    54
		stop
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    55
	;;
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    56
	status)
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    57
		status
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    58
	;;
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    59
	restart)
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    60
		echo "Restarting ${BINARY}"
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    61
		stop
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    62
		start
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    63
	;;
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    64
	force-reload)
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    65
		echo "Force reload stub"
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    66
		stop
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    67
		start
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    68
	;;
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    69
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    70
	*)
26
767f79e69de1 Debian QoS - Lintian Checks
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 0
diff changeset
    71
		echo "Usage: start|stop|restart|status|force-reload"
0
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    72
	;;
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    73
esac
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    74
586472add385 Initial Layout
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    75
exit 0