-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot-service.sh
More file actions
executable file
·45 lines (43 loc) · 1.26 KB
/
bot-service.sh
File metadata and controls
executable file
·45 lines (43 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Control script for the Bluesky Bot service (com.bluesky.bot)
SERVICE_NAME="com.bluesky.bot"
PLIST_PATH="$HOME/Library/LaunchAgents/$SERVICE_NAME.plist"
case "$1" in
start)
echo "Starting $SERVICE_NAME..."
launchctl load "$PLIST_PATH"
launchctl start "$SERVICE_NAME"
echo "Started."
;;
stop)
echo "Stopping $SERVICE_NAME..."
launchctl stop "$SERVICE_NAME"
launchctl unload "$PLIST_PATH"
echo "Stopped."
;;
restart)
echo "Restarting $SERVICE_NAME..."
launchctl stop "$SERVICE_NAME"
launchctl unload "$PLIST_PATH"
sleep 1
launchctl load "$PLIST_PATH"
launchctl start "$SERVICE_NAME"
echo "Restarted."
;;
status)
if launchctl list | grep -q "$SERVICE_NAME"; then
PID=$(launchctl list | grep "$SERVICE_NAME" | awk '{print $1}')
if [ "$PID" != "-" ]; then
echo "$SERVICE_NAME is running (PID: $PID)"
else
echo "$SERVICE_NAME is loaded but not running"
fi
else
echo "$SERVICE_NAME is not loaded"
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac