summarylogtreecommitdiffstats
path: root/mullvad-vpn-cli.install
blob: de235d1709906127070ee31026447bb8083f40c1 (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
pre_install() {
	if systemctl status mullvad-daemon &> /dev/null; then
		echo 'Stopping & disabling Mullvad VPN daemon...'
		systemctl disable --now mullvad-daemon
	fi
}

post_install() {
    echo 'Copying sample settings...'
    if [[ ! -e /etc/mullvad-vpn/settings.json ]]; then
        cp -av /etc/mullvad-vpn/settings.json.sample \
            /etc/mullvad-vpn/settings.json
        echo 'Please edit /etc/mullvad-vpn/settings.json'
    fi
	echo 'Enabling Mullvad VPN daemon...'
	systemctl enable --now mullvad-daemon
}

pre_upgrade() {
	echo 'Stopping Mullvad VPN daemon...'
	systemctl stop mullvad-daemon
}

post_upgrade() {
	echo 'Restarting Mullvad VPN daemon...'
	systemctl daemon-reload
	systemctl start mullvad-daemon
}

pre_remove() {
	# the user might've disabled or stopped the service themselves already
	echo 'Making sure the Mullvad VPN daemon is stopped & disabled...'
	systemctl stop mullvad-daemon || true
	systemctl disable mullvad-daemon || true
}

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 alter config:'
	echo 'e.g. vim /etc/mullvad-vpn/settings.json'
	echo -------------------------------------------------------------
}