# sbin — Support Scripts

## install-service.sh

Generates a systemd **user-level** service file and enables it. No root required.

**Prerequisites:** The app's `.venv` must exist and have Flask installed.

```bash
bash sbin/install-service.sh
```

You will be prompted for a host (default `127.0.0.1`) and port (default `5000`).
The script writes `~/.config/systemd/user/battery-tracker.service` and enables it.

**Start the service:**
```bash
systemctl --user start battery-tracker
systemctl --user status battery-tracker
```

**View live logs:**
```bash
journalctl --user -u battery-tracker -f
```

**Make it start on login** (requires lingering to be enabled for your user):
```bash
loginctl enable-linger "$USER"
```

**Uninstall:**
```bash
systemctl --user disable --now battery-tracker
rm ~/.config/systemd/user/battery-tracker.service
systemctl --user daemon-reload
```

**Re-run to update** (e.g. if you moved the app directory):
```bash
bash sbin/install-service.sh
systemctl --user restart battery-tracker
```
