[PATCH] base-files: sysupgrade: store status of system-services

Paul Spooren mail at aparcar.org
Sat Jan 9 14:46:26 EST 2021



On So, Jan 3, 2021 at 23:14, Sven Roederer <devel-sven at geroedel.de> 
wrote:
> When saving the list of installed pkgs, also store the status of the
> system services. The list is created in the etc/backup folder also
> and formated as:
> 
> /etc/init.d/<service> {enable|disable}
> 
> This way it can be sourced after sysupgrade, to restore the previous
> state.
> 
> Signed-off-by: Sven Roederer <devel-sven at geroedel.de>
> ---
> 
> Currently all services get enabled during image creation. This can 
> cause
> issues after upgrade with services explicitly disabled by the user.
> With this created list sourced by a simple uci-defaults script the 
> state
> can be restored automatically.
> Not including such a uci-defaults script by default, as currently the
> stored package list is also not reinstalled.
> 
> 
>  package/base-files/Makefile              |  2 +-
>  package/base-files/files/sbin/sysupgrade | 11 +++++++++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/package/base-files/Makefile b/package/base-files/Makefile
> index 0c612b73ca..fbcb694592 100644
> --- a/package/base-files/Makefile
> +++ b/package/base-files/Makefile
> @@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
>  include $(INCLUDE_DIR)/feeds.mk
> 
>  PKG_NAME:=base-files
> -PKG_RELEASE:=239
> +PKG_RELEASE:=240
>  PKG_FLAGS:=nonshared
> 
>  PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ 
> $(GENERIC_PLATFORM_DIR)/base-files/
> diff --git a/package/base-files/files/sbin/sysupgrade 
> b/package/base-files/files/sbin/sysupgrade
> index 79927a2b5c..cadce36172 100755
> --- a/package/base-files/files/sbin/sysupgrade
> +++ b/package/base-files/files/sbin/sysupgrade
> @@ -57,6 +57,7 @@ export CONFFILES=/tmp/sysupgrade.conffiles
>  export CONF_TAR=/tmp/sysupgrade.tgz
>  export ETCBACKUP_DIR=/etc/backup
>  export INSTALLED_PACKAGES=${ETCBACKUP_DIR}/installed_packages.txt
> +export SERVICE_STATUS=${ETCBACKUP_DIR}/service_status.txt
> 
>  IMAGE="$1"
> 
> @@ -228,6 +229,7 @@ do_save_conffiles() {
> 
>  	if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
>  		echo "${INSTALLED_PACKAGES}" >> "$CONFFILES"
> +		echo "${SERVICE_STATUS}" >> "$CONFFILES"
>  		mkdir -p "$ETCBACKUP_DIR"
>  		# Avoid touching filesystem on each backup
>  		RAMFS="$(mktemp -d -t sysupgrade.XXXXXX)"
> @@ -245,6 +247,15 @@ do_save_conffiles() {
>  			\( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) 
> -o \
>  			\( -exec echo {} unknown \; \) \
>  			\) | sed -e 's,.*/,,;s/\.control /\t/' > ${INSTALLED_PACKAGES}
> +
> +		# Format: /etc/init.d/servicename {enable,disable}
> +		rm -f ${SERVICE_STATUS}
> +		for service in /etc/init.d/* ; do \
> +			${service} enabled && \
> +				echo >> ${SERVICE_STATUS} "$service" "enable" || \
> +				echo >> ${SERVICE_STATUS} "$service" "disable" \
> +			; \
> +		done
>  	fi
> 
>  	v "Saving config files..."
> --
> 2.20.1
> 

I like the idea of this patch but would agree with Stijn that it should 
be it's own parameter.

@Reiner could you collaborate with your oot solution? This feature 
seems like something that should exists per default, not requiring 
everyone to come up with an individual implementation.

@Daniel that's convenient for custom images but by default I may just 
want to upgrade with an upstream image. Even a custom image like 
generated by ASU doesn't support service settings.







More information about the openwrt-devel mailing list