From f9e6871131e2956644475aefb126059f4e235892 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 24 Oct 2008 07:10:25 -0400 Subject: [PATCH] factor out common initscript code svn path=/trunk/packages/sipb-xen-base/; revision=1211 --- debian/changelog | 6 ++++++ files/lib/init/config-init.sh | 33 +++++++++++++++++++++++++++++++++ files/lib/init/gen-files.sh | 9 +++++++++ 3 files changed, 48 insertions(+) create mode 100644 files/lib/init/config-init.sh create mode 100644 files/lib/init/gen-files.sh diff --git a/debian/changelog b/debian/changelog index 11de8fc..4fc4f5b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +sipb-xen-base (8.25) unstable; urgency=low + + * Factor out common initscript code, provide it here + + -- Greg Price Fri, 24 Oct 2008 07:06:59 -0400 + sipb-xen-base (8.24) unstable; urgency=low * Switch to using a setup.py file with CDBS's Python support diff --git a/files/lib/init/config-init.sh b/files/lib/init/config-init.sh new file mode 100644 index 0000000..1268a1b --- /dev/null +++ b/files/lib/init/config-init.sh @@ -0,0 +1,33 @@ +# For a package which only configures another, "parent" package. +# +# Global variable PARENTPACKAGE names parent; may be array +# for zero or many parents. +# +# Global variable PACKAGE names this package, for log message. +# +# Requires bash. + +. /lib/init/vars.sh +. /lib/lsb/init-functions +. /lib/init/gen-files.sh + +config_init () { + case "$1" in + start|reload|force-reload|restart) + log_begin_msg "Reloading config for $PACKAGE" + gen_files + log_end_msg $? + for p in "${PARENTPACKAGE[@]}"; do + /etc/init.d/"$p" "$1" + done + ;; + stop) + for p in "${PARENTPACKAGE[@]}"; do + /etc/init.d/"$p" "$1" + done + ;; + *) + log_success_msg "Usage: /etc/init.d/$PACKAGE {start|reload|force-reload|restart|stop}" + ;; + esac +} diff --git a/files/lib/init/gen-files.sh b/files/lib/init/gen-files.sh new file mode 100644 index 0000000..61d0016 --- /dev/null +++ b/files/lib/init/gen-files.sh @@ -0,0 +1,9 @@ +# Generates files from templates. +# Files should be named in an array variable GEN_FILES. + +gen_files() +{ + for f in "${GEN_FILES[@]}"; do + mako-render $f.mako >$f + done +} -- 1.7.9.5