Files
king-arth-iot-devices/doc/setupAutostart.md
T
2026-11-01 16:46:30 +01:00

88 lines
1.7 KiB
Markdown

# Autostart applications
```sh
sudo nano /etc/systemd/system/SwordMain.service
```
```ini
[Unit]
Description=IoT Service for Sword Station
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=theUser
WorkingDirectory=/home/theUser/SwordMain
ExecStart=/home/theUser/SwordMain/run.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
```
```sh
chmod +x /home/theUser/SwordMain/start.sh
# Reload systemd
sudo systemctl daemon-reload
# Enable the service
sudo systemctl enable SwordMain.service
# start immediately
sudo systemctl start SwordMain.service
# check status
sudo systemctl status SwordMain.service
```
game $(pwd)/assets -b "mqtts://excaliburs-erben.de:8883" -t "outdoor/king-arthur/sword/" -p "awesomeexodusoutdooradventures" -u "exodususer"
## Watchdog
```sh
sudo nano /etc/systemd/system/SwordWatchdog.service
```
```ini
[Unit]
Description=Network Watchdog for Sword
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
# user root user
WorkingDirectory=/home/theUser/SwordWatchdog
ExecStart=/home/theUser/SwordWatchdog/watchdog.py
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
```
## WiFi Power
```sh
sudo nano /etc/systemd/system/wifi-txpower.service
# ..
sudo systemctl enable wifi-txpower.service
sudo systemctl start wifi-txpower.service
```
```sh
[Unit]
Description=Set WiFi TX Power limit to prevent overheating
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
# Wait 15 seconds after network connects so the network manager doesn't overwrite it
ExecStartPre=/bin/sleep 15
ExecStart=/sbin/iwconfig wlan0 txpower 20
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
```