Files
boc/projects/landvex/20-automation/installera.sh
T

74 lines
2.4 KiB
Bash
Raw Normal View History

#!/bin/bash
# Landvex Artikelautomation — installationsskript
# Kör som root eller med sudo
set -e
echo "=== Landvex Artikelautomation — Installation ==="
# Skapa loggkatalog
mkdir -p /var/log/landvex
chown bernt:bernt /var/log/landvex
# Kopiera servicefiler
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cp "$SCRIPT_DIR/landvex-artikel.service" /etc/systemd/system/
cp "$SCRIPT_DIR/landvex-artikel-erik.timer" /etc/systemd/system/
cp "$SCRIPT_DIR/landvex-artikel-johan.timer" /etc/systemd/system/
# Skapa instanser för Erik (cap=4 per körning, 2 körningar = 8 poster)
cat > /etc/systemd/system/landvex-artikel-erik@.service << 'EOF'
[Unit]
Description=Landvex Artikelproduktion — Erik %i
After=network.target
[Service]
Type=oneshot
User=bernt
WorkingDirectory=/home/bernt/.openclaw/workspace/projects/landvex/20-automation
Environment="PYTHONPATH=/home/bernt/.openclaw/workspace/projects/landvex"
ExecStart=/usr/bin/python3 /home/bernt/.openclaw/workspace/projects/landvex/20-automation/kor_agent.py --agent-id erik-%i --cap 4
StandardOutput=append:/var/log/landvex/artikel-erik.log
StandardError=append:/var/log/landvex/artikel-erik.log
EOF
# Skapa instanser för Johan (cap=2 per körning, 1 körning = 2 poster)
cat > /etc/systemd/system/landvex-artikel-johan@.service << 'EOF'
[Unit]
Description=Landvex Artikelproduktion — Johan %i
After=network.target
[Service]
Type=oneshot
User=bernt
WorkingDirectory=/home/bernt/.openclaw/workspace/projects/landvex/20-automation
Environment="PYTHONPATH=/home/bernt/.openclaw/workspace/projects/landvex"
ExecStart=/usr/bin/python3 /home/bernt/.openclaw/workspace/projects/landvex/20-automation/kor_agent.py --agent-id johan-%i --cap 2
StandardOutput=append:/var/log/landvex/artikel-johan.log
StandardError=append:/var/log/landvex/artikel-johan.log
EOF
# Ladda om systemd
systemctl daemon-reload
# Aktivera timers
systemctl enable landvex-artikel-erik.timer
systemctl enable landvex-artikel-johan.timer
# Starta timers
systemctl start landvex-artikel-erik.timer
systemctl start landvex-artikel-johan.timer
echo ""
echo "=== Installation klar ==="
echo "Timers:"
systemctl list-timers | grep landvex || true
echo ""
echo "Loggar: /var/log/landvex/"
echo "Kö: /home/bernt/.openclaw/workspace/projects/landvex/20-automation/intag/artikelko.json"
echo ""
echo "Manuell körning:"
echo " sudo systemctl start landvex-artikel-erik@01.service"
echo " sudo systemctl start landvex-artikel-johan@01.service"