[PATCH] base-files: sysupgrade: include uci-defaults script disabling services

Paul D newtwen at gmail.com
Wed Feb 14 12:50:04 PST 2024


(Not directly commenting on this change set)

Would services not do better to be tracked within uci and its config 
files in /etc/config?

Or do changes to those files there risk triggering other procd actions 
to the services they dictate?



On 2024-02-14 16:05, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal at milecki.pl>
> 
> 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 at gmail.com>
> Cc: Jo-Philipp Wich <jo at mein.io>
> Cc: Jonas Gorski <jonas.gorski at gmail.com>
> Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
> ---
>   package/base-files/files/sbin/sysupgrade | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
> index 1e09f65e07..b1ada062ed 100755
> --- a/package/base-files/files/sbin/sysupgrade
> +++ b/package/base-files/files/sbin/sysupgrade
> @@ -273,6 +273,16 @@ create_backup_archive() {
>   			\) | 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..."
>   	sed -i 's/^\///' "$CONFFILES" # Drop leading slashes
>   	[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""




More information about the openwrt-devel mailing list