st3fan / dovecot-xaps-daemon

MIT License
164 stars 37 forks source link

CentOS 6 init script #13

Closed SteffanCline closed 6 years ago

SteffanCline commented 9 years ago

I figured I could contribute this. I have the daemon up and running but the plugin is not registering for some reason. That is next to figure out.

#!/bin/bash
#
# xapsd init script for CentOS 6
#
# chkconfig: 345 99 01
# description: Apple Push Notification Service
# processname: xapsd

# Source function library.
. /etc/init.d/functions

# Declare variables for xapsd daemon
RETVAL=0
PROG="xapsd"
EXEC="/usr/local/sbin/$PROG"
LOGFILE="/var/log/$PROG.log"
CERTIFICATE="/etc/$PROG/certificate.pem"
DATABASE="/var/lib/$PROG/database.json"
DEBUG="false"
KEY="/etc/$PROG/key.pem"
SOCKET="/var/run/$PROG/$PROG.sock"
LOCKFILE="/var/lock/subsys/$PROG"
OPTIONS="-certificate=$CERTIFICATE -database=$DATABASE -debug=$DEBUG -key=$KEY -socket=$SOCKET"

start() {
        [ -x $EXEC ] || exit 5
        echo -n "Starting $PROG: "
        daemon $EXEC $OPTIONS >> $LOGFILE 2>&1 &        
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch $LOCKFILE
        [ $RETVAL -eq 0 ] && success $"[ OK ]" || failure $"[ Failed! ] See log file $LOGFILE"
        echo
        return $RETVAL
}

stop() {
        echo -n "Shutting down $PROG: "
        kill $(pidof $PROG)
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f $SOCKET
        [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
        [ $RETVAL -eq 0 ] && success $"[ OK ]" || failure $"[ Failed! ]"
        echo
        return $RETVAL
}

status() {
        echo -n "Checking $PROG status: "
        PID=$(pidof $PROG)
        [[ -n $PID ]] && success $"$PROG service is running as pid $PID" || failure $"$PROG service is not running"
        RETVAL=$?
        return $RETVAL
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage: $PROG {start|stop|status|restart}"
        exit 1
        ;;
esac
exit $RETVAL
freswa commented 6 years ago

I don't think this is an issue..?! If I am wrong, please feel free to reopen.