summarylogtreecommitdiffstats
path: root/mullvad-vpn.install
blob: 03b4392001fb5c707e97602121ad04864e0e42e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pre_install() {
  if systemctl status mullvad-daemon &> /dev/null; then
    echo 'Stopping & disabling Mullvad VPN daemon...'
    /opt/Mullvad\ VPN/resources/mullvad-setup prepare-restart || true
    systemctl disable --now mullvad-daemon
    echo 'Disabling Mullvad early boot blocking 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

  pkill -x "mullvad-gui" || true

  rm -f /var/cache/mullvad-vpn/relays.json
  rm -f /var/cache/mullvad-vpn/api-ip-address.txt
}

post_install() {
  chmod u+s "/usr/bin/mullvad-exclude"

  echo 'Starting & enabling Mullvad VPN daemon...'
  systemctl enable --now mullvad-daemon
  echo 'Enabling Mullvad early boot blocking service...'
  systemctl enable mullvad-early-boot-blocking
}

pre_upgrade() {
  pre_install
}

post_upgrade() {
  systemctl daemon-reload

  post_install
}

pre_remove() {
  # SIGTERM for some reason causes the app to crash sometimes and SIGINT works as expected.
  pkill -2 -x "mullvad-gui" || true
  sleep 0.5
  pkill -9 -x "mullvad-gui" || true

  # the user might've disabled or stopped the services themselves already
  echo 'Making sure the services are stopped & disabled...'
  systemctl disable --now mullvad-daemon || true
  systemctl disable --now 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"
}

post_remove() {
  echo -------------------------------------------------------------
  echo 'Optionally remove logs & cache:'
  echo 'sudo rm -rf /var/log/mullvad-vpn/'
  echo 'sudo rm -rf /var/cache/mullvad-vpn/'
  echo ''
  echo 'Optionally remove config:'
  echo 'sudo rm -rf /etc/mullvad-vpn/'
  echo ''
  echo 'Optionally remove app settings:'
  echo 'rm -rf ~/.config/Mullvad\ VPN/'
  echo ''
  echo 'Optionally remove auto-launcher:'
  echo 'rm ~/.config/autostart/mullvad-vpn.desktop'
  echo -------------------------------------------------------------
}