#!/usr/bin/env bash ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd)" info() { TERM=${TERM:-dumb} echo -e "$(tput setaf 4)- $@$(tput sgr0)" 1>&2 } cmd() { echo "[#] $*" >&2 "$@" } set -e info "building innernet binary." cmd cargo build --release --bin innernet info "installing innernet binary." cmd sudo cp -f $ROOT_DIR/target/release/innernet /usr/local/bin cmd sudo ln -s /usr/local/bin/innernet /usr/local/bin/inn if ! which wg > /dev/null; then info "installing wireguard." cmd brew install wireguard-tools fi info "installing launch daemon for innernet daemon script." echo "\ Label no.tonari.innernet ProgramArguments /usr/local/bin/innernet fetch --daemon --interval 60 KeepAlive RunAtLoad LaunchOnlyOnce StandardOutPath /var/log/innernet.log StandardErrorPath /var/log/innernet.log EnvironmentVariables PATH /usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin " | cmd sudo tee /Library/LaunchDaemons/no.tonari.innernet.plist cmd sudo launchctl enable system/no.tonari.innernet cmd sudo launchctl bootstrap system /Library/LaunchDaemons/no.tonari.innernet.plist