[CalendarServer-users] How to install as system service?

Wilfredo Sánchez Vega wsanchez at wsanchez.net
Wed Nov 28 16:39:10 PST 2007


   The "run" script is intended as a development tool, not as a way to  
run a deployed server (though I suppose that works).  For a  
deployment, I suggest that you instead install the server and run it  
via the caldavd executable.  Something like:

   ./run -i /tmp/dst; cd /tmp/dst && pax -pe -rvw . /;
   /usr/local/bin/caldavd start

	-wsv


On Nov 22, 2007, at 7:31 AM, Damion Theobald wrote:

> Hi,
>
> This is my script to work on SUSE Linux enterprise Server 10.
>
> The line, export USER="", was added to facilitate the server starting
> automatically when booting as the CalendarServer/run script looks  
> for the
> user variable that is not set until you login to the machine.
>
> This script was added to the /etc/init.d/ folder and using chkconfig  
> command
> to auto start.
>
> Regards
> Damion
>
>
> #! /bin/sh
> #
> #
> # /etc/init.d/caldav
> #
> ### BEGIN INIT INFO
> # Provides: 		caldav
> # Required-Start: 	$network $syslog
> # Required-Stop: 	$network $syslog
> # Default-Start: 	3 5
> # Default-Stop: 	0 1 2 4 6
> # Description: 		Calendar server Demon
> ### END INIT INFO
>
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> DESC="Apple Calendar Server"
> NAME=caldav
> DAEMON=/srv/caldav/CalendarServer/run
> PIDFILE=/srv/caldav/CalendarServer/logs/caldavd.pid
> SCRIPTNAME=/etc/init.d/$NAME
> CALUSER=root
> CALOPTIONS=-d
> SERVICE="python /srv/caldav/Twisted/bin/twistd"
>
> test -s /etc/rc.status && \
>     . /etc/rc.status
>
>
> # First reset status of this service
> rc_reset
>
> case "$1" in
>   start)
>         echo -e "Starting $DESC"
>         export USER=""
> 	   startproc -u root -p $PIDFILE $DAEMON $CALOPTIONS
>         export USER=
> 	   rc_status -v
> 	  ;;
>
>   stop)
>         echo -n "Stopping $DESC"
> 	   killproc -TERM -p $PIDFILE $SERVICE
> 	   rc_status -v
> 	   ;;
>
>   restart)
> 	$0 stop
> 	$0 start	
> 	rc_status
>        ;;
> Esac
>
>
>
>
>> -----Original Message-----
>> From: calendarserver-users-bounces at lists.macosforge.org
>> [mailto:calendarserver-users-bounces at lists.macosforge.org] On  
>> Behalf Of
>> David Szego
>> Sent: 07 November 2007 00:50
>> To: Jindan Zhou
>> Cc: calendarserver-users at lists.macosforge.org
>> Subject: Re: [CalendarServer-users] How to install as system service?
>>
>> 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
>>
>> -----------------
>>
>> _______________________________________________
>> calendarserver-users mailing list
>> calendarserver-users at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo/calendarserver-users
>
>
> _______________________________________________
> calendarserver-users mailing list
> calendarserver-users at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo/calendarserver-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2876 bytes
Desc: not available
Url : http://lists.macosforge.org/pipermail/calendarserver-users/attachments/20071128/cb6f1bb9/smime.bin


More information about the calendarserver-users mailing list