| Server IP : 64.223.137.62 / Your IP : 104.23.243.124 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
# Copyright (c) 2017 Synology Inc. All rights reserved.
# prerm script for synology-active-backup-for-business package
DATTOBD="synosnap"
DATTOBD_MODULE="synosnap"
APP_NAME="synosnap"
main()
{
action="$1"
case "${action}" in
remove)
action_remove $@
;;
upgrade)
action_upgrade $@
;;
deconfigure)
action_deconfigure $@
;;
failed-upgrade)
action_failed_upgrade $@
;;
*)
echo "prerm called with unknown arguemnts '$1'" >&2
return 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()
{
# 1. remove modprobe synosnap & reload script in initrd for all kernels that installed synosnap
# 2. try to remove backup initrd for all kernels that installed synosnap
dkms_output=$(dkms status | grep synosnap | grep install)
if [ -z "$dkms_output" ]; then
echo "No synosnap modules installed in dkms."
return 0
fi
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 try to remove backup initrd for these kernel versions..."
# if not found the proper initrd name, intrd will be empty string
for kernel_version in "${kernel_versions[@]}"; do
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
continue
fi
# get the size (MB) of the initrd
initrd_size=$(du -m /boot/$initrd | cut -f1)
if type "update-initramfs" &> /dev/null; then
echo "Configuring update-initramfs for $kernel_version, please wait..."
update-initramfs -u -k $kernel_version
elif type "mkinitrd" &> /dev/null; then
echo "Configuring initrd for $kernel_version, 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)."
echo_highlight "Please manually update the initrd for the kernel- $kernel_version later."
fi
backup_initrd="/boot/$initrd.old-syno"
if [[ -f $backup_initrd ]]; then
echo "Removing old backup initrd $backup_initrd"
rm -fv $backup_initrd
fi
done
return 0
}
action_remove()
{
in_favour_package_name="$3"
new_version="$4"
dattobd_version="$(dpkg-query --show --showformat='${Version}' synosnap)"
rmmod ${DATTOBD_MODULE}
rm -rf /etc/synosnap/
rm -fv /usr/share/initramfs-tools/hooks/synosnap
rm -fv /usr/share/initramfs-tools/scripts/init-premount/synosnap
rm -fv /lib/systemd/system-shutdown/synosnap.shutdown
update_initrd
dkms remove ${DATTOBD}/${dattobd_version} --all
return 0
}
action_upgrade()
{
new_version="$2"
installed_version=$(dpkg-query --show --showformat='${Version}' ${APP_NAME})
dpkg --compare-versions "${new_version}" "ge" "${installed_version}"
if [ $? -ne 0 ]; then
echo "installed ${APP_NAME} version is newer or equal"
return 1
fi
return 0
}
action_deconfigure()
{
in_favour_package_name="$3"
in_favour_package_version="$4"
conflicting_package_name="$6"
conflicting_package_version="$7"
return 0
}
action_failed_upgrade()
{
old_version="$2"
return 0
}
main $@
exit $?