Created
January 12, 2015 17:47
-
-
Save gronke/64f69f68670ab9105c07 to your computer and use it in GitHub Desktop.
init.d script for dovecot-xaps-daemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
### BEGIN INIT INFO | |
# Provides: xapsd | |
# Required-Start: $local_fs $remote_fs $network | |
# Required-Stop: $local_fs $remote_fs $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start or stop pyload. | |
### END INIT INFO | |
NAME=xapsd | |
DAEMON="/usr/local/bin/twistd" | |
USER=push | |
PIDFILE=/var/run/$NAME/$NAME.pid | |
LOGFILE=/var/log/xapsd.log | |
SOCKET=/tmp/xapsd.sock | |
BASE_DIR=$(su $USER -c "cd && pwd") | |
SCRIPT_DIR="$BASE_DIR/dovecot-xaps-daemon" | |
OPTIONS="--pidfile $PIDFILE --logfile $LOGFILE xapsd --key=$BASE_DIR/key.pem --certificate=$BASE_DIR/certificate.pem --database=$BASE_DIR/xapsd.json --socket=$SOCKET" | |
export PATH="${PATH:+$PATH:}/sbin" | |
[ -x $DAEMON ] || exit 0 | |
. /lib/lsb/init-functions | |
start_daemon () { | |
start-stop-daemon --start --pidfile $PIDFILE --chuid $USER --chdir $SCRIPT_DIR --exec $DAEMON -- $OPTIONS | |
} | |
stop_daemon () { | |
start-stop-daemon --stop --retry="TERM/15/KILL/5" --pidfile "$PIDFILE" --user "$USER" --chuid "$USER" | |
} | |
case "$1" in | |
start) | |
log_daemon_msg "Starting dovecot-xaps-daemon" "$NAME" | |
start_daemon | |
log_end_msg 0 | |
;; | |
stop) | |
log_daemon_msg "Stopping dovecot-xaps-daemon" "$NAME" | |
stop_daemon | |
log_end_msg 0 | |
;; | |
restart) | |
log_daemon_msg "Restarting dovecot-xaps-daemon" "$NAME" | |
stop_daemon | |
start_daemon | |
log_end_msg 0 | |
;; | |
*) | |
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" | |
exit 2 | |
;; | |
esac | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo su | |
apt-get install git-core python-twisted | |
adduser --disabled-login --disabled-password push | |
touch /var/log/xapsd.log | |
chown root:push /var/log/xapsd.log | |
chmod 775 /var/log/xapsd.log | |
mkdir /var/run/xapsd | |
chown root:push /var/run/xapsd | |
chmod 775 /var/run/xapsd | |
su push -c "cd && git clone https://github.com/st3fan/dovecot-xaps-daemon.git" | |
cp init.d-dovecot-xaps-daemon /etc/init.d/xapsd | |
chmod a+x /etc/init.d/xapsd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment