[CalendarServer-users] How to install as system service?
David Szego
david.szego at gmail.com
Tue Nov 6 16:50:14 PST 2007
On 6-Nov-07, at 5:06 PM, Jindan Zhou wrote:
> Yeah, it would be nice if some one could donate their linux shell
> script, so
> that it can be installed as a linux service, too.
Here's mine. This needs work... It starts, but doesn't yet stop (PIDs
not seen right I guess, haven't looked much at it yet.)
I've installed:
- the conf files and account.xml in /etc/caldavd
- the actual software in /opt/calendarserver/ which includes:
/opt/calendarserver/CalDAVTester, /opt/calendarserver/
CalendarServer, /opt/calendarserver/Twisted, and so on,
- the data (calendars themselves) in /var/cache/calendarserver
At the moment it's running as root, (CALUSER=root) so I don't have to
worry about any permission issues. The init.d script is taken from
some random script in my init.d directory, running Ubuntu.
If I happened to be set up for svn, I'd post it to the official code,
but I leave it for someone else to do, as I'm really just a good
amateur hack! =-)
Cheers,
David Szego.
-----------
/etc/init.d/calendarserver
-----------
#!/bin/sh
# Apple CalendarServer startup script, taken from an Ubuntu script.
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Apple Calendar Server"
NAME=calendarserver
DAEMON=/opt/calendarserver/CalendarServer/run
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
CACHEDIR=/var/cache/$NAME
CALUSER=root
CALOPTIONS=-d
#
# Function that starts the daemon/service.
#
d_start() {
start-stop-daemon --start --quiet \
--chuid $CALUSER \
--pidfile $PIDFILE \
--exec $DAEMON \
--background \
--make-pidfile \
-- \
$CALOPTIONS
}
d_start_direct() {
start-stop-daemon --start --quiet \
--chuid $CALUSER \
--pidfile $PIDFILE \
--exec $DAEMON \
-- \
$CALOPTIONS
}
# Function that stops the daemon/service.
#
d_stop() {
start-stop-daemon --stop --pidfile $PIDFILE --name $NAME
}
#
# Function that sends a SIGHUP to the daemon/service.
#
d_reload() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--name $NAME --signal 1
}
case "$1" in
start)
echo -n "Starting $DESC"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC"
d_stop
echo "."
;;
restart|force-reload)
#
# If the "reload" option is implemented, move the
"force-reload"
# option to the "reload" entry above. If not, "force-
reload" is
# just the same as "restart".
#
echo -n "Restarting $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
# echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-
reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
-----------------
More information about the calendarserver-users
mailing list