Edgewall Software

Changes between Version 2 and Version 3 of Bitten Slave Daemon Ubuntu


Ignore:
Timestamp:
Oct 20, 2009, 1:25:51 PM (14 years ago)
Author:
flexiondotorg
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Bitten Slave Daemon Ubuntu

    v2 v3  
    1 Here is a simple script to start bitten-slave as a daemon. This will usually be put in /etc/init.d or wherever your init scripts are kept. This has been tested on Ubuntu Hardy, however should run from any system with only minimal changes. You will need to change the DAEMON_ARG varible to contain a URL which reflects your server.
     1Here is a simple script to start bitten-slave as a daemon on Ubuntu. The example file below should be saved as 'bitten-slave' in '/etc/init.d'. This has been tested on Ubuntu Hardy, 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.
    22
    33
    44{{{
    5 #! /bin/sh
     5#!/bin/sh
    66### BEGIN INIT INFO
    77# Provides:          bitten-slave
    8 # required-start:     $all
     8# required-start:    $all
    99# required-stop:     $all
    1010# Default-Start:     2 3 4 5
     
    1414### END INIT INFO
    1515
    16 NAME="bitten-slave"
    17 DAEMON_CMD="/usr/bin/bitten-slave"
    18 DAEMON_ARG="http://localhost/trac/builds -i 15
     16PATH=/sbin:/usr/sbin:/bin:/usr/bin
     17DESC="Bitten Slave"
     18NAME=bitten-slave
     19DAEMON=/usr/local/bin/$NAME
     20DAEMON_ARGS="-f /etc/bitten/slave.ini --interval=15 http://trac.example.org/MyProject/builds"
     21PIDFILE=/var/run/$NAME.pid
     22SCRIPTNAME=/etc/init.d/$NAME
    1923
    20 test -x $DAEMON_CMD || exit 0
     24# Exit if the package is not installed
     25[ -x "$DAEMON" ] || exit 0
    2126
    22 set -e
     27# Read configuration variable file if it is present
     28[ -r /etc/default/$NAME ] && . /etc/default/$NAME
     29
     30# Load the VERBOSE setting and other rcS variables
     31. /lib/init/vars.sh
     32
     33# Define LSB log_* functions.
     34# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
     35. /lib/lsb/init-functions
     36
     37#
     38# Function that starts the daemon/service
     39#
     40do_start()
     41{
     42        start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
     43}
     44
     45#
     46# Function that stops the daemon/service
     47#
     48do_stop()
     49{
     50        start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 5
     51        RETVAL="$?"
     52        rm -f $PIDFILE
     53        return "$RETVAL"
     54}
    2355
    2456case "$1" in
    25   start)
    26     echo -n "Running bitten-slave"
    27     start-stop-daemon --start -m --quiet --background --pidfile /var/run/bitten-slave.pid --exec $DAEMON_CMD -- $DAEMON_ARG
    28     ;;
    29   stop)
    30     echo -n "Stopping bitten-slave"
    31     start-stop-daemon --stop --quiet --pidfile /var/run/bitten-slave.pid --oknodo
    32     ;;
    33   *)   
    34     N=/etc/init.d/$NAME
    35     echo "Usage: $N {start|stop}" >&2
    36     exit 1   
    37     ;;
     57  start)
     58        log_daemon_msg "Starting $DESC" "$NAME"
     59        do_start
     60        case "$?" in
     61                0|1) log_end_msg 0 ;;
     62                2) log_end_msg 1 ;;
     63        esac
     64        ;;
     65  stop)
     66        log_daemon_msg "Stopping $DESC" "$NAME"
     67        do_stop
     68        case "$?" in
     69                0|1) log_end_msg 0 ;;
     70                2) log_end_msg 1 ;;
     71        esac
     72        ;;
     73  restart|force-reload)
     74        #
     75        # If the "reload" option is implemented then remove the
     76        # 'force-reload' alias
     77        #
     78        log_daemon_msg "Restarting $DESC" "$NAME"
     79        do_stop
     80        case "$?" in
     81          0|1)
     82                do_start
     83                case "$?" in
     84                        0) log_end_msg 0 ;;
     85                        1) log_end_msg 1 ;; # Old process is still running
     86                        *) log_end_msg 1 ;; # Failed to start
     87                esac
     88                ;;
     89          *)
     90                # Failed to stop
     91                log_end_msg 1
     92                ;;
     93        esac
     94        ;;
     95  *)
     96        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
     97        exit 3
     98        ;;
    3899esac
    39100
    40 exit 0
     101:
    41102}}}
     103
     104To start the daemon manaually run the following.
     105
     106{{{
     107sudo /etc/init.d/bitten-slave start
     108}}}
     109
     110Likewise you can stop the daemon with
     111
     112{{{
     113sudo /etc/init.d/bitten-slave stop
     114}}}
     115
     116To enable the script so the bitten slave will automatically be started at boot time and stopped at shutdown make the script executable and enable it.
     117
     118{{{
     119sudo chmod 755 /etc/init.d/bitten-slave
     120update-rc.d bitten-slave defaults
     121}}}