HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: //etc.defaults/init/auto-smallupdate.conf
description	"auto smallupdate when upgrade bootup"

start on stopped dsm-services and stopped synopkgctl-launcher

task
console log
emits syno.autosmallupdate.done

script
	if [ ! -f /var/.UpgradeBootup ] || [ -f /var/.AutoSmallupdateBootup ]; then
		initctl emit --no-wait syno.autosmallupdate.done || true
		exit 0
	fi

	if ! synoupgrade --support-auto-smallupdate; then
		initctl emit --no-wait syno.autosmallupdate.done || true
		exit 0
	fi

	if [ -f /var/.SkipAutoSmallupdate ]; then
		echo "Skip auto smallupdate"
		rm -f /var/.SkipAutoSmallupdate
		initctl emit --no-wait syno.autosmallupdate.done || true
		exit 0
	fi

	SMALL_PATCH="/.smallupdate.pat"

	echo "start bootup smallupdate"
	/bin/touch /var/.AutoSmallupdateBootup || true

	if [ -f $SMALL_PATCH ]; then
		/usr/syno/sbin/synoupgrade --bootup-smallupdate=$SMALL_PATCH || true
	elif /usr/syno/sbin/synoupgrade --check-smallupdate; then
		/usr/syno/sbin/synoupgrade --bootup-smallupdate || true
	fi

	echo "end bootup smallupdate"
	# block bootup if need reboot timeout
	if [ ! -f /tmp/.bootup_smallupdate_wait_reboot ]; then
		/sbin/initctl emit --no-wait syno.autosmallupdate.done || true
	else
		echo "wait smallupdate reboot"
		# go through when timeout
		sleep 240 || true
		echo "wait reboot over 240s timeout!"
		/sbin/initctl emit --no-wait syno.autosmallupdate.done || true
	fi
end script
# vim:ft=upstart