SOLVED If any lost souls find themselves here in a similar situation let it be known that the file that worked for me was creating a file at '%h/.config/systemd/user/google-drive-ocamlfuse.service' with the following content:
[Unit]
Description=FUSE filesystem over Google Drive
After=network.target
[Service]
ExecStart=google-drive-ocamlfuse %h/googledrive
ExecStop=fusemount -u %h/googledrive
Restart=always
RestartSec=300
Type=forking
[Install]
WantedBy=default.target
Howdy, I have very recently installed Opensuse Tumbleweed alongside Windows 10 (On a seperate drive) and am trying to get things setup to where I can fully transition to linux. One of the first things I have hit a wall on is getting a file to execute on boot using systemd.
I am trying to use this package to be able to access my google drive from Dolphin. And so far it works okay. Except that it doesn't survive a reboot. I have to run the command:
google-drive-ocamlfuse ~/googledrive
after each reboot in order for the google drive directories to be accessible. So I googled how to make that happen automagically on boot and found this guide that helped me get a startup script going.
I created /usr/local/bin/ocamlfuseStartup.sh as a file that contains the command from before:
google-drive-ocamlfuse ~/googledrive
and verified that it works as intended when I enter ./ocamlfuseStartup.sh from that directory.
I then created another file at /usr/lib/systemd/system/startup.service that contains the following:
[Unit]
Description=Startup Script
[Service]
ExecStart=/bin/bash /usr/local/bin/ocamlfuseStartup.sh
[Install]
WantedBy=multi-user.target
I have no idea what the /bin/bash portion is for because I found it from a googling but without it I get the following error:
startup.service: Main process exited, code=exited, status=203/EXEC
However with it I get this error:
startup.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
which I take to mean that there is something wrong with my ocamlfuseStartup.sh file maybe? But since it works when I manually execute the file I'm kind of at a loss.
I found this thread where it seemed like someone else was having a similar issue but I didn't really grok what they were talking about.
Any and all help is greatly appreciated!
The 203 error you got is because your script isnt a valid executable, it needs to have a shebang at the top, you can change it to something like this and set the executable bit with
chmod +x <file>
this tells it to run using bash as the interpreter.
Im not familliar with this google drive software, but im figuring that its exiting with an error code cuz its running as a system service, and $HOME probobly isnt set so
~
doesnt expand and the software gets an invalid path.But I recommend using a user service for this, it will run when you login, you should be able to copy the service file you already have into
~/.config/systemd/user/
and runsystemctl --user daemon-reload
andsystemctl --user enable startup.service --now
, this will enable and start the service in one go.I also recommend adding the following lines under
[Service]
idk if the software will exit if it loses network or wifi or anything, but this will have it automatically restart after 60 seconds, should it exit for any reason.
If you need it to run before login, it is possible to do with a system service, but it will need a bit more setup
They could use loginctl enable-persist if they want a user service to run at boot. I use it for my home nas server, just to make it slightly easier to manage my non-root services.
Thanks for your input, I'll look into this.