-
Install
htpc.serviceto/etc/systemd/system/htpc.serviceNote: I run the HTPC services as the user
htpcso amend the service file appropriately if needed. -
Create
service.shin the same location as referenced by the systemd service and ensure it is executable.Note: This should also be where your
docker-compose.ymlfile exists. -
Create
settings.envin the same directory asservice.sh. -
Modify
settings.envso that the mount directory is referenced per your requirements. -
Create the file
.mountedin the root of the mount by runningtouch .mountedin the correct place (/mnt/multimediafor me - updatesettings.envas needed). -
(Optional) Update
/etc/sudoersso 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.