Created
October 7, 2013 09:30
-
-
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.
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/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