#!/bin/bash set -e ours=.wb theirs=.wb-orig # Remove diversion of sshd_configs from wb-configs which # was accidently left unattended # These functions are taken from config-package-dev heplers # with modifications which allow to remove diversions from # other packages wb_undisplace_unlink_symlink() { file="$1" ourfile="$2" theirfile="$3" if [ ! -L "$file" ] || \ [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \ "$(readlink "$file")" != "$(basename "$theirfile")" ]; then echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2 else rm -f "$file" fi } wb_undisplace_unlink_displace() { file="$1" if [ ! -L "$file" ] && [ ! -e "$file" ]; then echo "Run dpkg-divert --remove..." dpkg-divert --remove --rename "$file" else echo "Not removing diversion of $file by $package" >&2 fi } wb_undisplace_unlink() { prefix=$1 suffix=$2 file=$prefix$suffix ourfile=$prefix$ours$suffix theirfile=$prefix$theirs$suffix wb_undisplace_unlink_symlink "$file" "$ourfile" "$theirfile" wb_undisplace_unlink_displace "$file" } wb_check_undisplace_unlink_from() { prefix=$1 suffix=$2 from_package=$3 from_version=$4 file=$prefix$suffix ourfile=$prefix$ours$suffix theirfile=$prefix$theirs$suffix if LC_ALL=C dpkg-divert --list "$from_package" | \ grep -xFq "diversion of $file to $theirfile by $from_package"; then echo "Picking up diversion of $file from $package to replace it with our one" wb_undisplace_unlink "$prefix" "$suffix" "$from_package" fi } if [ "$1" = "upgrade" ] && dpkg --compare-versions "$2" "lt" "1.75.4"; then wb_check_undisplace_unlink_from /etc/ssh/sshd_config "" wb-configs "1.75.4" fi # if wb-configs is upgraded with newer mosquitto, schedule service restarts # (will be handled in postinst) if [ "$1" = "upgrade" ] && dpkg --compare-versions "$2" "lt" "3.0.0~~"; then echo "Scheduling services restart because of mosquitto upgrade" touch /var/lib/wirenboard/.mosquitto2-upgrade-restart-required fi deb-systemd-invoke stop watchdog # divert /usr/bin/mosquitto_pub, /usr/bin/mosquitto_sub to use our wrapper scripts # the same section is in postrm script mosquitto_apps=("mosquitto_sub" "mosquitto_pub" "mosquitto_rr") for file in "${mosquitto_apps[@]}"; do if [[ ! -e "/usr/bin/${file}.mosq" ]]; then dpkg-divert --package wb-configs --divert "/usr/bin/${file}.mosq" --rename "/usr/bin/${file}" fi done # Automatically added by dh_installdeb/13.3.4 dpkg-maintscript-helper rm_conffile /etc/kernel/postinst.d/zImage-uboot -- "$@" dpkg-maintscript-helper rm_conffile /etc/init.d/wb-configs 1.76\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/apt/sources.list.d/contactless.list 1.76\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/apt/sources.list.d/wheezy-backports.list 1.76\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/apt/sources.list.d/nodesource.list 3.30.1\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/apt/preferences 1.78\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/preferences 1.78\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/mosquitto/conf.d/auth.conf 3.0.0\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/mosquitto/conf.d/listeners.conf 3.0.0\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/mosquitto/conf.d/bridge.conf 3.0.0\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/mosquitto/conf.d/bridge.conf.example 3.0.0\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/mosquitto/conf.d/30limits.conf 3.22.0\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/ssl/openssl.cnf 3.22.1\~ -- "$@" # End automatically added section