X-Git-Url: https://git.mxchange.org/?p=quix0rs-apt-p2p.git;a=blobdiff_plain;f=debian%2Finit.d;fp=debian%2Finit.d;h=97bb1775cb04fa746d21eda08c6355b79091f7a2;hp=fd986e462e6fca6ceda2f68cab8cf86cb8dfba72;hb=8a9842922243fa0a31d7c92d157b4ffc5c275dc8;hpb=1681d035e6c4adced1d8c34900bed7f86f86b0a4 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)