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!
Thanks a ton for your help! I'm not quite there but I feel like I'm learning more lol
With your help I have made the changes you listed as well as some other changes while trying to troubleshoot. In no particular order:
Moved ocamlfuseStartup.sh to ~/.local/bin/ocamlfuseStartup.sh because I now am more familiar with what an immutable distro is and does and also added the shebang. File now reads:
Moved startup.service to ~/home/tyler/.config/systemd/user/startup.service, file now reads as follows:
I am now getting (code=exited, status=127) when I run "systemctl --user status startup.service --now." Which I have googled and determined that it is now having difficulty finding the program or one of the dependencies according to the bash man page. I attempted to troubleshoot this error by adding the full location of the program /usr/bin/google-drive-ocamlfuse to the ocamlfuseStartup.sh file. I'm unsure how to proceed from here though. Once again, super appreciative of your help. I'm going to bed now though...
I dont think systemd will expand the
~
, try replacing theExecStart=/bin/bash ~/.local/bin/ocamlfuseStartup.sh
line withExecStart=/bin/bash %h/.local/bin/ocamlfuseStartup.sh
, this will expand to your home directory, if its still giving a not found error, try runningwhich google-drive-ocamlfuse
in a terminal and make sure the path is correctI really appreciate your help with this. With your changes we have even acheived some partial success!
I did verify the package location with which google-drive-ocamlfuse, and replaced the ~ with %h.
The current configuration for ocamlfuseStartup.sh is:
startup.service is now:
spoiler
This current configuration leads to 0=SUCCESS, and boy howdy was I ELATED! Until... I realized that it didn't actually do the thing... The directory %h/googledrive remains empty unless I manually run the command "google-drive-ocamlfuse ~/googledrive" as before.
Interestingly enough, status shows all good in the hood as far as I can tell:
spoiler
journalctl also shows no whammies as far as I can tell:
spoiler
So I am once again stumped. I feel like it's so close.
However, with resources from others in this thread I have begun a war on two fronts. Introducing our newest contender ~/.config/systemd/user/google-drive-ocamlfuse.service Which as far as I can tell is another way of skinning this cat that doesn't involve a seperate .sh file to be called. Seems cleaner than the angle I had started working from, but what do I know. Special thanks to Oscar with his github link to documentation and after some iterative monkeying google-drive-ocamlfuse.service looks like so:
spoiler
And again 0=SUCCESS and premature elation, but alas no joy. Remarkably similar status and journalctl entries, so I remain stumped. Or possibly double stumped...
spoiler
I have attempted to run these competing services seperately as well as in tandem with the same lack of results. I feel that if I can't get it licked soon I will kick systemd to the curb and attempt another method outlined in the github link provided by Oscar. Most likely the fstab method that he mentioned because it sounds violent and that's the vibe at the moment lol. Once again thank you for any and all assistance.
It looks like its creating a new process and going in the background and systemd cant track it anymore, so it thinks that its exited and tries restarting. I took a link Oscar sent, and I saw that there is a systemd service and the
Type
is set toforking
, I think this could solve the problem, they also have anExecStop
line, id set it toExecStop=fusermount -u %h/googledrive
so it will unmount properly whenever you manually stop the service. So try settingType=forking
, and adding theExecStop
line, hopefully this will stop systemd from restarting it when it hasnt actually exitedHOLY SHIT WE DID IT!!! I have now rebooted several times and the changes you recommended have made it work automagically! I'm so relieved! I can't thank you enough, and I definitely owe you a beer.