[tor-commits] [flashproxy/js] Add init.d script for websockify.

dcf at torproject.org dcf at torproject.org
Mon Apr 2 16:40:50 UTC 2012


commit 0603a500826ce7930c62857513f395b28e2789a4
Author: David Fifield <david at bamsoftware.com>
Date:   Sun Apr 1 23:12:40 2012 -0700

    Add init.d script for websockify.
---
 README            |   11 +++++++++
 init.d/websockify |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/README b/README
index 51c19c4..a28c608 100644
--- a/README
+++ b/README
@@ -125,6 +125,8 @@ The relay runs with a WebSocket proxy in external proxy mode.
 	git clone git://github.com/kanaka/websockify.git
 This command proxies WebSocket on port 9901 to a local ORPort on 9001.
 	./websockify :9901 127.0.0.1:9001
+The init.d script described under "Installing so as to restart at boot"
+does this automatically.
 
 Add this line to torrc to make the relay use the external proxy:
 	ServerTransportPlugin websocket proxy 127.0.0.1:9901
@@ -161,3 +163,12 @@ CentOS. "make install" copies files to /usr/local/bin.
 	-- Edit /etc/init.d/facilitator to set $RELAY.
 	# chkconfig --add facilitator
 	# service facilitator start
+
+	# cd websockify
+	# cp websockify websocket.py /usr/local/bin
+	# useradd -d /dev/null -s /bin/false websockify
+	# mkdir /var/websockify
+	# chown -R websockify.websockify /var/websockify
+	# cp ~/flashproxy/init.d/websockify /etc/init.d/websockify
+	# chkconfig --add websockify
+	# service websockify start
diff --git a/init.d/websockify b/init.d/websockify
new file mode 100755
index 0000000..22a5450
--- /dev/null
+++ b/init.d/websockify
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# websockify   This shell script takes care of starting and stopping
+#              the websockify server.
+#
+# chkconfig: 2345 90 10
+# description: websockify server.
+# processname: websockify
+# pidfile: /var/websockify/websockify.pid
+
+# Installation instructions:
+# cp init.d/websockify /etc/init.d/websockify
+# chkconfig --add websockify
+# service websockify start
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+BINDIR=/usr/local/bin
+VARDIR=/var/websockify
+WEBSOCKIFY=$BINDIR/websockify
+WEBSOCKIFY_PORT=9901
+LOCAL_ADDRESS=127.0.0.1:9001
+PIDFILE=$VARDIR/websockify.pid
+USER=websockify
+
+# See how we were called.
+case "$1" in
+  start)
+	[ -x $WEBSOCKIFY ] || exit 1
+	echo -n $"Starting websockify server: "
+	cd $VARDIR && daemon --user "$USER" --pidfile $PIDFILE "$WEBSOCKIFY" :"$WEBSOCKIFY_PORT" "$LOCAL_ADDRESS"
+	RETVAL=$?
+	echo
+	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/websockify
+	;;
+  stop)
+	# Stop daemon.
+	echo -n $"Shutting down websockify server: "
+	killproc websockify
+	RETVAL=$?
+	echo
+	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/websockify
+	;;
+  status)
+	status websockify
+	RETVAL=$?
+	;;
+  restart|reload)
+	$0 stop
+	$0 start
+	;;
+  condrestart)
+	[ -f /var/lock/subsys/websockify ] && restart || :
+	;;
+  *)
+	echo $"Usage: $0 {start|stop|status|restart}"
+	RETVAL=3
+	;;
+esac
+
+exit $RETVAL





More information about the tor-commits mailing list