#!/bin/sh
# Runs as root. Loads the env agent into the logged-in session and opens the app to activate the extension.
user=$(stat -f %Su /dev/console)
[ "$user" = root ] && exit 0
uid=$(id -u "$user")
agent=/Library/LaunchAgents/com.usestrix.firewall.env.plist
launchctl bootout "gui/$uid" "$agent" 2>/dev/null
launchctl bootstrap "gui/$uid" "$agent"
launchctl asuser "$uid" sudo -u "$user" open -a /Applications/StrixFirewall.app --args --install
exit 0
