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!
I like to have a decently firm grasp of the commands I type into the terminal so either I'm too high or what you're throwing down is more advanced than I'm comfortable with. Thank you for your help though. Especially regarding the broken environment, I think I am dealing with some of that now as I am now receiving an error 127. I added the full path for the google-drive-ocamlfuse package but am still receiving the error 127 so I will try to load it's dependencies next time similar to your which sed example.
not sure at what level you are, here are some hints:
take your time to understand what the things do. shells like bash are very powerful and accidentially typing simething wrong could cause data loss or similar. but as you said, take care that you undestand what things are for and how they work.
most tools like sed or bash have a manpage that helps. bash has a huge one as it is very powerull (want to "program" like in C with pointers to variables, bash can do so using eval, which is evil, it really has downsides when doing too much in bash), but anyway learn the tools you use as you try them.
you can leave the manpage with pressing "q". pressing "h" shows how to navigate man pages.
the exit code of your script could come from bash itself or from the last command executed, it depends a bit. lets say bash stumbles over invalid syntax in the script while running the code or over a redirection ('<' '>') that points to an empty variable or nonexisting directory, then its bash who exits with its error. so an empty variable could cause such an error. but it usually exits with the exit code of the last run command (see bash "set -e" option which lets bash exit on the first failed command which together with the "-x" switch is very handy, but dont confuse it with other "-e" things in bash's huge manpage)
try in your console:
using () in a terminal opens a subshell so that what you do there (set -e, setting variables etc) does not affect your current shells environment (unless you change files on disk or such) in the last case the exit code was from the "echo foo" command which succeded and returned 0 while the exit code of /bin/false was ignored (other than in that 'set -e' example)
i use exit codes a lot in bash scripts to control script flow also together with functions.
some programs have a bit mask of what went wrong ('man fsck' explains that they use a bitwise OR to determine the resulting exit code of the program to include multiple possible errors at once) so when dealing with an exit code other than 0 you likely first want to know which program caused it (maybe using the "-x" switch i.e.) and then consult man page or online help what it means.
as ocamlfuseStartup.sh is a shellscript you likely find what happens inside of it.
good luck