]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Add an enable variable to the /etc/default file (Closes: #518594)
authorCameron Dale <camrdale@gmail.com>
Sun, 21 Mar 2010 07:19:55 +0000 (00:19 -0700)
committerCameron Dale <camrdale@gmail.com>
Sun, 21 Mar 2010 07:19:55 +0000 (00:19 -0700)
debian/changelog
debian/default
debian/init.d

index 688617b99e5978da893e34c6ded0444717b203e5..0987ab53cd227ad325a16f47a2354fc2d12f4d94 100644 (file)
@@ -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 <camrdale@gmail.com>  Sat, 20 Mar 2010 23:26:24 -0700
+ -- Cameron Dale <camrdale@gmail.com>  Sun, 21 Mar 2010 00:15:20 -0700
 
 apt-p2p (0.1.5) unstable; urgency=low
 
index 08f503f98bcc08c1d5374534a32b205ca75c9a9f..d0a380b30d05060619dcd4023d991927d293f0fc 100644 (file)
@@ -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 
 
index fd986e462e6fca6ceda2f68cab8cf86cb8dfba72..97bb1775cb04fa746d21eda08c6355b79091f7a2 100755 (executable)
@@ -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)