Heray-Was-Here
Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver9 5.15.0-170-generic #180-Ubuntu SMP Fri Jan 9 16:10:31 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.24
Disable Function : NONE
Directory :  /var/lib/dpkg/info/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/lib/dpkg/info/synosnap.preinst
#!/bin/bash

DATTOBD="synosnap"
DATTOBD_MODULE="synosnap"

main()
{
	action="$1"
	case "${action}" in
		install)
			action_install $@
		;;
		upgrade)
			action_upgrade $@
		;;
		abort-upgrade)
		;;
		*)
			echo "preinst called with unknown argument '$1'" >&2
			exit 1
		;;
	esac

	return $?
}

action_install()
{
	return 0
}

check_need_rmmod()
{
	. "${SYNO_AGENT_INSTALL_FOLDER}/variables.sh"
	old_version="$1"
	new_version="${DATTOBD_VERSION}"
	echo "upgrade from ${old_version} to ${new_version}"

	# In some scenarios, user can still use the old version until reboot
	# so we will not rmmod the driver, but we prepare the new version driver
	# after reboot, user will use the new version driver
	# -----
	# 0.11.5 -> 0.11.6 -> fix kernel >= 6.4 some diskreboot cant cbt, 
	# this bug only affect after reboot process, no need to rmmod
	# -----
	no_need_rmmod_versions=(
		"0.11.5 0.11.6" 
	)

	for pair in "${no_need_rmmod_versions[@]}"; do
		if [[ "$pair" == "$old_version $new_version" ]]; then
			echo "$old_version upgrade to $new_version, no need to rmmod, keep CBT"
			return 0
		fi
	done

	return 1
}

action_upgrade()
{
	old_version="$2"

	check_need_rmmod ${old_version}

	if [ $? -ne 0 ]; then
		rmmod ${DATTOBD_MODULE}
	fi
	
	dkms remove ${DATTOBD}/${old_version} --all

	return 0
}

main $@
exit $?



Hry