You are hereBlogs / David Grant's blog / init.d Script for Trac on Ubuntu Linux

init.d Script for Trac on Ubuntu Linux


By David Grant - Posted on 29 August 2008

I modified an nginx init.d script and created an init.d script for trac.d. I run tracd and then forward traffic from trac.davidgrant.ca to trac's port (using nginx) rather than using cgi or fast-cgi. Please let me know if you have any problems with this scripts and I will fix it.

#! /bin/sh
### BEGIN INIT INFO
# Provides:          tracd
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the tracd web server
# Description:       starts tracd using start-stop-daemon
### END INIT INFO
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/tracd
NAME=tracd
DESC=tracd
#DAEMON_OPTS="-s -r -d -p 8080 --basic-auth=*,/etc/tracd/tracusers,trac /trac"
DAEMON_OPTS="-s -d -p 8000 /home/david/trac --pidfile /var/run/$NAME.pid"
 
test -x $DAEMON || exit 0
 
# Include tracd defaults if available
if [ -f /etc/default/tracd ] ; then
        . /etc/default/tracd
fi
 
set -e
 
case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
                --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
        echo "$NAME."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile \
                /var/run/$NAME.pid
        sleep 1
        start-stop-daemon --start --quiet --pidfile \
                /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
        exit 1
        ;;
esac
 
exit 0

After you create the script at /etc/init.d/tracd, don't forget to do the following:

sudo chmod +x /etc/init.d/tracd
sudo /usr/sbin/update-rc.d -f tracd defaults

to make the script executable and to make it run on startup.

thank you for sharing it, it works for me too :-)

This works just great. Thanks a lot :)

I used this script and I had to remove the -r in the DAEMON_OPTS (the port 8080 one), to make it work.

It's just a script I was looking for, because I'm too lazy admin to write it myself ;) Of course I need to do some customization, for example add a dependency on Nginx, but it's a great start point for me. Thank you very much, David!

Thank you for a straightforward script.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <s> <img> <h2> <h3>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Insert Google Map macro.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may use [view:name=display=args] tags to display views.

More information about formatting options

CAPTCHA
Sorry I had to add this test to combat the spam problem.
q
g
G
C
z
7
Enter the code without spaces and pay attention to upper/lower case.