From 7aa41d7b67c0d03f849a4deede46811309d72efb Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Mon, 30 Mar 2026 10:19:22 +0200 Subject: [PATCH] Copy debian install scripts --- .../mullvad-vpn-daemon.post-deinstall | 39 +++++++++++++++++++ .../mullvad-vpn-daemon.post-install | 8 ++++ .../mullvad-vpn-daemon.pre-deinstall | 23 +++++++++++ .../mullvad-vpn-daemon.pre-install | 16 ++++++++ 4 files changed, 86 insertions(+) create mode 100644 mullvad-vpn-daemon/mullvad-vpn-daemon.post-deinstall create mode 100644 mullvad-vpn-daemon/mullvad-vpn-daemon.post-install create mode 100644 mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall create mode 100644 mullvad-vpn-daemon/mullvad-vpn-daemon.pre-install diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.post-deinstall b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-deinstall new file mode 100644 index 0000000..64f821d --- /dev/null +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-deinstall @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -eu + +function remove_logs_and_cache { + rm -r --interactive=never /var/log/mullvad-vpn/ || \ + echo "Failed to remove mullvad-vpn logs" + rm -r --interactive=never /var/cache/mullvad-vpn/ || \ + echo "Failed to remove mullvad-vpn cache" +} + +function remove_config { + rm -r --interactive=never /etc/mullvad-vpn || \ + echo "Failed to remove mullvad-vpn config" +} + +function remove_symlinks { + rm /usr/bin/mullvad-problem-report || \ + echo "Failed to remove mullvad-problem-report" +} + +# checking what kind of an action is taking place +case $@ in + # apt purge passes "purge" + "purge") + remove_logs_and_cache + remove_config + remove_symlinks + ;; + # apt remove passes "remove" + "remove") + remove_symlinks + ;; + # dnf remove passes a 0 + "0") + remove_logs_and_cache + remove_config + remove_symlinks + ;; +esac diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.post-install b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-install new file mode 100644 index 0000000..f1952a9 --- /dev/null +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-install @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -eu + +ln -sf /opt/Mullvad\ VPN/resources/mullvad-problem-report /usr/bin/mullvad-problem-report + +systemctl enable "/usr/lib/systemd/system/mullvad-daemon.service" +systemctl start mullvad-daemon.service || echo "Failed to start mullvad-daemon.service" +systemctl enable "/usr/lib/systemd/system/mullvad-early-boot-blocking.service" diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall new file mode 100644 index 0000000..f164013 --- /dev/null +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -eu + +echo "Running prerm." +is_number_re='^[0-9]+$' +# Check if we're running during an upgrade step on Fedora +# https://fedoraproject.org/wiki/Packaging:Scriptlets#Syntax +if [[ "$1" =~ $is_number_re ]] && [ "$1" -gt 0 ]; then + exit 0; +fi + +if [[ "$1" == "upgrade" ]]; then + exit 0; +fi + +# the user might've disabled or stopped the service themselves already +systemctl stop mullvad-daemon.service || true +systemctl disable mullvad-daemon.service || true +systemctl stop mullvad-early-boot-blocking.service || true +systemctl disable mullvad-early-boot-blocking.service || true + +/opt/Mullvad\ VPN/resources/mullvad-setup reset-firewall || echo "Failed to reset firewall" +/opt/Mullvad\ VPN/resources/mullvad-setup remove-device || echo "Failed to remove device from account" diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-install b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-install new file mode 100644 index 0000000..7d380d3 --- /dev/null +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-install @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -eu + +if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then + if systemctl status mullvad-daemon &> /dev/null; then + /opt/Mullvad\ VPN/resources/mullvad-setup prepare-restart || true + systemctl stop mullvad-daemon.service + systemctl disable mullvad-daemon.service + systemctl disable mullvad-early-boot-blocking.service || true + cp /var/log/mullvad-vpn/daemon.log /var/log/mullvad-vpn/old-install-daemon.log \ + || echo "Failed to copy old daemon log" + fi +fi + +rm -f /var/cache/mullvad-vpn/relays.json +rm -f /var/cache/mullvad-vpn/api-ip-address.txt