Skip to content

Instantly share code, notes, and snippets.

@neroanelli
Created November 23, 2013 14:55
Show Gist options
  • Save neroanelli/7615447 to your computer and use it in GitHub Desktop.
Save neroanelli/7615447 to your computer and use it in GitHub Desktop.
redsocks2 initial script for tomato firmware.
#!/bin/sh
PREFIX="/opt/bin"
PIDFILE="/var/run/redsocks2.pid"
CONFFILE="/opt/etc/redsocks2/redsocks2.conf"
case "$1" in
start)
if [ -f "$PIDFILE" ]; then
echo "Redsocks2 is already running."
exit 1
fi
echo -n "Starting Redsocks2 Services: "
$PREFIX/redsocks2 -c $CONFFILE -p $PIDFILE
if [ "$?" = "0" ]; then
echo "succeeded."
else
echo "failed."
exit 1
fi
;;
stop)
if [ -f "$PIDFILE" ]; then
echo -n "Shutting down Redsocks2 Services: "
kill `cat $PIDFILE` > /dev/null
rm -f $PIDFILE
echo "succeeded."
else
echo "Redsocks2 is not running."
exit 1
fi
;;
restart)
"$0" stop
sleep 1
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment