summaryrefslogtreecommitdiffhomepage
path: root/dist-assets/linux/before-remove.sh
blob: 2cb0c9afcd5e2c52f1aee9b8c7d92a237d286c43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env bash
set -eu

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
    echo not running
    exit 0;
fi

if which systemctl &> /dev/null; then
    # the user might've disabled or stopped the service themselves already
    systemctl stop mullvad-daemon.service || true
    systemctl disable mullvad-daemon.service || true
elif /sbin/init --version | grep upstart &> /dev/null; then
    stop mullvad-daemon
    rm -f /etc/init/mullvad-daemon.conf
fi