[DRE-commits] [unicorn] 01/03: Revert "prevent auto-enable of SysV daemon on first install:"
Hleb Valoshka
tsfgnu-guest at moszumanska.debian.org
Mon Nov 2 13:06:41 UTC 2015
This is an automated email from the git hooks/post-receive script.
tsfgnu-guest pushed a commit to branch master
in repository unicorn.
commit fdeda992940fe2931e66bcef68470ec9e3308250
Author: Hleb Valoshka <375gnu at gmail.com>
Date: Wed Oct 7 10:51:10 2015 +0300
Revert "prevent auto-enable of SysV daemon on first install:"
This reverts commit 5c1c2d66c75af1a4a9261bec8ec383189e028153.
---
debian/unicorn.lintian-overrides | 2 --
debian/unicorn.postinst | 67 ++++++++++++++++++++++++++++++++++------
debian/unicorn.prerm | 19 ++++++++++++
3 files changed, 77 insertions(+), 11 deletions(-)
diff --git a/debian/unicorn.lintian-overrides b/debian/unicorn.lintian-overrides
deleted file mode 100644
index d75bcb6..0000000
--- a/debian/unicorn.lintian-overrides
+++ /dev/null
@@ -1,2 +0,0 @@
-## Override for postinst workaround to prevent auto-enable of SysV service:
-duplicate-updaterc.d-calls-in-postinst
diff --git a/debian/unicorn.postinst b/debian/unicorn.postinst
index b6869db..18d4cd7 100644
--- a/debian/unicorn.postinst
+++ b/debian/unicorn.postinst
@@ -2,14 +2,63 @@
set -e
+if [ $1 != "configure" ] ; then
+ exit 0
+fi
+
+if [ -f /etc/default/unicorn ]; then
+ . /etc/default/unicorn
+fi
+
+TIMEOUT=${TIMEOUT-60}
+PID=${PID-/run/unicorn.pid}
+OLD_PID="${PID}.oldbin"
+
+invoke() {
+ if [ -x "$(which invoke-rc.d)" ]; then
+ invoke-rc.d $1 $2
+ else
+ /etc/init.d/$1 $2
+ fi
+}
+
+running() {
+ invoke $1 status >/dev/null 2>&1
+}
+
+sig() {
+ test -s $PID && kill -$1 `cat $PID`
+}
+
+oldsig() {
+ test -s $OLD_PID && kill -$1 `cat $OLD_PID`
+}
+
+upgrade() {
+ echo "Trying to upgrade running server"
+ if sig USR2 && sleep 2 && sig 0 && oldsig QUIT ; then
+ n=$TIMEOUT
+ while test -s $OLD_PID && test $n -ge 0 ; do
+ printf '.' && sleep 1 && n=`expr $n - 1`
+ done
+
+ if test $n -lt 0 && test -s $OLD_PID; then
+ echo "$OLD_PID still exists after $TIMEOUT seconds. Killing and starting new."
+ sig KILL || true
+ oldsig KILL || true
+ invoke unicorn start || exit $?
+ fi
+ fi
+}
+
+if [ -x /etc/init.d/unicorn ]; then
+ if running unicorn; then
+ upgrade
+ else
+ invoke unicorn start || exit $?
+ fi
+fi
+
#DEBHELPER#
-case "$1" in
- configure*)
- if [ -z "$2" -a -x "$(which update-rc.d)" ]; then
- ## sysv: override auto-enable on first install.
- ## Causes Lintian error: "duplicate-updaterc.d-calls-in-postinst".
- update-rc.d unicorn disable >>/dev/null || true
- fi
- ;;
-esac
+exit 0
diff --git a/debian/unicorn.prerm b/debian/unicorn.prerm
new file mode 100644
index 0000000..ffa9a92
--- /dev/null
+++ b/debian/unicorn.prerm
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ remove|deconfigure)
+ if [ -x /etc/init.d/unicorn ]; then
+ if [ -x "$(which invoke-rc.d)" ]; then
+ invoke-rc.d unicorn stop
+ else
+ /etc/init.d/unicorn stop
+ fi
+ fi
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/unicorn.git
More information about the Pkg-ruby-extras-commits
mailing list