From 8a9842922243fa0a31d7c92d157b4ffc5c275dc8 Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Sun, 21 Mar 2010 00:19:55 -0700 Subject: [PATCH] Add an enable variable to the /etc/default file (Closes: #518594) --- debian/changelog | 3 ++- debian/default | 3 +++ debian/init.d | 35 ++++++++++++++++++++++++----------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index 688617b..0987ab5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,9 @@ apt-p2p (0.1.6) unstable; urgency=low - Update standards version to 3.8.4 (no changes) * Fix various documentation issues (Closes: #518590, #518549, #518548, 518550) + * Add an enable variable to the /etc/default file (Closes: #518594) - -- Cameron Dale Sat, 20 Mar 2010 23:26:24 -0700 + -- Cameron Dale Sun, 21 Mar 2010 00:15:20 -0700 apt-p2p (0.1.5) unstable; urgency=low diff --git a/debian/default b/debian/default index 08f503f..d0a380b 100644 --- a/debian/default +++ b/debian/default @@ -1,5 +1,8 @@ # apt-p2p configuration +## Whether to start apt-p2p or not, must be either 'true' or 'false' +#enable=true + ## Filename to store pid of process #pidfile=/var/run/apt-p2p/apt-p2p.pid diff --git a/debian/init.d b/debian/init.d index fd986e4..97bb177 100755 --- a/debian/init.d +++ b/debian/init.d @@ -26,12 +26,21 @@ application=/usr/sbin/apt-p2p twistd=/usr/bin/twistd user=apt-p2p group=nogroup +enable=true [ -r /etc/default/apt-p2p ] && . /etc/default/apt-p2p test -x $twistd || exit 0 test -r $application || exit 0 +case "x$enable" in + xtrue|xfalse) ;; + *) echo -n "Value of 'enable' in /etc/default/apt-p2p must be either 'true' or 'false'; " + echo "not starting apt-p2p daemon." + exit 1 + ;; +esac + # return true if at least one pid is alive alive() { @@ -50,17 +59,21 @@ alive() case "$1" in start) - echo -n "Starting apt-p2p" - [ ! -d $rundir ] && mkdir $rundir - [ ! -f $logfile ] && touch $logfile - chown $user $rundir $logfile - [ -f $pidfile ] && chown $user $pidfile - # Make cache files readable - umask 022 - start-stop-daemon --start --quiet --exec $twistd -- \ - --pidfile=$pidfile --rundir=$rundir --python=$application \ - --logfile=$logfile --no_save - echo "." + if "$enable"; then + echo -n "Starting apt-p2p" + [ ! -d $rundir ] && mkdir $rundir + [ ! -f $logfile ] && touch $logfile + chown $user $rundir $logfile + [ -f $pidfile ] && chown $user $pidfile + # Make cache files readable + umask 022 + start-stop-daemon --start --quiet --exec $twistd -- \ + --pidfile=$pidfile --rundir=$rundir --python=$application \ + --logfile=$logfile --no_save + echo "." + else + echo "apt-p2p daemon not enabled in /etc/default/apt-p2p, not starting..." + fi ;; stop) -- 2.30.2