Add Linux deployment scripts
- install.sh: Sets up /opt/kao with systemd service - uninstall.sh: Clean removal - Hide message when optimal (only show when something to report) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -220,9 +220,9 @@
|
|||||||
emoteEl.style.color = data.color;
|
emoteEl.style.color = data.color;
|
||||||
messageEl.style.color = data.color;
|
messageEl.style.color = data.color;
|
||||||
|
|
||||||
// Show event message if available, otherwise show state
|
// Only show message when there's something to report
|
||||||
const topEvent = data.active_events && data.active_events[0];
|
const topEvent = data.active_events && data.active_events[0];
|
||||||
messageEl.textContent = (topEvent && topEvent.message) || data.message;
|
messageEl.textContent = (topEvent && topEvent.message) || '';
|
||||||
|
|
||||||
// Update animation class
|
// Update animation class
|
||||||
emoteEl.className = '';
|
emoteEl.className = '';
|
||||||
|
|||||||
79
install.sh
Normal file
79
install.sh
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Kao Installation Script
|
||||||
|
# Installs to /opt/kao and sets up systemd service
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
INSTALL_DIR="/opt/kao"
|
||||||
|
SERVICE_FILE="/etc/systemd/system/kao.service"
|
||||||
|
CURRENT_USER=$(whoami)
|
||||||
|
|
||||||
|
echo "===================================="
|
||||||
|
echo " Kao Installer"
|
||||||
|
echo "===================================="
|
||||||
|
echo "Install directory: $INSTALL_DIR"
|
||||||
|
echo "Running as user: $CURRENT_USER"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Check if running with appropriate permissions
|
||||||
|
if [ ! -w "/opt" ]; then
|
||||||
|
echo "Error: Need write access to /opt"
|
||||||
|
echo "Run with: sudo $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create install directory
|
||||||
|
echo "[1/5] Creating install directory..."
|
||||||
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
cp -r aggregator.py kao.py index.html config.json requirements.txt detectors "$INSTALL_DIR/"
|
||||||
|
chown -R "$CURRENT_USER:$CURRENT_USER" "$INSTALL_DIR"
|
||||||
|
|
||||||
|
# Create virtual environment
|
||||||
|
echo "[2/5] Creating virtual environment..."
|
||||||
|
cd "$INSTALL_DIR"
|
||||||
|
python3 -m venv venv
|
||||||
|
./venv/bin/pip install --upgrade pip -q
|
||||||
|
./venv/bin/pip install -r requirements.txt -q
|
||||||
|
|
||||||
|
# Create systemd service
|
||||||
|
echo "[3/5] Creating systemd service..."
|
||||||
|
cat > "$SERVICE_FILE" << EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Kao - System Status Monitor
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=$CURRENT_USER
|
||||||
|
WorkingDirectory=$INSTALL_DIR
|
||||||
|
ExecStart=$INSTALL_DIR/venv/bin/python $INSTALL_DIR/kao.py
|
||||||
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Reload systemd and enable service
|
||||||
|
echo "[4/5] Enabling service..."
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable kao.service
|
||||||
|
|
||||||
|
# Start service
|
||||||
|
echo "[5/5] Starting Kao..."
|
||||||
|
systemctl start kao.service
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "===================================="
|
||||||
|
echo " Installation complete!"
|
||||||
|
echo "===================================="
|
||||||
|
echo ""
|
||||||
|
echo "Kao is now running at http://$(hostname -I | awk '{print $1}'):5000"
|
||||||
|
echo ""
|
||||||
|
echo "Commands:"
|
||||||
|
echo " sudo systemctl status kao # Check status"
|
||||||
|
echo " sudo systemctl restart kao # Restart"
|
||||||
|
echo " sudo systemctl stop kao # Stop"
|
||||||
|
echo " sudo journalctl -u kao -f # View logs"
|
||||||
|
echo ""
|
||||||
|
echo "Config file: $INSTALL_DIR/config.json"
|
||||||
35
uninstall.sh
Normal file
35
uninstall.sh
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Kao Uninstall Script
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
INSTALL_DIR="/opt/kao"
|
||||||
|
SERVICE_FILE="/etc/systemd/system/kao.service"
|
||||||
|
|
||||||
|
echo "===================================="
|
||||||
|
echo " Kao Uninstaller"
|
||||||
|
echo "===================================="
|
||||||
|
|
||||||
|
# Check permissions
|
||||||
|
if [ ! -w "/opt" ]; then
|
||||||
|
echo "Error: Need write access"
|
||||||
|
echo "Run with: sudo $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Stop and disable service
|
||||||
|
echo "[1/3] Stopping service..."
|
||||||
|
systemctl stop kao.service 2>/dev/null || true
|
||||||
|
systemctl disable kao.service 2>/dev/null || true
|
||||||
|
|
||||||
|
# Remove service file
|
||||||
|
echo "[2/3] Removing systemd service..."
|
||||||
|
rm -f "$SERVICE_FILE"
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
# Remove install directory
|
||||||
|
echo "[3/3] Removing files..."
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Kao has been uninstalled."
|
||||||
Reference in New Issue
Block a user