Created
October 3, 2011 08:59
-
-
Save monken/1258738 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
### BEGIN INIT INFO | |
# Provides: metacpan-web | |
# Required-Start: $ALL | |
# Required-Stop: | |
# Default-Start: 3 5 | |
# Default-Stop: 0 1 2 6 | |
# Short-Description: MetaCPAN Front-End | |
### END INIT INFO | |
# Check for missing binaries (stale symlinks should not happen) | |
# Note: Special treatment of stop for LSB conformance | |
HOME=/home/metacpan | |
source /home/metacpan/perl5/perlbrew/etc/bashrc | |
perlbrew switch perl-5.14.0 | |
STARMAN_BIN=/home/metacpan/perl5/perlbrew/perls/perl-5.14.0/bin/starman | |
ROOT=/home/metacpan/metacpan.org | |
PID_FILE=/var/run/metacpan-web.pid | |
test -x $STARMAN_BIN || { echo "$STARMAN_BIN not installed"; | |
if [ "$1" = "stop" ]; then exit 0; | |
else exit 5; fi; } | |
# Check for existence of needed config file and read it | |
#metacpan-web_CONFIG=/etc/sysconfig/metacpan-web | |
#test -r $metacpan-web_CONFIG || { echo "$metacpan-web_CONFIG not existing"; | |
# if [ "$1" = "stop" ]; then exit 0; | |
# else exit 6; fi; } | |
# Read config | |
#. $metacpan-web_CONFIG | |
# Source LSB init functions | |
# providing start_daemon, killproc, pidofproc, | |
# log_success_msg, log_failure_msg and log_warning_msg. | |
# This is currently not used by UnitedLinux based distributions and | |
# not needed for init scripts for UnitedLinux only. If it is used, | |
# the functions from rc.status should not be sourced or used. | |
#. /lib/lsb/init-functions | |
$0 status | |
if test $? = 0; then | |
$0 restart | |
else | |
rc_reset # Not running is not a failure. | |
fi | |
# Remember status and be quiet | |
rc_status | |
;; | |
restart) | |
## Stop the service and regardless of whether it was | |
## running or not, start it again. | |
$0 stop | |
$0 start | |
# Remember status and be quiet | |
rc_status | |
;; | |
status) | |
echo -n "Checking for service metacpan-web " | |
## Check status with checkproc(8), if process is running | |
## checkproc will return with exit status 0. | |
# Return value is slightly different for the status command: | |
# 0 - service up and running | |
# 1 - service dead, but /var/run/ pid file exists | |
# 2 - service dead, but /var/lock/ lock file exists | |
# 3 - service not running (unused) | |
# 4 - service status unknown :-( | |
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) | |
# NOTE: checkproc returns LSB compliant status values. | |
/sbin/checkproc -p $PID_FILE $STARMAN_BIN | |
# NOTE: rc_status knows that we called this init script with | |
# "status" option and adapts its messages accordingly. | |
rc_status -v | |
;; | |
probe) | |
## Optional: Probe for the necessity of a reload, print out the | |
## argument to this init script which is required for a reload. | |
## Note: probe is not (yet) part of LSB (as of 1.9) | |
test /etc/metacpan-web/metacpan-web.conf -nt $PID_FILE && echo reload | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}" | |
exit 1 | |
;; | |
esac | |
rc_exit | |
$0 status | |
if test $? = 0; then | |
$0 restart | |
else | |
rc_reset # Not running is not a failure. | |
fi | |
# Remember status and be quiet | |
rc_status | |
;; | |
restart) | |
## Stop the service and regardless of whether it was | |
## running or not, start it again. | |
$0 stop | |
$0 start | |
# Remember status and be quiet | |
rc_status | |
;; | |
status) | |
echo -n "Checking for service metacpan-web " | |
## Check status with checkproc(8), if process is running | |
## checkproc will return with exit status 0. | |
# Return value is slightly different for the status command: | |
# 0 - service up and running | |
# 1 - service dead, but /var/run/ pid file exists | |
# 2 - service dead, but /var/lock/ lock file exists | |
# 3 - service not running (unused) | |
# 4 - service status unknown :-( | |
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) | |
# NOTE: checkproc returns LSB compliant status values. | |
/sbin/checkproc -p $PID_FILE $STARMAN_BIN | |
# NOTE: rc_status knows that we called this init script with | |
# "status" option and adapts its messages accordingly. | |
rc_status -v | |
;; | |
probe) | |
## Optional: Probe for the necessity of a reload, print out the | |
## argument to this init script which is required for a reload. | |
## Note: probe is not (yet) part of LSB (as of 1.9) | |
test /etc/metacpan-web/metacpan-web.conf -nt $PID_FILE && echo reload | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}" | |
exit 1 | |
;; | |
esac | |
rc_exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment