Files
mcp_screen/desktop_client/setup_service.sh
T

35 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
PLIST_NAME="com.adolforeyna.companionclient.plist"
LOCAL_PLIST="/Users/adolforeyna/Projects/MicroPython/test1/Screen/desktop_client/${PLIST_NAME}"
TARGET_DIR="${HOME}/Library/LaunchAgents"
TARGET_PLIST="${TARGET_DIR}/${PLIST_NAME}"
echo "=== Installing Desktop Companion LaunchAgent ==="
# 1. Create target directory if it doesn't exist
mkdir -p "${TARGET_DIR}"
# 2. Unload the service if it's already running
echo "Stopping existing agent if running..."
launchctl bootout gui/$(id -u) "${TARGET_PLIST}" 2>/dev/null
launchctl unload "${TARGET_PLIST}" 2>/dev/null
# 3. Copy the plist file
echo "Copying plist configuration..."
cp "${LOCAL_PLIST}" "${TARGET_PLIST}"
chmod 644 "${TARGET_PLIST}"
# 4. Load/start the LaunchAgent
echo "Loading and starting the service..."
launchctl bootstrap gui/$(id -u) "${TARGET_PLIST}"
# Or fallback if bootstrap fails
if [ $? -ne 0 ]; then
launchctl load "${TARGET_PLIST}"
fi
echo "Service successfully installed and started!"
echo "Check status using: launchctl list | grep com.adolforeyna.companionclient"
echo "Logs are available at:"
echo " STDOUT: /Users/adolforeyna/Projects/MicroPython/test1/Screen/desktop_client/stdout.log"
echo " STDERR: /Users/adolforeyna/Projects/MicroPython/test1/Screen/desktop_client/stderr.log"