monotone

monotone Mtn Source Tree

Root/monotone-server.monotone.init

1#! /bin/sh
2#
3# monotone Monotone server init script.
4#
5# Author: Matthew A. Nicholson <matt@matt-land.com>.
6#
7### BEGIN INIT INFO
8# Provides: monotone
9# Required-Start: $network $remote_fs
10# Required-Stop: $network $remote_fs
11# Default-Start: 2 3 4 5
12# Default-Stop: 0 1 6
13# Short-Description: Monotone server.
14# Description: Provides synchronization services of a monotone
15# repository via netsync.
16### END INIT INFO
17
18set -e
19
20PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
21DESC="Monotone Server"
22NAME=monotone
23EXECNAME=mtn
24DAEMON=/usr/bin/$EXECNAME
25PIDDIR=/var/run/$NAME
26SCRIPTNAME=/etc/init.d/$NAME
27MAINLOG=/var/log/$NAME/$EXECNAME.log
28ERRORLOG=/var/log/$NAME/error.log
29
30# defaults for /etc/default/monotone
31START=1
32ADDRESS=0.0.0.0
33MTN_HOME=/var/lib/monotone
34MTN_CONFDIR=/etc/monotone
35MTN_KEYDIR=$MTN_HOME/keys
36MTN_DB=$MTN_HOME/default.mtn
37
38# Gracefully exit if the package has been removed.
39test -x $DAEMON || exit 0
40
41# Get the logging helpers.
42. /lib/lsb/init-functions
43
44# Read config file
45if [ -r /etc/default/$NAME ]; then
46. /etc/default/$NAME
47fi
48
49PIDFILE=$PIDDIR/$EXECNAME.pid
50
51# Function that starts the daemon.
52d_start()
53{
54 if [ "$START" -ne 1 ]; then
55log_action_msg "$NAME configured in /etc/default/$NAME not to start"
56 return 0
57 fi
58
59 log_daemon_msg "Starting $DESC" "$NAME"
60
61 # If /var/run is created in tmpfs, it will be wiped of previous data
62 if [ ! -d "$PIDDIR" ]; then
63mkdir -p "$PIDDIR" && chown monotone:monotone "$PIDDIR"
64 fi
65
66 if start-stop-daemon --start --quiet --oknodo --background \
67 --pidfile $PIDFILE --exec $DAEMON --chuid monotone --chdir $MTN_HOME \
68-- \
69 --confdir=$MTN_CONFDIR --db=$MTN_DB --no-standard-rcfiles \
70--pid-file=$PIDFILE --log=$MAINLOG --dump=$ERRORLOG --timestamps \
71 --rcfile=$MTN_CONFDIR/serverrc --keydir=$MTN_KEYDIR --quiet \
72 --bind=$ADDRESS serve
73
74 then log_end_msg 0
75 else log_end_msg 1
76 fi
77}
78
79# Function that stops the daemon.
80d_stop()
81{
82 if [ "$START" -ne 1 ]; then
83 return 0
84 fi
85
86 log_daemon_msg "Stopping $DESC" "$NAME"
87 if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
88 --name $EXECNAME --user monotone
89
90 then
91rm -f $PIDFILE
92log_end_msg 0
93 else
94log_end_msg 1
95 fi
96}
97
98case "$1" in
99 start)
100d_start
101;;
102 stop)
103d_stop
104;;
105 restart|force-reload)
106d_stop
107d_start
108;;
109 status)
110status_of_proc $DAEMON mtn && exit 0 || exit $?
111;;
112 *)
113echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
114exit 1
115;;
116esac

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status