]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - debian/init.d
Change the module location of the apt OpProgress class (Closes: #641732)
[quix0rs-apt-p2p.git] / debian / init.d
index 2faf531e9de4e09a03d968337b5f4c245a2854bd..97bb1775cb04fa746d21eda08c6355b79091f7a2 100755 (executable)
@@ -2,8 +2,8 @@
 
 ### BEGIN INIT INFO
 # Provides:          apt-p2p
-# Required-Start:    $network
-# Required-Stop:
+# Required-Start:    $remote_fs $network
+# Required-Stop:     $remote_fs
 # Should-Start:      $named
 # Should-Stop:
 # Default-Start:     2 3 4 5
@@ -24,14 +24,23 @@ pidfile=$rundir/apt-p2p.pid
 logfile=/var/log/apt-p2p.log
 application=/usr/sbin/apt-p2p
 twistd=/usr/bin/twistd
-user=aptp2p
+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)