Skip to content

Instantly share code, notes, and snippets.

@kajic
Created March 11, 2014 16:37
Show Gist options
  • Save kajic/9489581 to your computer and use it in GitHub Desktop.
Save kajic/9489581 to your computer and use it in GitHub Desktop.
init.d script for twofishes, assumes you have a twofishes user with the binary and data in /home/twofishes/opt/twofishes
#!/bin/sh
JAVA=/usr/bin/java
JAR=/home/twofishes/opt/twofishes/server-assembly-0.81.9.jar
DATA=/home/twofishes/opt/twofishes/data/
OPTS="-Xmx4096m -jar $JAR --hfile_basepath $DATA --preload 1 --warmup 1"
NAME=twofishes
DESC=twofishes
test -x $JAVA || exit 0
test -e $JAR || exit 0
test -d $DATA || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --verbose --background --chuid "twofishes:twofishes" --make-pidfile --pidfile /var/run/$NAME.pid \
--exec $JAVA -- $OPTS || true
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --verbose --chuid "twofishes:twofishes" --pidfile /var/run/$NAME.pid \
--exec $JAVA || true
echo "$NAME."
;;
*)
echo "Usage: $NAME {start|stop}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment