Replacing test for stop links in sysvinit script with ls to match on wildcards.
authorDaniel Baumann <daniel@debian.org>
Fri, 17 Aug 2012 11:26:18 +0000 (13:26 +0200)
committerDaniel Baumann <daniel@debian.org>
Fri, 17 Aug 2012 12:12:53 +0000 (14:12 +0200)
scripts/debconfig/0030-sysvinit

index b78fcd6..2e29ca5 100755 (executable)
@@ -147,40 +147,46 @@ case "${_LXC_ENABLE}" in
                                continue
                        fi
 
+                       _ALREADY_DISABLED="false"
+
                        # service is already disabled
                        for _RUNLEVEL in /etc/rc*.d
                        do
-                               if [ ! -e "${_RUNLEVEL}/K*${_SERVICE}" ]
+                               if ! ls ${_RUNLEVEL}/K*${_SERVICE} > /dev/null 2>&1
                                then
                                        # disabled services have stop links in all runlevels
                                        # if at least one runlevel does not have a stop link,
                                        # then the service was not disabled and we need to continue
                                        # with disabling the service later on
+                                       _ALREADY_DISABLED="false"
                                        break
                                fi
 
                                # service is indeed already disabled
-                               continue
+                               _ALREADY_DISABLED="true"
                        done
 
-                       if ls /etc/rc*.d/K*${_SERVICE} > /dev/null 2>&1 && \
-                          ! ls /etc/rc*.d/S*${_SERVICE} > /dev/null 2>&1
+                       if [ "${_ALREADY_DISABLED}" = "false" ]
                        then
-                               # service has only stop links
-                               # therefore, using 'update-rc.d disable' does not work,
-                               # and using 'update-rc.d remove' is not upgrade safe
-                               # (on upgrades, the stop links would be re-added).
-                               for _SYMLINK in /etc/rc*.d/K*${_SERVICE}
-                               do
-                                       rm -f ${_SYMLINK}
-                                       ln -s /bin/live-initscripts-empty-stop ${_SYMLINK}
-                               done
-                       fi
+                               if ls /etc/rc*.d/K*${_SERVICE} > /dev/null 2>&1 && \
+                                  ! ls /etc/rc*.d/S*${_SERVICE} > /dev/null 2>&1
+                               then
+                                       # service has only stop links
+                                       # therefore, using 'update-rc.d disable' does not work,
+                                       # and using 'update-rc.d remove' is not upgrade safe
+                                       # (on upgrades, the stop links would be re-added).
+                                       for _SYMLINK in /etc/rc*.d/K*${_SERVICE}
+                                       do
+                                               rm -f ${_SYMLINK}
+                                               ln -s /bin/live-initscripts-empty-stop ${_SYMLINK}
+                                       done
+                               fi
 
-                       # service is a normal service with both start and stop links
-                       update-rc.d -f ${_SERVICE} disable 2>&1 | \
-                       grep -v "update-rc.d: using dependency based boot sequencing" | \
-                       grep -v "update-rc.d: error: cannot find a LSB script for mountroot" || true
+                               # service is a normal service with both start and stop links
+                               update-rc.d -f ${_SERVICE} disable 2>&1 | \
+                               grep -v "update-rc.d: using dependency based boot sequencing" | \
+                               grep -v "update-rc.d: error: cannot find a LSB script for mountroot" || true
+                       fi
                done
                ;;