#!/bin/bash ### BEGIN INIT INFO # Provides: svn # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: UGCS Svn Service # Description: Provides svnserve service with kerberos tokens for UGCS ### END INIT INFO SVN_USER=svn SVN_GROUP=svn SVN_COMMAND=/usr/bin/svnserve SVN_ROOT=/afs/.ugcs/svn/ PIDFILE=/var/run/svnserve/svnserve.pid KEYTAB=/etc/keytabs/svn.keytab K5START=/usr/bin/k5start K5START_PID=/var/run/svnserve/svnserve_k5start.pid . /lib/lsb/init-functions make_piddir() { piddir=`dirname $PIDFILE` if [ ! -d $piddir ]; then mkdir $piddir chown $SVN_USER:$SVN_GROUP $piddir fi } flush_vols() { for user in `ls $SVN_ROOT`; do if [ -d $SVN_ROOT/$user ]; then fs flushvolume $SVN_ROOT/$user 2>&1 >/dev/null fi done } start_svn() { make_piddir log_daemon_msg "Starting svnserve" "svnserve" # This long command has svnserve nested in a k5start which is itself nested in a start-stop-daemon # start-stop-daemon takes care of changing the user. It then run k5start, which creates the new PAG for svnserve and gets tokens, and calls svnserve # We make svnserve run in the foreground so that it stays in the k5start PAGRunning daemons alongside k5start doesn't seem to work very well k5start_opts="-U -f $KEYTAB -b -K 10 -l 10h -p $K5START_PID -q -c $PIDFILE -t" start_stop_daemon_opts="-p $PIDFILE -g $SVN_GROUP -c $SVN_USER" svn_opts="-r $SVN_ROOT -d --foreground" start-stop-daemon $start_stop_daemon_opts --exec $K5START --start -- $k5start_opts -- $SVN_COMMAND $svn_opts log_end_msg $? } stop_svn() { log_daemon_msg "Stopping svnserve" start-stop-daemon -p $PIDFILE --exec $SVN_COMMAND --stop --oknodo rm -rf $PIDFILE log_end_msg $? } case "$1" in start) start_svn ;; stop) stop_svn ;; restart) stop_svn start_svn ;; *) echo "Usage: /etc/init.d/svn {start|stop|restart}" exit 1 esac