Create a systemd service for Nextcloud - joefidler/joefidler.github.io GitHub Wiki
Use systemd to control our nextcloud pod.
Most of this originally comes from https://www.underkube.com/posts/2021-01-28-nextcloud-podman-rootless-systemd-part-iv-exposing/#systemd-service as well as https://www.unixsysadmin.com/systemd-user-services/
mkdir -p ~/.config/systemd/user/
Create the service file (by cut and paste into the nano text editor)
nano ~/.config/systemd/user/nextcloud_pod.service
The file itself:
[Unit]
Description=nextcloud_pod.service
[Service]
Restart=on-failure
ExecStartPre=/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
ExecStart=/usr/bin/podman pod start nextcloud_pod
ExecStop=/usr/bin/podman pod stop -t 10 nextcloud_pod
ExecStopPost=/usr/bin/sh -c "/usr/bin/podman rm -f `cat /%t/%n-cid`"
KillMode=none
Type=forking
PIDFile=/%t/%n-pid
[Install]
WantedBy=default.target
Start the service
systemctl --user daemon-reload
systemctl enable --user nextcloud_pod --now (starts it also , leave out the "now" to just enable)
sudo loginctl enable-linger squidward
Confirm and debug the service starting
systemctl --user status nextcloud_pod.service
journalctl --user -xe
Control the service
systemctl stop --user nextcloud_pod.service