41 lines
1.6 KiB
Bash
Executable File
41 lines
1.6 KiB
Bash
Executable File
#!/bin/zsh
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR=${0:A:h}
|
|
PROJECT_DIR=${SCRIPT_DIR:h}
|
|
BIN_DIR="${HOME}/.local/bin"
|
|
STATE_DIR="${HOME}/Library/Application Support/UltraMesh"
|
|
LAUNCH_DIR="${HOME}/Library/LaunchAgents"
|
|
PLIST_PATH="${LAUNCH_DIR}/com.ultramesh.umnd.plist"
|
|
|
|
cd "${PROJECT_DIR}"
|
|
swift build -c release --product umnd
|
|
swift build -c release --product umn
|
|
BUILD_DIR=$(swift build -c release --show-bin-path)
|
|
|
|
mkdir -p "${BIN_DIR}" "${STATE_DIR}" "${LAUNCH_DIR}"
|
|
install -m 755 "${BUILD_DIR}/umnd" "${BIN_DIR}/umnd"
|
|
install -m 755 "${BUILD_DIR}/umn" "${BIN_DIR}/umn"
|
|
codesign --force --sign - "${BIN_DIR}/umnd" >/dev/null 2>&1
|
|
codesign --force --sign - "${BIN_DIR}/umn" >/dev/null 2>&1
|
|
|
|
launchctl bootout "gui/${UID}" "${PLIST_PATH}" >/dev/null 2>&1 || true
|
|
plutil -create xml1 "${PLIST_PATH}"
|
|
plutil -insert Label -string com.ultramesh.umnd "${PLIST_PATH}"
|
|
plutil -insert ProgramArguments -array "${PLIST_PATH}"
|
|
plutil -insert ProgramArguments.0 -string "${BIN_DIR}/umnd" "${PLIST_PATH}"
|
|
plutil -insert RunAtLoad -bool true "${PLIST_PATH}"
|
|
plutil -insert KeepAlive -bool true "${PLIST_PATH}"
|
|
plutil -insert ProcessType -string Background "${PLIST_PATH}"
|
|
plutil -insert StandardOutPath -string "${STATE_DIR}/umnd.log" "${PLIST_PATH}"
|
|
plutil -insert StandardErrorPath -string "${STATE_DIR}/umnd.log" "${PLIST_PATH}"
|
|
chmod 600 "${PLIST_PATH}"
|
|
launchctl bootstrap "gui/${UID}" "${PLIST_PATH}"
|
|
|
|
echo "Ultra Mesh Network installed."
|
|
echo "Binary directory: ${BIN_DIR}"
|
|
if [[ ":${PATH}:" != *":${BIN_DIR}:"* ]]; then
|
|
echo "Add this line to ~/.zshrc: export PATH=\"\$HOME/.local/bin:\$PATH\""
|
|
fi
|
|
"${BIN_DIR}/umn" status
|