[tor-commits] [flashproxy/master] use GNU autotools to create an installable package, including docs
infinity0 at torproject.org
infinity0 at torproject.org
Thu Nov 21 13:18:46 UTC 2013
commit 0080b8dff74c583682867eb190e49237fee3b9db
Author: Ximin Luo <infinity0 at gmx.com>
Date: Thu Sep 12 17:03:08 2013 +0100
use GNU autotools to create an installable package, including docs
---
Makefile | 5 +-
facilitator/.gitignore | 27 +++++
facilitator/Makefile | 19 ----
facilitator/Makefile.am | 42 ++++++++
facilitator/autogen.sh | 2 +
facilitator/conf/fp-facilitator | 27 +++++
facilitator/configure.ac | 13 +++
facilitator/doc/facilitator-howto.txt | 39 ++------
facilitator/init.d/facilitator | 122 -----------------------
facilitator/init.d/facilitator-email-poller | 119 ----------------------
facilitator/init.d/facilitator-email-poller.in | 121 +++++++++++++++++++++++
facilitator/init.d/facilitator-reg-daemon | 119 ----------------------
facilitator/init.d/facilitator-reg-daemon.in | 121 +++++++++++++++++++++++
facilitator/init.d/facilitator.in | 125 ++++++++++++++++++++++++
14 files changed, 492 insertions(+), 409 deletions(-)
diff --git a/Makefile b/Makefile
index bf504af..8771405 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,10 @@ test:
./flashproxy-client-test
test-full: test
- cd facilitator && make test
+ cd facilitator && \
+ { test -x ./config.status && ./config.status || \
+ { test -x ./configure || ./autogen.sh; } && ./configure; } \
+ && make && make check
cd proxy && make test
.PHONY: all install dist sign dist-exe clean clean-all test test-full
diff --git a/facilitator/.gitignore b/facilitator/.gitignore
new file mode 100644
index 0000000..7574515
--- /dev/null
+++ b/facilitator/.gitignore
@@ -0,0 +1,27 @@
+# files build by autogen.sh
+/aclocal.m4
+/configure
+/depcomp
+/install-sh
+/missing
+/test-driver
+/Makefile.in
+
+# files built by ./configure
+/init.d/facilitator
+/init.d/facilitator-email-poller
+/init.d/facilitator-reg-daemon
+/Makefile
+/config.status
+/config.log
+
+# files built by autoconf not meant for source-distribution
+/autom4te.cache
+
+# files for binary-distribution
+/flashproxy-facilitator-*.tar.*
+
+# files output by test-driver
+/test-*.log
+/*-test.log
+/*-test.trs
diff --git a/facilitator/Makefile b/facilitator/Makefile
deleted file mode 100644
index 07ed125..0000000
--- a/facilitator/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-DESTDIR =
-PREFIX = /usr/local
-BINDIR = $(PREFIX)/bin
-
-all:
- :
-
-install:
- mkdir -p $(DESTDIR)$(BINDIR)
- cp -f facilitator facilitator-email-poller facilitator-reg-daemon facilitator-reg facilitator.cgi fac.py $(DESTDIR)$(BINDIR)
- cp -f init.d/facilitator init.d/facilitator-email-poller init.d/facilitator-reg-daemon $(DESTDIR)/etc/init.d/
-
-clean:
- rm -f *.pyc
-
-test:
- ./facilitator-test
-
-.PHONY: all install clean test
diff --git a/facilitator/Makefile.am b/facilitator/Makefile.am
new file mode 100644
index 0000000..58e19b3
--- /dev/null
+++ b/facilitator/Makefile.am
@@ -0,0 +1,42 @@
+# our own variables
+
+fpfacilitatoruser = @fpfacilitatoruser@
+initscriptdir = $(sysconfdir)/init.d
+exampledir = $(docdir)/examples
+
+# automake PLVs
+
+dist_bin_SCRIPTS = facilitator facilitator-email-poller facilitator-reg-daemon facilitator-reg facilitator.cgi fac.py
+initscript_SCRIPTS = init.d/facilitator init.d/facilitator-email-poller init.d/facilitator-reg-daemon
+
+dist_doc_DATA = doc/appengine-howto.txt doc/facilitator-howto.txt doc/gmail-howto.txt README
+dist_example_DATA = conf/fp-facilitator
+
+dist_TESTS = facilitator-test
+
+# stuff built from AC_CONFIG_FILES
+# see http://www.gnu.org/software/automake/manual/html_node/Scripts.html
+CLEANFILES = $(initscript_SCRIPTS)
+
+# our own targets
+
+post-install:
+ which adduser >/dev/null 2>&1 && \
+ adduser --quiet \
+ --system \
+ --disabled-password \
+ --home $(sysconfdir)/flashproxy \
+ --no-create-home \
+ --shell /bin/false \
+ --group \
+ $(fpfacilitatoruser) || \
+ useradd \
+ --system \
+ --home $(sysconfdir)/flashproxy \
+ -M \
+ --shell /bin/false \
+ $(fpfacilitatoruser)
+ for i in facilitator facilitator-email-poller facilitator-reg-daemon; do \
+ update-rc.d $$i defaults; \
+ /etc/init.d/$$i start; \
+ done
diff --git a/facilitator/autogen.sh b/facilitator/autogen.sh
new file mode 100755
index 0000000..4e7cc05
--- /dev/null
+++ b/facilitator/autogen.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+autoreconf -if
diff --git a/facilitator/conf/fp-facilitator b/facilitator/conf/fp-facilitator
new file mode 100644
index 0000000..125d0cc
--- /dev/null
+++ b/facilitator/conf/fp-facilitator
@@ -0,0 +1,27 @@
+# This is an example apache2 config for serving the facilitator.
+#
+# You can edit this file according to the instructions below, then copy it to
+# /etc/apache2/sites-available/fp-facilitator, or wherever is appropriate. Then
+# you can run `a2ensite fp-facilitator` to enable it.
+#
+<VirtualHost *:443>
+ # Update this with your hostname!
+ ServerName fp-facilitator.example.com
+ DocumentRoot /dev/null
+ # Make sure the path below matchs where you installed the facilitator.
+ ScriptAliasMatch ^(.*) /usr/bin/facilitator.cgi$1
+ MaxClients 256
+
+ CustomLog ${APACHE_LOG_DIR}/fp-access.log common
+ ErrorLog ${APACHE_LOG_DIR}/fp-error.log
+ LogLevel warn
+ SSLEngine on
+
+ # Manually install your certificate to the following location.
+ SSLCertificateFile /etc/apache2/fp-facilitator.pem
+ # If you got an intermediate certificate, uncomment the following line
+ # and install the certificate to that location too.
+ #SSLCertificateChainFile /etc/apache2/fp-intermediate.pem
+
+ Header add Strict-Transport-Security "max-age=15768000"
+</VirtualHost>
diff --git a/facilitator/configure.ac b/facilitator/configure.ac
new file mode 100644
index 0000000..3b74de5
--- /dev/null
+++ b/facilitator/configure.ac
@@ -0,0 +1,13 @@
+AC_PREREQ([2.69])
+AC_INIT([flashproxy-facilitator], [1.3])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+
+AC_ARG_VAR(fpfacilitatoruser, [the user/group for the facilitator to run as])
+fpfacilitatoruser="${fpfacilitatoruser:-flashproxy-fac}"
+
+AC_CONFIG_FILES([Makefile
+ init.d/facilitator
+ init.d/facilitator-email-poller
+ init.d/facilitator-reg-daemon])
+
+AC_OUTPUT
diff --git a/facilitator/doc/facilitator-howto.txt b/facilitator/doc/facilitator-howto.txt
index a5cadb6..6283cf8 100644
--- a/facilitator/doc/facilitator-howto.txt
+++ b/facilitator/doc/facilitator-howto.txt
@@ -87,10 +87,6 @@ Restart servers.
== Facilitator program installation
-Create the user the daemons will run as.
-
- # useradd --shell /usr/sbin/nologin --system --home /nonexistent -M facilitator-nobody
-
Install the programs.
# cd
@@ -103,6 +99,13 @@ This installs facilitator.cgi, facilitator, facilitator-email-poller,
facilitator-reg-daemon, facilitator-reg, and fac.py to /usr/local/bin.
It also installs System V init files to /etc/init.d/.
+Do post-installation tasks.
+
+ # make postinst
+
+This creates a user for the daemons to run as, and sets up the init.d
+scripts in the default system runlevels.
+
=== Registration daemon setup
The facilitator-reg-daemon program requires a private RSA key (used to
@@ -119,13 +122,6 @@ reg-daemon.pub into the appropriate place.
Install reg-daemon.key /etc/flashproxy to match what the init script
expects.
-=== Init script setup
-
- # update-rc.d facilitator defaults
- # /etc/init.d/facilitator start
- # update-rc.d facilitator-reg-daemon defaults
- # /etc/init.d/facilitator-reg-daemon start
-
== HTTP server setup
Apache is the web server that runs the CGI program.
@@ -138,24 +134,9 @@ Edit /etc/apache2/ports.conf and comment out the port 80 configuration.
# NameVirtualHost *:80
# Listen 80
-Create a new file /etc/apache2/sites-available/fp-facilitator with
-these contents:
- MaxClients 256
- <VirtualHost *:443>
- ServerName fp-facilitator.example.com
- DocumentRoot /dev/null
- ScriptAliasMatch ^(.*) /usr/local/bin/facilitator.cgi$1
- CustomLog /dev/null common
- ErrorLog ${APACHE_LOG_DIR}/error.log
- LogLevel warn
- SSLEngine on
- SSLCertificateFile /etc/apache2/fp-facilitator.pem
- SSLCertificateChainFile /etc/apache2/intermediate.pem
- Header add Strict-Transport-Security "max-age=15768000"
- </VirtualHost>
-intermediate.pem is a possible intermediate certificate file provided by
-the CA; if you did not get one, then leave off the
-SSLCertificateChainFile line.
+Edit conf/fp-facilitator as per the instructions given in that file, and
+install it to /etc/apache2/sites-available/fp-facilitator or whatever is
+appropriate for your apache2 installation.
Link the configured site into sites-enabled.
# a2ensite fp-facilitator
diff --git a/facilitator/init.d/facilitator b/facilitator/init.d/facilitator
deleted file mode 100755
index 19bb482..0000000
--- a/facilitator/init.d/facilitator
+++ /dev/null
@@ -1,122 +0,0 @@
-#! /bin/sh
-### BEGIN INIT INFO
-# Provides: facilitator
-# Required-Start: $remote_fs $syslog
-# Required-Stop: $remote_fs $syslog
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Flash proxy facilitator
-# Description: Debian init script for the flash proxy facilitator.
-### END INIT INFO
-#
-# Author: David Fifield <david at bamsoftware.com>
-#
-
-# Based on /etc/init.d/skeleton from Debian 6.
-
-# The relay must support the websocket pluggable transport.
-# This is the IPv4 address of tor1.bamsoftware.com.
-RELAY=173.255.221.44:9901
-
-PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
-DESC="Flash proxy facilitator"
-NAME=facilitator
-PIDFILE=/var/run/$NAME.pid
-LOGFILE=/var/log/$NAME.log
-PRIVDROP_USER=facilitator-nobody
-DAEMON=/usr/local/bin/$NAME
-DAEMON_ARGS="-r $RELAY --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
-SCRIPTNAME=/etc/init.d/$NAME
-
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
-
-. /lib/init/vars.sh
-. /lib/lsb/init-functions
-
-#
-# Function that starts the daemon/service
-#
-do_start()
-{
- # Return
- # 0 if daemon has been started
- # 1 if daemon was already running
- # 2 if daemon could not be started
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
- || return 1
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
- $DAEMON_ARGS \
- || return 2
-}
-
-#
-# Function that stops the daemon/service
-#
-do_stop()
-{
- # Return
- # 0 if daemon has been stopped
- # 1 if daemon was already stopped
- # 2 if daemon could not be stopped
- # other if a failure occurred
- start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
- RETVAL="$?"
- [ "$RETVAL" = 2 ] && return 2
- # Wait for children to finish too if this is a daemon that forks
- # and if the daemon is only ever run from this initscript.
- # If the above conditions are not satisfied then add some other code
- # that waits for the process to drop all resources that could be
- # needed by services started subsequently. A last resort is to
- # sleep for some time.
- start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
- [ "$?" = 2 ] && return 2
- rm -f $PIDFILE
- return "$RETVAL"
-}
-
-case "$1" in
- start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
- do_start
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- status)
- status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
- ;;
- restart|force-reload)
- log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0 ;;
- 1) log_end_msg 1 ;; # Old process is still running
- *) log_end_msg 1 ;; # Failed to start
- esac
- ;;
- *)
- # Failed to stop
- log_end_msg 1
- ;;
- esac
- ;;
- *)
- echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
- exit 3
- ;;
-esac
-
-:
diff --git a/facilitator/init.d/facilitator-email-poller b/facilitator/init.d/facilitator-email-poller
deleted file mode 100755
index 2c9ecb8..0000000
--- a/facilitator/init.d/facilitator-email-poller
+++ /dev/null
@@ -1,119 +0,0 @@
-#! /bin/sh
-### BEGIN INIT INFO
-# Provides: facilitator-email-poller
-# Required-Start: $remote_fs $syslog
-# Required-Stop: $remote_fs $syslog
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Flash proxy email rendezvous poller
-# Description: Debian init script for the flash proxy email rendezvous poller.
-### END INIT INFO
-#
-# Author: David Fifield <david at bamsoftware.com>
-#
-
-# Based on /etc/init.d/skeleton from Debian 6.
-
-PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
-DESC="Flash proxy email rendezvous poller"
-NAME=facilitator-email-poller
-PIDFILE=/var/run/$NAME.pid
-LOGFILE=/var/log/$NAME.log
-CONFDIR=/etc/flashproxy
-PRIVDROP_USER=facilitator-nobody
-DAEMON=/usr/local/bin/$NAME
-DAEMON_ARGS="--pass $CONFDIR/reg-email.pass --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
-SCRIPTNAME=/etc/init.d/$NAME
-
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
-
-. /lib/init/vars.sh
-. /lib/lsb/init-functions
-
-#
-# Function that starts the daemon/service
-#
-do_start()
-{
- # Return
- # 0 if daemon has been started
- # 1 if daemon was already running
- # 2 if daemon could not be started
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
- || return 1
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
- $DAEMON_ARGS \
- || return 2
-}
-
-#
-# Function that stops the daemon/service
-#
-do_stop()
-{
- # Return
- # 0 if daemon has been stopped
- # 1 if daemon was already stopped
- # 2 if daemon could not be stopped
- # other if a failure occurred
- start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
- RETVAL="$?"
- [ "$RETVAL" = 2 ] && return 2
- # Wait for children to finish too if this is a daemon that forks
- # and if the daemon is only ever run from this initscript.
- # If the above conditions are not satisfied then add some other code
- # that waits for the process to drop all resources that could be
- # needed by services started subsequently. A last resort is to
- # sleep for some time.
- start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
- [ "$?" = 2 ] && return 2
- rm -f $PIDFILE
- return "$RETVAL"
-}
-
-case "$1" in
- start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
- do_start
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- status)
- status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
- ;;
- restart|force-reload)
- log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0 ;;
- 1) log_end_msg 1 ;; # Old process is still running
- *) log_end_msg 1 ;; # Failed to start
- esac
- ;;
- *)
- # Failed to stop
- log_end_msg 1
- ;;
- esac
- ;;
- *)
- echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
- exit 3
- ;;
-esac
-
-:
diff --git a/facilitator/init.d/facilitator-email-poller.in b/facilitator/init.d/facilitator-email-poller.in
new file mode 100755
index 0000000..ef90794
--- /dev/null
+++ b/facilitator/init.d/facilitator-email-poller.in
@@ -0,0 +1,121 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: facilitator-email-poller
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Flash proxy email rendezvous poller
+# Description: Debian init script for the flash proxy email rendezvous poller.
+### END INIT INFO
+#
+# Author: David Fifield <david at bamsoftware.com>
+#
+
+# Based on /etc/init.d/skeleton from Debian 6.
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
+DESC="Flash proxy email rendezvous poller"
+NAME=facilitator-email-poller
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+PIDFILE=@localstatedir@/run/$NAME.pid
+LOGFILE=@localstatedir@/log/$NAME.log
+CONFDIR=@sysconfdir@/flashproxy
+PRIVDROP_USER=@fpfacilitatoruser@
+DAEMON=@bindir@/$NAME
+DAEMON_ARGS="--pass $CONFDIR/reg-email.pass --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ restart|force-reload)
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/facilitator/init.d/facilitator-reg-daemon b/facilitator/init.d/facilitator-reg-daemon
deleted file mode 100755
index e299468..0000000
--- a/facilitator/init.d/facilitator-reg-daemon
+++ /dev/null
@@ -1,119 +0,0 @@
-#! /bin/sh
-### BEGIN INIT INFO
-# Provides: facilitator-reg-daemon
-# Required-Start: $remote_fs $syslog
-# Required-Stop: $remote_fs $syslog
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Flash proxy local registration daemon.
-# Description: Debian init script for the flash proxy local registration daemon.
-### END INIT INFO
-#
-# Author: David Fifield <david at bamsoftware.com>
-#
-
-# Based on /etc/init.d/skeleton from Debian 6.
-
-PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
-DESC="Flash proxy local registration daemon"
-NAME=facilitator-reg-daemon
-PIDFILE=/var/run/$NAME.pid
-LOGFILE=/var/log/$NAME.log
-CONFDIR=/etc/flashproxy
-PRIVDROP_USER=facilitator-nobody
-DAEMON=/usr/local/bin/$NAME
-DAEMON_ARGS="--key $CONFDIR/reg-daemon.key --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
-SCRIPTNAME=/etc/init.d/$NAME
-
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
-
-. /lib/init/vars.sh
-. /lib/lsb/init-functions
-
-#
-# Function that starts the daemon/service
-#
-do_start()
-{
- # Return
- # 0 if daemon has been started
- # 1 if daemon was already running
- # 2 if daemon could not be started
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
- || return 1
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
- $DAEMON_ARGS \
- || return 2
-}
-
-#
-# Function that stops the daemon/service
-#
-do_stop()
-{
- # Return
- # 0 if daemon has been stopped
- # 1 if daemon was already stopped
- # 2 if daemon could not be stopped
- # other if a failure occurred
- start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
- RETVAL="$?"
- [ "$RETVAL" = 2 ] && return 2
- # Wait for children to finish too if this is a daemon that forks
- # and if the daemon is only ever run from this initscript.
- # If the above conditions are not satisfied then add some other code
- # that waits for the process to drop all resources that could be
- # needed by services started subsequently. A last resort is to
- # sleep for some time.
- start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
- [ "$?" = 2 ] && return 2
- rm -f $PIDFILE
- return "$RETVAL"
-}
-
-case "$1" in
- start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
- do_start
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- status)
- status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
- ;;
- restart|force-reload)
- log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0 ;;
- 1) log_end_msg 1 ;; # Old process is still running
- *) log_end_msg 1 ;; # Failed to start
- esac
- ;;
- *)
- # Failed to stop
- log_end_msg 1
- ;;
- esac
- ;;
- *)
- echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
- exit 3
- ;;
-esac
-
-:
diff --git a/facilitator/init.d/facilitator-reg-daemon.in b/facilitator/init.d/facilitator-reg-daemon.in
new file mode 100755
index 0000000..5126baa
--- /dev/null
+++ b/facilitator/init.d/facilitator-reg-daemon.in
@@ -0,0 +1,121 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: facilitator-reg-daemon
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Flash proxy local registration daemon.
+# Description: Debian init script for the flash proxy local registration daemon.
+### END INIT INFO
+#
+# Author: David Fifield <david at bamsoftware.com>
+#
+
+# Based on /etc/init.d/skeleton from Debian 6.
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
+DESC="Flash proxy local registration daemon"
+NAME=facilitator-reg-daemon
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+PIDFILE=@localstatedir@/run/$NAME.pid
+LOGFILE=@localstatedir@/log/$NAME.log
+CONFDIR=@sysconfdir@/flashproxy
+PRIVDROP_USER=@fpfacilitatoruser@
+DAEMON=@bindir@/$NAME
+DAEMON_ARGS="--key $CONFDIR/reg-daemon.key --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ restart|force-reload)
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/facilitator/init.d/facilitator.in b/facilitator/init.d/facilitator.in
new file mode 100755
index 0000000..53c27b4
--- /dev/null
+++ b/facilitator/init.d/facilitator.in
@@ -0,0 +1,125 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: facilitator
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Flash proxy facilitator
+# Description: Debian init script for the flash proxy facilitator.
+### END INIT INFO
+#
+# Author: David Fifield <david at bamsoftware.com>
+#
+
+# Based on /etc/init.d/skeleton from Debian 6.
+
+# The relay must support the websocket pluggable transport.
+# This is the IPv4 address of tor1.bamsoftware.com.
+RELAY=173.255.221.44:9901
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
+DESC="Flash proxy facilitator"
+NAME=facilitator
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+PIDFILE=@localstatedir@/run/$NAME.pid
+LOGFILE=@localstatedir@/log/$NAME.log
+CONFDIR=@sysconfdir@/flashproxy
+PRIVDROP_USER=@fpfacilitatoruser@
+DAEMON=@bindir@/$NAME
+DAEMON_ARGS="-r $RELAY --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ restart|force-reload)
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
More information about the tor-commits
mailing list