[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] handle initscripts in a more robust way and provide an option not to install them



commit 471a4bc234be1bf7e5f33142b1d1c1688ee50bbf
Author: Ximin Luo <infinity0@xxxxxxx>
Date:   Sat Sep 14 15:59:51 2013 +0100

    handle initscripts in a more robust way and provide an option not to install them
---
 facilitator/Makefile.am  |   76 +++++++++++++++++++++++++++++-----------------
 facilitator/configure.ac |    8 +++++
 2 files changed, 56 insertions(+), 28 deletions(-)

diff --git a/facilitator/Makefile.am b/facilitator/Makefile.am
index 44c0442..5705e91 100644
--- a/facilitator/Makefile.am
+++ b/facilitator/Makefile.am
@@ -1,7 +1,9 @@
 # our own variables
 
 fpfacilitatoruser = @fpfacilitatoruser@
-initscriptdir = $(sysconfdir)/init.d
+# unfortunately sysvinit does not support having initscripts in /usr/local/etc
+# yet, so we have to hard code a path here. :(
+initscriptdir = /etc/init.d
 exampledir = $(docdir)/examples
 appenginedir = $(pkgdatadir)/appengine
 pkgconfdir = $(sysconfdir)/flashproxy
@@ -10,7 +12,9 @@ appengineconfdir = $(pkgconfdir)/reg-appengine
 # automake PLVs
 
 dist_bin_SCRIPTS = facilitator facilitator-email-poller facilitator-reg-daemon facilitator-reg facilitator.cgi fac.py
+if DO_INITSCRIPTS
 initscript_SCRIPTS = init.d/facilitator init.d/facilitator-email-poller init.d/facilitator-reg-daemon
+endif
 
 dist_doc_DATA = doc/appengine-howto.txt doc/facilitator-howto.txt doc/gmail-howto.txt README
 dist_example_DATA = examples/fp-facilitator conf/reg-email.pass
@@ -31,7 +35,16 @@ CLEANFILES = $(initscript_SCRIPTS)
 # root access and *must not be run* for fake/staged installs, e.g. when giving
 # non-standard directories to ./configure or DESTDIR to make.
 
-pre-install:
+pre-install: meta-install-sanity install-user
+post-install: meta-install-sanity install-secrets install-symlinks install-daemon
+pre-remove: meta-install-sanity remove-daemon remove-symlinks remove-secrets
+post-remove: meta-install-sanity remove-user
+
+meta-install-sanity:
+	test "x$(DESTDIR)" = "x" || { echo >&2 \
+	  "don't run {pre,post}-{install,remove} when DESTDIR is set"; false; }
+
+install-user:
 	id -u $(fpfacilitatoruser) >/dev/null 2>&1 || { \
 	which adduser >/dev/null 2>&1 && \
 	  adduser --quiet \
@@ -49,7 +62,17 @@ pre-install:
 	    --shell /bin/false \
 	    $(fpfacilitatoruser) ; }
 
-post-install-secrets:
+remove-user:
+	: # deluser does actually remove the group as well
+	id -u $(fpfacilitatoruser) >/dev/null 2>&1 && { \
+	which deluser >/dev/null 2>&1 && \
+	  deluser --quiet \
+	    --system \
+	    $(fpfacilitatoruser) || \
+	  userdel \
+	    $(fpfacilitatoruser) ; } || true
+
+install-secrets:
 	install -m 600 /dev/null $(pkgconfdir)/reg-daemon.key
 	openssl genrsa 2048 | tee $(pkgconfdir)/reg-daemon.key | \
 	openssl rsa -pubout > $(pkgconfdir)/reg-daemon.pub
@@ -57,42 +80,39 @@ post-install-secrets:
 	chown $(fpfacilitatoruser): $(pkgconfdir)/reg-daemon.key
 	chown $(fpfacilitatoruser): $(pkgconfdir)/reg-email.pass
 
-post-install-symlinks:
+remove-secrets:
+	rm -f $(pkgconfdir)/reg-*
+
+install-symlinks:
 	for i in fp-reg.go app.yaml README; do \
 	  $(LN_S) -f $(appenginedir)/$$i $(appengineconfdir)/$$i; \
 	done
 
-post-install-daemon:
+remove-symlinks:
+	rm -rf $(appengineconfdir)
+
+# initscripts: assume that if the user wanted to install them, then they also
+# wanted to configure them, and that the system supports them. if this isn't the
+# case then either (a) they are doing a staged install for another system and
+# shouldn't be running {pre,post}-{install,remove} or (b) they shouldn't have
+# told us to install initscripts for their system that doesn't support it.
+
+install-daemon:
+if DO_INITSCRIPTS
 	for i in facilitator facilitator-email-poller facilitator-reg-daemon; do \
 	  update-rc.d $$i defaults; \
 	  invoke-rc.d $$i start; \
 	done
+endif
 
-post-install: post-install-secrets post-install-symlinks post-install-daemon
-
-pre-remove-daemon:
+remove-daemon:
+if DO_INITSCRIPTS
 	for i in facilitator facilitator-email-poller facilitator-reg-daemon; do \
 	  invoke-rc.d $$i stop; \
+	  update-rc.d $$i remove; \
 	done
-
-pre-remove-symlinks:
-	rm -rf $(appengineconfdir)
-
-pre-remove-secrets:
-	rm -f $(pkgconfdir)/reg-*
-
-pre-remove: pre-remove-daemon pre-remove-symlinks pre-remove-secrets
-
-post-remove:
-	: # deluser does actually remove the group as well
-	id -u $(fpfacilitatoruser) >/dev/null 2>&1 && { \
-	which deluser >/dev/null 2>&1 && \
-	  deluser --quiet \
-	    --system \
-	    $(fpfacilitatoruser) || \
-	  userdel \
-	    $(fpfacilitatoruser) ; } || true
+endif
 
 .PHONY: pre-install post-install pre-remove post-remove
-.PHONY: post-install-secrets post-install-symlinks post-install-daemon
-.PHONY: pre-remove-daemon pre-remove-symlinks pre-remove-secrets
+.PHONY: install-user install-secrets install-symlinks install-daemon
+.PHONY: remove-user remove-secrets remove-symlinks remove-daemon
diff --git a/facilitator/configure.ac b/facilitator/configure.ac
index 386c20f..e6a100d 100644
--- a/facilitator/configure.ac
+++ b/facilitator/configure.ac
@@ -11,4 +11,12 @@ AC_CONFIG_FILES([Makefile
 	init.d/facilitator-reg-daemon])
 
 AC_PROG_LN_S
+# check that we want to install initscripts. don't bother checking that they
+# are supported, since we might be doing a staged install on a different system.
+AC_ARG_ENABLE([initscripts],
+	[AS_HELP_STRING([--disable-initscripts],
+		[install and configure sysvinit-style initscripts (default yes)])],
+	[do_initscripts=], [do_initscripts=yes])
+AM_CONDITIONAL([DO_INITSCRIPTS], [test "x$do_initscripts" = xyes])
+
 AC_OUTPUT



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits