| Server IP : 64.223.137.62 / Your IP : 104.23.197.97 Web 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 MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/lib/dpkg/info/ |
Upload File : |
#!/bin/bash
DATTOBD="synosnap"
main()
{
action="$1"
case "${action}" in
configure)
action_configure $@
;;
abort-upgrade)
action_abort_upgrade $@
;;
abort-remove)
action_abort_remove $@
;;
abort-deconfigure)
action_abort_deconfigure $@
;;
*)
echo "preinst called with unknown argument '$1'" >&2
exit 1
;;
esac
return $?
}
TEXT_COLOR='\033[0;31m' #Red
BG_COLOR='\033[43m' # Yellow background
NC='\033[0m' # No Color
function echo_highlight() {
echo -e "${TEXT_COLOR}${BG_COLOR}$1${NC}"
}
update_initrd()
{
dkms_output=$(dkms status | grep synosnap | grep install)
kernel_versions=()
while IFS=',/' read -r -a line_array; do
kernel_version=$(echo "${line_array[2]}" | tr -d '[:space:]')
kernel_versions+=("$kernel_version")
done <<< "$dkms_output"
echo "Found synosnap installed by dkms in the following kernel versions: ${kernel_versions[@]}"
echo "Start updating initrd and backup old initrd for these kernel versions..."
for kernel_version in "${kernel_versions[@]}"; do
# Find out what the proper filename for initrd
# if not found the proper initrd name, intrd will be empty string
for initrd in "initrd.img-$kernel_version" "initramfs-$kernel_version.img" "initrd-$kernel_version.img" "initrd-$kernel_version" ''; do
[[ $initrd && -f /boot/$initrd ]] && break
done
if ! [[ $initrd ]]; then
# Return if we cannot find an initrd.
echo_highlight "Warning: Unable to find an initial ram disk that we know how to handle." \
"Will not try to make an initrd, plesae do it manually."
return 1
fi
# get the size (MB) of the initrd
initrd_size=$(du -m /boot/$initrd | cut -f1)
# backup old initrd
echo "Backing up /boot/$initrd to /boot/$initrd.old-syno"
cp -fv "/boot/$initrd" "/boot/$initrd.old-syno"
if [ $? -ne 0 ]; then
echo_highlight "Failed to backup /boot/$initrd to /boot/$initrd.old-syno"
echo_highlight "One possible cause is insufficient free space on the /boot volume (at least $initrd_size MB required)."
return 1
fi
echo "Making new /boot/$initrd"
echo "If next boot fails, revert to /boot/$initrd.old-syno image"
if type "update-initramfs" &> /dev/null; then
echo "Configuring update-initramfs, please wait..."
update-initramfs -u -k $kernel_version
elif type "mkinitrd" &> /dev/null; then
echo "Configuring initrd, please wait..."
mkinitrd -f /boot/$initrd $kernel_version
fi
if [ $? -ne 0 ]; then
echo_highlight "Failed to update /boot/$initrd"
echo_highlight "One possible cause is insufficient free space on the /boot volume (at least $initrd_size MB required)."
return 1
fi
done
return 0
}
migrate_data()
{
exist=$(ls /opt/Synology/ActiveBackupforBusiness/data/snapshot-history-db.sqlite 2>/dev/null || true)
if [[ -n "$exist" ]];then
mv /opt/Synology/ActiveBackupforBusiness/data/snapshot-history-db.sqlite /opt/synosnap/snapshot-history-db.sqlite
fi
}
action_configure()
{
dattobd_version="$(dpkg-query --show --showformat='${Version}' synosnap)"
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
DISTROVER=$VERSION_ID
if [ "$DISTRO" = "debian" ] && dpkg --compare-versions "$DISTROVER" ge "12"; then
echo "* Debian 12+ detected, disable DKMS autoinstall"
# ABB #11026 remove AUTOINSTALL="yes" from dkms.conf
sed -i '/AUTOINSTALL="yes"/d' /usr/src/${DATTOBD}-${dattobd_version}/dkms.conf
fi
fi
# check env varirable SYNO_AGENT_INSTALL_FOLDER is set or not
if [ -z "$SYNO_AGENT_INSTALL_FOLDER" ]; then
echo_highlight "SYNO_AGENT_INSTALL_FOLDER is not set"
exit 1
fi
if [ -f "$SYNO_AGENT_INSTALL_FOLDER/dkms_common.postinst" ]; then
$SYNO_AGENT_INSTALL_FOLDER/dkms_common.postinst ${DATTOBD} ${dattobd_version}
else
echo_highlight "unexpected error: dkms_common.postinst is not found"
exit 1
fi
dkms status | grep synosnap | grep install
if [ "$?" -ne "0" ];then
echo "DRIVER_INSTALL_RESULT=1" > /opt/synosnap/result
exit 1
fi
# for reload boot script
update_initrd
if [ "$?" -ne "0" ];then
echo "DRIVER_INSTALL_RESULT=1" > /opt/synosnap/result
exit 1
fi
echo "DRIVER_INSTALL_RESULT=0" > /opt/synosnap/result
if [ -f /opt/synosnap/enroll ];then
. /opt/synosnap/enroll
fi
if [ "$ENROLL" == "1" ];then
echo_highlight "****"
echo_highlight "secure boot is enabled"
echo_highlight "please use sudo mokutil --import /opt/synosnap/MOK.der to enroll new key"
echo_highlight "after enrolled the new key, reboot your device"
echo_highlight "****"
else
modprobe ${DATTOBD}
fi
migrate_data
return 0
}
action_abort_upgrade()
{
new_version="$2"
return 0
}
action_abort_remove()
{
in_favour_package_name="$3"
new_version="$4"
return 0
}
action_abort_deconfigure()
{
in_favour_package_name="$3"
in_favour_package_version="$4"
conflicting_package_name="$6"
conflicting_package_version="$7"
return 0
}
main $@
exit $?