-
Install
htpc.service
to/etc/systemd/system/htpc.service
Note: I run the HTPC services as the user
htpc
so amend the service file appropriately if needed. -
Create
service.sh
in the same location as referenced by the systemd service and ensure it is executable.Note: This should also be where your
docker-compose.yml
file exists. -
Create
settings.env
in the same directory asservice.sh
. -
Modify
settings.env
so that the mount directory is referenced per your requirements. -
Create the file
.mounted
in the root of the mount by runningtouch .mounted
in the correct place (/mnt/multimedia
for me - updatesettings.env
as needed). -
(Optional) Update
/etc/sudoers
so that the unprivileged user can restart the systemd service without a password, by adding this line (update as needed):%htpc ALL=NOPASSWD: /bin/systemctl * htpc*
-
Reload systemd and enable the service:
sudo systemctl daemon-reload && sudo systemctl enable htpc.service
-
Start the service with
sudo systemctl start htpc.service
Now when the service starts up, the script will simply check if that .mounted
file exists (which should only exist on the network share, not on the local disk) and if the file is absent, the docker-compose services won't start.