#!/bin/sh # Startup script for radicale # # chkconfig: 345 95 5 # description: Simple CalDAV server # ### BEGIN INIT INFO # Provides: radicale # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Default-Start: # Default-Stop: # Short-Description: Simple CalDAV server # Description: The Radicale Project is a complete CalDAV calendar server solution. # It canstore multiple calendars. ### END INIT INFO prog=radicale servicename=$prog # Source function library. . /etc/rc.d/init.d/functions [ -f /usr/bin/radicale ] || exit 0 if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi start() { if [ -f /var/run/$prog.pid ]; then gprintf "Starting %s: already running" "$prog" failure "startup" echo exit 3 fi gprintf "Starting %s:" "$prog" daemon --check $servicename $prog success "startup" echo RETVAL=$? if [ $RETVAL -eq 0 ]; then touch /var/lock/subsys/$servicename runpid=$(pgrep -xn radicale) echo $runpid > /var/run/$prog.pid fi } stop() { if [ ! -f /var/run/$prog.pid ]; then gprintf "Stopping %s: not running" "$prog" failure "stop" echo exit 3 fi gprintf "Stopping %s:" "$prog" pid=$(cat /var/run/$prog.pid) kill -9 $pid >/dev/null 2>&1 success "stop" echo rm -f /var/lock/subsys/$servicename rm -f /var/run/$prog.pid return 0 } case "$1" in start) start ;; stop) stop ;; status) if ! [ -f /var/run/$prog.pid ]; then gprintf "%s is not running.\n" "$prog" exit 3 fi pid=$(cat /var/run/$prog.pid) kill -0 $pid >/dev/null 2>&1 if [ $? == 0 ]; then gprintf "%s (pid %s) is running...\n" "$prog" "$pid" exit 0 fi gprintf "$prog is stopped\n" exit 3 ;; reload) stop start ;; restart) stop start ;; condrestart) if [ -f /var/lock/subsys/$servicename ]; then stop start fi ;; *) gprintf "Usage: %s\n" "$prog {start|stop|restart|condrestart|status}" exit 1 esac exit 0