diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-05-14 12:46:10 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-05-14 15:59:41 +0200 |
| commit | 0b2805bc02b182df4adce9d0b6963afaad45395d (patch) | |
| tree | 168687eef58ff85c3429790bb2cd86fae602a9c5 | |
| parent | ba5ae0c3436be0312d700463d4b51eddc285da3b (diff) | |
| download | mullvadvpn-0b2805bc02b182df4adce9d0b6963afaad45395d.tar.xz mullvadvpn-0b2805bc02b182df4adce9d0b6963afaad45395d.zip | |
Add pkg postinstall script for installing daemon
| -rwxr-xr-x | dist-assets/pkg-scripts/postinstall | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/dist-assets/pkg-scripts/postinstall b/dist-assets/pkg-scripts/postinstall new file mode 100755 index 0000000000..2180d91ee4 --- /dev/null +++ b/dist-assets/pkg-scripts/postinstall @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +set -eu + +LOG_DIR=/var/log/mullvad-daemon + +mkdir -p $LOG_DIR +exec 2>&1 > $LOG_DIR/install.log + +INSTALL_DIR=$2 +DAEMON_PLIST_PATH="/Library/LaunchDaemons/net.mullvad.daemon.plist" + +DAEMON_PLIST=$(cat <<-EOM +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>Label</key> + <string>net.mullvad.daemon</string> + + <key>ProgramArguments</key> + <array> + <string>$INSTALL_DIR/Mullvad VPN.app/Contents/Resources/mullvad-daemon</string> + <string>-v</string> + <string>--log</string> + <string>$LOG_DIR/daemon.log</string> + <string>--tunnel-log</string> + <string>$LOG_DIR/openvpn.log</string> + </array> + + <key>UserName</key> + <string>root</string> + + <key>RunAtLoad</key> + <true/> + + <key>KeepAlive</key> + <true/> + + <key>StandardErrorPath</key> + <string>$LOG_DIR/stderr.log</string> + </dict> +</plist> +EOM +) + +launchctl unload -w $DAEMON_PLIST_PATH +echo "$DAEMON_PLIST" > $DAEMON_PLIST_PATH +launchctl load -w $DAEMON_PLIST_PATH |
