blob: c8561c073012b42beb253212b764209b836cdc6e (
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
|
#!/usr/bin/env bash
set -eux
LOG_DIR=/var/log/mullvad-vpn
INSTALL_DIR=$2
mkdir -p $LOG_DIR
chmod 755 $LOG_DIR
exec 2>&1 > $LOG_DIR/preinstall.log
echo "Running preinstall at $(date)"
# Notify the running daemon that we are going to kill it and replace it with a newer version.
"$INSTALL_DIR/Mullvad VPN.app/Contents/Resources/mullvad-setup" prepare-restart || \
echo "Failed to send 'prepare-restart' command to old mullvad-daemon"
# Migrate cache files from <=2020.8-beta2 paths
OLD_CACHE_DIR="/var/root/Library/Caches/mullvad-vpn"
NEW_CACHE_DIR="/Library/Caches/mullvad-vpn"
if [ -d "$OLD_CACHE_DIR" ]; then
echo "Found old cache dir at $OLD_CACHE_DIR, moving to $NEW_CACHE_DIR"
mkdir -p "$NEW_CACHE_DIR"
mv "$OLD_CACHE_DIR"/* "$NEW_CACHE_DIR/" || echo "Unable to migrate cache. No cache files?"
rm -rf "$OLD_CACHE_DIR"
fi
# Remove the existing relay and API address cache lists.
# There is a risk that they're incompatible with the format this version wants
rm "$NEW_CACHE_DIR/relays.json" || true
rm "$NEW_CACHE_DIR/api-ip-address.txt" || true
# Create a group for mullvad-exclusion
MULLVAD_EXCLUSION_GROUP="mullvad-exclusion"
if ! dscl . -list /Groups | grep $MULLVAD_EXCLUSION_GROUP; then
dscl . -create /Groups/$MULLVAD_EXCLUSION_GROUP \
|| echo "FAILED TO CREATE $MULLVAD_EXCLUSION_GROUP GROUP"
fi
if ! dscl . -read /Groups/$MULLVAD_EXCLUSION_GROUP | grep PrimaryGroupID; then
MULLVAD_EXCLUSION_GID=$(( RANDOM ))
dscl . -append /Groups/$MULLVAD_EXCLUSION_GROUP PrimaryGroupID $MULLVAD_EXCLUSION_GID \
&& echo "Created mullvad-exclusion group with gid $MULLVAD_EXCLUSION_GID" \
|| echo "FAILED TO CREATE 'mullvad-exclusion' group"
fi
|