Changes between Version 2 and Version 3 of Bitten Slave Daemon Ubuntu
- Timestamp:
- Oct 20, 2009, 1:25:51 PM (14 years ago)
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.1 Here 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. 2 2 3 3 4 4 {{{ 5 #! 5 #!/bin/sh 6 6 ### BEGIN INIT INFO 7 7 # Provides: bitten-slave 8 # required-start: 8 # required-start: $all 9 9 # required-stop: $all 10 10 # Default-Start: 2 3 4 5 … … 14 14 ### END INIT INFO 15 15 16 NAME="bitten-slave" 17 DAEMON_CMD="/usr/bin/bitten-slave" 18 DAEMON_ARG="http://localhost/trac/builds -i 15 16 PATH=/sbin:/usr/sbin:/bin:/usr/bin 17 DESC="Bitten Slave" 18 NAME=bitten-slave 19 DAEMON=/usr/local/bin/$NAME 20 DAEMON_ARGS="-f /etc/bitten/slave.ini --interval=15 http://trac.example.org/MyProject/builds" 21 PIDFILE=/var/run/$NAME.pid 22 SCRIPTNAME=/etc/init.d/$NAME 19 23 20 test -x $DAEMON_CMD || exit 0 24 # Exit if the package is not installed 25 [ -x "$DAEMON" ] || exit 0 21 26 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 # 40 do_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 # 48 do_stop() 49 { 50 start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 5 51 RETVAL="$?" 52 rm -f $PIDFILE 53 return "$RETVAL" 54 } 23 55 24 56 case "$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 ;; 38 99 esac 39 100 40 exit 0 101 : 41 102 }}} 103 104 To start the daemon manaually run the following. 105 106 {{{ 107 sudo /etc/init.d/bitten-slave start 108 }}} 109 110 Likewise you can stop the daemon with 111 112 {{{ 113 sudo /etc/init.d/bitten-slave stop 114 }}} 115 116 To 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 {{{ 119 sudo chmod 755 /etc/init.d/bitten-slave 120 update-rc.d bitten-slave defaults 121 }}}