If I have an external drive I access via FTPS, how can I add a systemctl service to mount it and unmount it and have it mount it upon start-up? I already saw some examples with scripts and crontab but I found them too incoherent and hard to deal with.
Create the directory where you'd like to mount the drive
Create now the file
/etc/systemd/system/external-ftp.service
with this content (yoursystemd/system
dir might be in a different location):Note the
-f
option to makecurlftps
run as daemon.ExecStart
andExecStop
need full path of commands, that is, note the full path ofcurlftps
andfusermount
. In your case may be different, find the full path withsudo find / -name curlftps -type f
.Now you just start the service
if everything is OK, you should be able to access
/mnt/ftp-drive
and the commandsudo service external-ftp status
should return OK.If everything is OK, activate the service to start on boot: