summaryrefslogtreecommitdiff
path: root/puppet/modules/obfsproxy/files/obfsproxy_daemon
diff options
context:
space:
mode:
authorirregulator <irregulator@riseup.net>2014-05-20 23:20:58 +0300
committerelijah <elijah@riseup.net>2014-07-01 16:05:40 -0700
commit54fcafe131c411a49e4277cd0d14c6ea20044203 (patch)
tree9c1dfd9a8d789415d12190922646646486b40f42 /puppet/modules/obfsproxy/files/obfsproxy_daemon
parent82dbbf823d6637082f63e55ed1d2f57a11e0d481 (diff)
Initial commit for obfsproxy server feature in platform
Diffstat (limited to 'puppet/modules/obfsproxy/files/obfsproxy_daemon')
-rwxr-xr-xpuppet/modules/obfsproxy/files/obfsproxy_daemon99
1 files changed, 99 insertions, 0 deletions
diff --git a/puppet/modules/obfsproxy/files/obfsproxy_daemon b/puppet/modules/obfsproxy/files/obfsproxy_daemon
new file mode 100755
index 00000000..f5914980
--- /dev/null
+++ b/puppet/modules/obfsproxy/files/obfsproxy_daemon
@@ -0,0 +1,99 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: obfsproxy daemon
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: obfsproxy daemon
+# Description: obfsproxy daemon
+### END INIT INFO
+
+. /lib/lsb/init-functions
+
+DAEMON=/usr/bin/obfsproxy
+NAME=obfsproxy
+DESC="obfsproxy daemon"
+USER=obfsproxy
+PIDFILE=/var/run/obfsproxy.pid
+CONF=/etc/obfsproxy.conf
+
+# If the daemon is not there, then exit.
+test -x $DAEMON || exit 0
+
+if [ -f $CONF ] ; then
+ . $CONF
+else
+ echo "Obfsproxy configuration file is missing, aborting..."
+ exit
+fi
+
+DAEMONARGS=" --log-min-severity=$LOG $TRANSPORT $PARAM \
+ --dest=$DEST_IP:$DEST_PORT server 0.0.0.0:$PORT"
+
+start_obfsproxy() {
+ start-stop-daemon --start --quiet --oknodo -m --pidfile $PIDFILE \
+ -b -c $USER --startas $DAEMON --$DAEMONARGS
+}
+
+stop_obfsproxy() {
+ start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
+}
+
+status_obfsproxy() {
+ status_of_proc -p $PIDFILE $DAEMON $NAME && status="0" || status="$?"
+}
+
+case $1 in
+ start)
+ if [ -e $PIDFILE ]; then
+ status_obfsproxy
+ if [ $status = "0" ]; then
+ exit
+ fi
+ fi
+ log_begin_msg "Starting $DESC"
+ start_obfsproxy
+ log_end_msg $?
+ ;;
+ stop)
+ if [ -e $PIDFILE ]; then
+ status_obfsproxy
+ if [ $status = "0" ]; then
+ log_begin_msg "Stopping $DESC"
+ stop_obfsproxy
+ rm -f $PIDFILE
+ log_end_msg $?
+ fi
+ else
+ log_daemon_msg "$NAME is not running"
+ log_end_msg $?
+ fi
+ ;;
+ restart)
+ $0 stop && sleep 2 && $0 start
+ ;;
+ status)
+# if [ -e $PIDFILE ]; then
+# #status_of_proc -p $PIDFILE $DAEMON "$NAME " && exit 0 || exit $?
+# status_obfsproxy
+# else
+# log_daemon_msg "$NAME is not running"
+# log_end_msg 0
+# fi
+ status_obfsproxy
+ ;;
+ reload)
+ if [ -e $PIDFILE ]; then
+ start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE --name $NAME
+ log_success_msg "$DESC reloaded successfully"
+ else
+ log_failure_msg "$PIDFILE does not exists"
+ fi
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload|status}"
+ exit 2
+ ;;
+esac