Skip to content

Instantly share code, notes, and snippets.

@chriscowley
Last active June 17, 2024 06:31
Show Gist options
  • Select an option

  • Save chriscowley/4586539 to your computer and use it in GitHub Desktop.

Select an option

Save chriscowley/4586539 to your computer and use it in GitHub Desktop.
Startup script for Trac daemon
#!/bin/sh
### BEGIN INIT INFO
# Provides: trac
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: trac initscript
# Description: trac
### END INIT INFO
# Original author: Chris Cowley
# Do NOT "set -e"
DAEMON=/usr/bin/tracd
SCRIPT_NAME=/etc/rc.d/trac
CONFIG_PATH=/etc/trac
PIDFILE="/tmp/trac.3050"
USER="trac"
TRACHOME="/var/local/trac"
REALM="example-realm"
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
case "$1" in
start)
echo "starting trac"
su - $USER -c "$DAEMON -d --basic-auth=*,$TRACHOME/.htpasswd,$REALM -e $TRACHOME -p 3050 --protocol=http --pidfile=$PIDFILE"
;;
stop)
echo "stoping trac"
kill `cat $PIDFILE`
;;
restart)
echo "stoping trac"
kill `cat $PIDFILE`
echo "starting trac"
su - $USER -c "$DAEMON -d --basic-auth=*,$TRACHOME/.htpasswd,$REALM -e $TRACHOME -p 3050 --protocol=http --pidfile=$PIDFILE"
;;
*)
echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
exit 3
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment