-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·121 lines (103 loc) · 3.95 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·121 lines (103 loc) · 3.95 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
set -e
# Awtrix3 Calendar - Install Script
# Installs the application as a self-contained macOS app bundle
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
APP_NAME="Awtrix3Calendar.app"
INSTALL_DIR="/Applications"
INSTALLED_APP="$INSTALL_DIR/$APP_NAME"
LOG_DIR="$HOME/Library/Logs/awtrix3calendar"
CONFIG_DIR="$HOME/.awtrix3calendar"
CONFIG_FILE="$CONFIG_DIR/config.json"
CLI_BIN="$HOME/.local/bin/awtrix3calendar"
echo "=== Awtrix3 Calendar Installer ==="
echo ""
# Create config file if it doesn't exist
if [ ! -f "$CONFIG_FILE" ]; then
echo "Creating configuration file..."
mkdir -p "$CONFIG_DIR"
cp "$SCRIPT_DIR/config.template.json" "$CONFIG_FILE"
echo ""
echo "** IMPORTANT: Configuration file created at: $CONFIG_FILE"
echo "** Please edit this file and set your MQTT credentials before starting the service."
echo ""
echo "Press Enter after editing the config file, or Ctrl+C to cancel..."
read -r
fi
# Validate config has been edited
if grep -q "YOUR_MQTT_USERNAME" "$CONFIG_FILE"; then
echo "ERROR: Please edit $CONFIG_FILE and set your MQTT credentials."
echo ""
echo " Open the file with: nano $CONFIG_FILE"
echo ""
exit 1
fi
# Create virtual environment if it doesn't exist
if [ ! -d "$SCRIPT_DIR/venv" ]; then
echo "Creating virtual environment..."
python3 -m venv "$SCRIPT_DIR/venv"
fi
# Install dependencies
echo "Installing dependencies..."
"$SCRIPT_DIR/venv/bin/pip" install -q -r "$SCRIPT_DIR/requirements.txt"
# Create log directory
echo "Creating log directory..."
mkdir -p "$LOG_DIR"
# Remove old app if exists
if [ -d "$INSTALLED_APP" ]; then
echo "Removing old installation..."
rm -rf "$INSTALLED_APP"
fi
# Build self-contained app bundle
echo "Building self-contained app bundle..."
mkdir -p "$INSTALLED_APP/Contents/MacOS"
mkdir -p "$INSTALLED_APP/Contents/Resources"
# Copy Python source files
echo " Copying Python source files..."
cp "$SCRIPT_DIR"/*.py "$INSTALLED_APP/Contents/Resources/"
# Copy virtual environment
echo " Copying virtual environment (this may take a moment)..."
cp -R "$SCRIPT_DIR/venv" "$INSTALLED_APP/Contents/Resources/venv"
# Copy Info.plist and launcher script
cp "$SCRIPT_DIR/Info.plist" "$INSTALLED_APP/Contents/"
cp "$SCRIPT_DIR/scripts/launcher.sh" "$INSTALLED_APP/Contents/MacOS/Awtrix3Calendar"
chmod +x "$INSTALLED_APP/Contents/MacOS/Awtrix3Calendar"
# Install CLI command
echo "Installing CLI command..."
mkdir -p "$(dirname "$CLI_BIN")"
cp "$SCRIPT_DIR/scripts/cli-wrapper.sh" "$CLI_BIN"
chmod +x "$CLI_BIN"
# Remove from login items if already there (to avoid duplicates)
osascript -e 'tell application "System Events" to delete login item "Awtrix3Calendar"' 2>/dev/null || true
# Add to login items
echo "Adding to Login Items..."
osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/Awtrix3Calendar.app", hidden:true}'
# Launch the app
echo "Starting application..."
open "$INSTALLED_APP"
echo ""
echo "=== Installation complete! ==="
echo ""
echo "The application:"
echo " - Is installed at: $INSTALLED_APP (self-contained)"
echo " - Will start automatically on login (see System Settings > General > Login Items)"
echo " - Is now running in the background"
echo " - You can safely delete the source directory after installation"
echo ""
echo "Configuration: $CONFIG_FILE"
echo ""
echo "Logs are available at:"
echo " $LOG_DIR/awtrix3calendar.log"
echo " $LOG_DIR/awtrix3calendar.error.log"
echo ""
echo "CLI commands:"
echo " awtrix3calendar start - Start as background daemon"
echo " awtrix3calendar stop - Stop running instance"
echo " awtrix3calendar status - Show running status"
echo " awtrix3calendar run - Run in foreground"
echo ""
echo "NOTE: Add ~/.local/bin to your PATH if not already present:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
echo "To view logs: tail -f $LOG_DIR/awtrix3calendar.log"
echo "To uninstall: $INSTALLED_APP (drag to Trash) or run ./uninstall.sh"