#!/bin/sh
set -eu
case "${1:-}" in remove|purge)
 if [ -d /run/systemd/system ];then systemctl daemon-reload;fi
 ;;
esac
if [ "${1:-}" = purge ];then
 rm -rf -- /var/lib/screen2screen-linux-host /etc/screen2screen-linux-host
 # Only remove matching shared settings if no other package owns them.
 for path in /etc/apt/keyrings/screen2screen-archive-keyring.asc /etc/apt/sources.list.d/screen2screen.sources;do
  if [ -f "$path" ] && [ ! -L "$path" ] && ! dpkg-query -S "$path" >/dev/null 2>&1;then
   case "$path" in *.asc) expected=9b55636a3a4b22b90dcb4bf696828ffc480e633ea729860d18264cb0d8a38780;; *) expected=edc5a45ef5ef4a9bfe82d91b47d13a99c05261c773b26bde4401063a58171e60;;esac
   actual=$(sha256sum "$path");actual=${actual%% *}
   if [ "$actual" = "$expected" ];then rm -f -- "$path";fi
  fi
 done
fi
