diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon-systemd.post-install b/mullvad-vpn-daemon/mullvad-vpn-daemon-systemd.post-install index 980d1e5..832a4db 100644 --- a/mullvad-vpn-daemon/mullvad-vpn-daemon-systemd.post-install +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon-systemd.post-install @@ -1,12 +1,9 @@ #!/bin/sh set -eu -# Are we running systemd? +# Enable and start systemd services if which systemctl >/dev/null 2>&1 && systemctl is-system-running | grep -vq offline >/dev/null 2>&1; then - # Does `mullvad-daemon.service` exist? - if systemctl list-unit-files mullvad-daemon.service >/dev/null 2>&1; then - 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" - fi + 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" fi diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon-systemd.post-upgrade b/mullvad-vpn-daemon/mullvad-vpn-daemon-systemd.post-upgrade index 980d1e5..832a4db 100644 --- a/mullvad-vpn-daemon/mullvad-vpn-daemon-systemd.post-upgrade +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon-systemd.post-upgrade @@ -1,12 +1,9 @@ #!/bin/sh set -eu -# Are we running systemd? +# Enable and start systemd services if which systemctl >/dev/null 2>&1 && systemctl is-system-running | grep -vq offline >/dev/null 2>&1; then - # Does `mullvad-daemon.service` exist? - if systemctl list-unit-files mullvad-daemon.service >/dev/null 2>&1; then - 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" - fi + 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" fi diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall index 10004b3..574a7dd 100644 --- a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall @@ -1,5 +1,6 @@ #!/bin/sh set -eu +# Log out and remove any firewall rules mullvad-setup reset-firewall || echo "Failed to reset firewall" mullvad-setup remove-device || echo "Failed to remove device from account" diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-upgrade b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-upgrade index 9f88962..aa89b4b 100644 --- a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-upgrade +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-upgrade @@ -1,9 +1,9 @@ #!/bin/sh set -eu -# Are we running systemd? +# Stop the daemon gracefully, and set up firewall rules to prevent network +# leaks during upgrade. if which systemctl >/dev/null 2>&1 && systemctl is-system-running | grep -vq offline >/dev/null 2>&1; then - # Is `mullvad-daemon.service` running? if systemctl status mullvad-daemon >/dev/null 2>&1; then mullvad-setup prepare-restart || true systemctl stop mullvad-daemon.service @@ -14,5 +14,5 @@ if which systemctl >/dev/null 2>&1 && systemctl is-system-running | grep -vq off fi fi -# Since we are upgrading mullvad-daemon, it will probably have current IP baked into itself. +# Clear the cached API IP address. rm -f /var/cache/mullvad-vpn/api-ip-address.txt