#!/usr/bin/env bash set -eu LOG_DIR=/var/log/mullvad-vpn mkdir -p $LOG_DIR exec 2>&1 > $LOG_DIR/postinstall.log echo "Running postinstall at $(date)" INSTALL_DIR=$2 DAEMON_PLIST_PATH="/Library/LaunchDaemons/net.mullvad.daemon.plist" DAEMON_PLIST=$(cat <<-EOM Label net.mullvad.daemon ProgramArguments $INSTALL_DIR/Mullvad VPN.app/Contents/Resources/mullvad-daemon -v UserName root RunAtLoad KeepAlive SoftResourceLimits NumberOfFiles 1024 StandardErrorPath $LOG_DIR/stderr.log EOM ) pkill -x "Mullvad VPN" || echo "Unable to kill GUI, not running?" sleep 1 launchctl unload -w $DAEMON_PLIST_PATH echo "$DAEMON_PLIST" > $DAEMON_PLIST_PATH launchctl load -w $DAEMON_PLIST_PATH mkdir -p /usr/local/bin ln -sf "$INSTALL_DIR/Mullvad VPN.app/Contents/Resources/mullvad" /usr/local/bin/mullvad ln -sf "$INSTALL_DIR/Mullvad VPN.app/Contents/Resources/mullvad-problem-report" /usr/local/bin/mullvad-problem-report