Edgewall Software

Changes between Initial Version and Version 1 of Bitten Slave Daemon Redhat


Ignore:
Timestamp:
Sep 27, 2010, 7:21:14 PM (14 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Bitten Slave Daemon Redhat

    v1 v1  
     1Here is a simple script to start bitten-slave as a daemon on Redhat derivatives. The example file below should be saved as 'bitten-slave' in '/etc/init.d'. This has been tested on CentOS 5.2, however should run from any system with only minimal changes. You will need to change the DAEMON_ARGS variable to contain a URL which reflects your server.
     2
     3
     4{{{
     5#!/bin/sh
     6#
     7# bitten-slave   startup script for the Bitten build slave
     8# processname:       bitten-slave
     9# config:            /etc/bitten/slave
     10# pidfile:           /var/run/bitten-slave.pid
     11# chkconfig: 2345 99 01
     12# description:       Bitten build slave
     13
     14# Source function library.
     15. /etc/rc.d/init.d/functions
     16
     17PATH=/sbin:/usr/sbin:/bin:/usr/bin
     18DESC="Bitten Slave"
     19NAME=bitten-slave
     20DAEMON=/usr/bin/$NAME
     21DAEMON_ARGS="--interval=15 https://trac.example.org/trac/builds"
     22DAEMON_USER=bitten-slave
     23PIDFILE=/var/run/$NAME.pid
     24
     25# Exit if the package is not installed
     26[ -x "$DAEMON" ] || exit 0
     27
     28# Read configuration variable file if it is present
     29[ -r /etc/sysconfig/bitten-slave/$NAME ] && . /etc/sysconfig/bitten-slave/$NAME
     30
     31start() {
     32        echo -n $"Starting $NAME: "
     33        daemon --user="$DAEMON_USER" --pidfile="$PIDFILE" "$DAEMON $DAEMON_ARGS &"
     34        RETVAL=$?
     35        pid=`ps -A | grep $NAME | cut -d" " -f2`
     36        pid=`echo $pid | cut -d" " -f2`
     37        if [ -n "$pid" ]; then
     38                echo $pid > "$PIDFILE"
     39        fi
     40        echo
     41        return $RETVAL
     42}
     43stop() {
     44        echo -n $"Stopping $NAME: "
     45        killproc -p "$PIDFILE" -d 10 "$DAEMON"
     46        RETVAL="$?"
     47        echo
     48        [ $RETVAL = 0 ] && rm -f "$PIDFILE"
     49        return "$RETVAL"
     50}
     51
     52case "$1" in
     53  start)
     54        start
     55        ;;
     56  stop)
     57        stop
     58        ;;
     59  restart)
     60        stop
     61        start
     62        ;;
     63  *)
     64        echo "Usage: $NAME {start|stop|restart}" >&2
     65        exit 1
     66        ;;
     67esac
     68
     69exit $RETVAL
     70}}}