Starting rclone service via .sh file after network has connected with systemd
0
votes
1
answer
210
views
I'm trying to get the rclone service to mount a drive as soon as the system has received a network connection on boot/reboot.
So far I have all of the mounting working correctly via terminal. I have written a simple .sh file to execute it which basically is:
#!/bin/sh
! mountpoint -q /home/{user}/{location}/{location} || umount /home/{user}/{location}/{location}
rclone mount {nameofservice}: /home/{user}/{location}/{location} --config /home/{user}/.config/rclone/rclone.conf
Running this in terminal works as expected.
I have followed an online tutorial to get this working after a network connection has been achieved using systemd and have created the following file with 755 +x permissions in
/etc/systemd/system/{nameof.service}
[Unit]
Description=Starts {nameof.service} rclone service on startup
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User={user}
Group={group}
ExecStart=/home/{user}/{nameofsh}.sh
TimeoutStartSec=5
RemainAfterExit=yes
[Install]
WantedBy=network-online.target
I need it to run as that particular user. Following creation of this file I also:
systemctl daemon-reload
systemctl enable {nameof.service}
In the tutorial I expected the enable command to return a message about creating a symlink which I didn't get - it just retuned with a new line, but I didn't think this was major.
Regardless, when I run systemctl restart {nameof.service}
I get the expected outcome, but not on start up or reboot.
At this point I'm not sure how I've gone wrong and would appreciate any help.
Asked by jamesrsg
(3 rep)
Jul 9, 2023, 01:28 PM
Last activity: Jul 9, 2023, 02:34 PM
Last activity: Jul 9, 2023, 02:34 PM