# systemd unit that manages the SanadR1 Docker container on the R1 backpack.
# Install: sudo cp sanadr1.service /etc/systemd/system/ && sudo systemctl daemon-reload
#          sudo systemctl enable --now sanadr1
# Coexists with the container's own --restart unless-stopped (belt-and-suspenders):
# systemd guarantees create+start on boot and gives systemctl start/stop/status.
[Unit]
Description=SanadR1 (Docker) - Gemini voice + dashboard on the R1 EDU backpack
Requires=docker.service
After=docker.service network-online.target
Wants=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
# Self-healing: if the container was removed (e.g. after an image reload), recreate
# it from run.sh; otherwise just (re)start the existing one.
ExecStartPre=-/bin/sh -c 'docker inspect sanadr1 >/dev/null 2>&1 || /home/unitree/SanadR1/docker/run.sh'
ExecStart=/usr/bin/docker start sanadr1
ExecStop=/usr/bin/docker stop sanadr1

[Install]
WantedBy=multi-user.target
