base-files: sysupgrade: include uci-defaults script disabling services
authorRafał Miłecki <rafal@milecki.pl>
Wed, 14 Feb 2024 15:05:19 +0000 (16:05 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Mon, 19 Feb 2024 12:53:14 +0000 (13:53 +0100)
Disabled services should be kept disabled after sysupgrade. This can be
easily handled using a proper uci-defaults script.

Extend sysupgrade to check for disabled services, generate uci-defaults
script disabling them and include it in backup.

Cc: Christian Marangi <ansuelsmth@gmail.com>
Cc: Jo-Philipp Wich <jo@mein.io>
Cc: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Jo-Philipp Wich <jo@mein.io>
package/base-files/files/sbin/sysupgrade

index 66bdf95de01735c16256ce0ff71ac49140e5bb84..4bac1041d9665ace4a6ab84d734941bf6f168e81 100755 (executable)
@@ -260,6 +260,16 @@ do_save_conffiles() {
                        \) | sed -e 's,.*/,,;s/\.control /\t/' > "$dir/${INSTALLED_PACKAGES}"
        fi
 
+       mkdir -p $dir/etc/uci-defaults/
+       touch $dir/etc/uci-defaults/10_disable_services
+       for service in /etc/init.d/*; do
+               if ! $service enabled; then
+                       echo "$service disable" >> $dir/etc/uci-defaults/10_disable_services
+               fi
+       done
+       echo "exit 0" >> $dir/etc/uci-defaults/10_disable_services
+       echo "/etc/uci-defaults/10_disable_services" >> "$CONFFILES"
+
        v "Saving config files..."
        [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
        sed -i -e 's,^/,,' "$CONFFILES"