Skip to content

Instantly share code, notes, and snippets.

@mad-gooze
Created October 7, 2013 09:30
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mad-gooze/6865106 to your computer and use it in GitHub Desktop.
Small script for running yaxy proxy (http://github.com/Kolyaj/Yaxy) as a service.
#!/bin/bash
RETVAL=0
PIDFILE="/var/run/yaxy.pid"
CONFIGFILE="/etc/.yaxy"
LOGFILE="/var/log/yaxy.log"
PORT="8558"
start() {
if [ -e $PIDFILE ]
then
echo "yaxy already started"
else
echo "Starting yaxy..."
if [ -e $LOGFILE ]
then
rm $LOGFILE
fi
yaxy --config $CONFIGFILE >> $LOGFILE &
echo $! >> $PIDFILE
fi
}
stop() {
if [ -e $PIDFILE ]
then
PID=$(cat $PIDFILE)
echo "Stopping yaxy..."
rm $PIDFILE
kill $PID
else
echo "yaxy not started"
fi
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
log)
cat $LOGFILE
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment