Skip to content

Instantly share code, notes, and snippets.

@oldcai
Last active August 29, 2015 13:59
Show Gist options
  • Save oldcai/10699734 to your computer and use it in GitHub Desktop.
Save oldcai/10699734 to your computer and use it in GitHub Desktop.
ShadowSPDY init scripts
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=shadowspdy_client
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/opt/ShadowSPDY/bin/splocal
DAEMON_OPTS="-c /opt/ShadowSPDY/config.json"
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
ulimit -s 512
start () {
echo -n "Starting daemon: "$NAME
touch $PIDFILE
#chown oldcai:oldcai $PIDFILE
#start-stop-daemon --make-pidfile --background --start --quiet --pidfile $PIDFILE --chuid oldcai:oldcai --exec $DAEMON -- $DAEMON_OPTS || true
start-stop-daemon --make-pidfile --background --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS || true
echo "."
}
stop () {
echo -n "Stopping daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE || true
echo "."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo -n "Restarting daemon: "$NAME
stop
sleep 1
start
;;
*)
echo "Usage: "$1" {start|stop|restart}"
exit 1
esac
exit 0
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=shadowspdy_server
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/opt/ShadowSPDY/bin/spserver
DAEMON_OPTS="-c /opt/ShadowSPDY/config.json"
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
ulimit -s 512
start () {
echo -n "Starting daemon: "$NAME
touch $PIDFILE
chown root:root $PIDFILE
start-stop-daemon --make-pidfile --background --start --quiet --pidfile $PIDFILE --chuid root:root --exec $DAEMON -- $DAEMON_OPTS || true
echo "."
}
stop () {
echo -n "Stopping daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE || true
echo "."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo -n "Restarting daemon: "$NAME
stop
sleep 1
start
;;
*)
echo "Usage: "$1" {start|stop|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment