-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·84 lines (74 loc) · 2.35 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·84 lines (74 loc) · 2.35 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# ClowFlow Monitoring - Install & Setup
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VENV_DIR="$SCRIPT_DIR/.venv"
PLIST_NAME="com.clowflow.monitoring"
PLIST_PATH="$HOME/Library/LaunchAgents/$PLIST_NAME.plist"
LOG_DIR="$HOME/.clowflow_monitoring/logs"
echo "=== ClowFlow Monitoring Setup ==="
# Create virtual environment
if [ ! -d "$VENV_DIR" ]; then
echo "Creating virtual environment..."
python3 -m venv "$VENV_DIR"
fi
echo "Installing dependencies..."
"$VENV_DIR/bin/pip" install -q -r "$SCRIPT_DIR/requirements.txt"
# Create log directory
mkdir -p "$LOG_DIR"
# Take initial snapshot
echo "Taking initial snapshot..."
"$VENV_DIR/bin/python" "$SCRIPT_DIR/monitor.py" --snapshot
echo ""
echo "Setup complete!"
echo ""
echo "Usage:"
echo " # Run monitoring in foreground"
echo " $VENV_DIR/bin/python $SCRIPT_DIR/monitor.py"
echo ""
echo " # Take a snapshot"
echo " $VENV_DIR/bin/python $SCRIPT_DIR/monitor.py --snapshot"
echo ""
echo " # Show changes since last snapshot"
echo " $VENV_DIR/bin/python $SCRIPT_DIR/monitor.py --diff"
echo ""
echo " # Install as background service (macOS)"
echo " bash $SCRIPT_DIR/install.sh --service"
echo ""
# Optional: install as launchd service
if [ "$1" = "--service" ]; then
echo "Installing as macOS LaunchAgent..."
cat > "$PLIST_PATH" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>$PLIST_NAME</string>
<key>ProgramArguments</key>
<array>
<string>$VENV_DIR/bin/python</string>
<string>$SCRIPT_DIR/monitor.py</string>
<string>-c</string>
<string>$SCRIPT_DIR/config.json</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>$LOG_DIR/monitor.stdout.log</string>
<key>StandardErrorPath</key>
<string>$LOG_DIR/monitor.stderr.log</string>
<key>WorkingDirectory</key>
<string>$SCRIPT_DIR</string>
</dict>
</plist>
PLIST
launchctl unload "$PLIST_PATH" 2>/dev/null || true
launchctl load "$PLIST_PATH"
echo "Service installed and running!"
echo " Stop: launchctl unload $PLIST_PATH"
echo " Start: launchctl load $PLIST_PATH"
echo " Logs: tail -f $LOG_DIR/monitor.stdout.log"
fi