It sounds to me the target you’d want here is network-online.target, going by the info here
Comment on Steam deck, Automount Network Share Library in Gamemode
CapillaryUpgrade@lemmy.sdf.org 9 months ago
This is really cool!
Where did you put the service file?
I don’t mean this as critique, but as possible next project, since your solution works perfectly fine. Systemd has some cool features that could make this project have a bit fewer moving parts:
- a .mount file could replace the mount and unmount script, and handle logging too! (I am pretty sure you would need separate files per mount, though, so “fewer moving parts” might be a bit of a lie, depending on your interpretation)
- that “After=” setting you used, can also be used to check for network connectivity. IIRC it’s “networking.target” on Fedora, at least. You might want to double check the systemd docs if After is the right one for this, as I have a hard remembering the systemd dependency intricacies.
That way you would end up with a .mount file per mounted directory, with logging using journald, and no external scripts.
I really like systemd as it can be a great tool, when you start to break down the complexity of it.
I hope you get well soon and get the best you can from this time.
lupec@lemm.ee 9 months ago
cammelspit@lemm.ee 9 months ago
I actually did try that but I messed it up somehow and didn’t get it working. I then sawanexample similar to what I did here and since it seemed to work for them, I copied it. Would also be able to ping the NAS itself instead so you can not only confirm the network is up but also confirm the NAS is listening and replying properly. 100% sure there are better ways to do almost everything here but it was my first big win and I had to share. 😂
lupec@lemm.ee 9 months ago
That’s totally valid, just wanted to share my two cents, having messed with a fair bit of systemd. At any rate, congrats, that’s a win for sure! :)
cammelspit@lemm.ee 9 months ago
Frankly, you are probably right. I am pretty new to all thisandwhat I have here is basically just cobbled together from nonsense examples I scrounged up off the internet. What’s funny is, a good 20% of this I habe no idea how it works! Lol
Originally i was juat going to make the script simply a list of all my mount commands and not even post anything about it at all. I spent a good two days playing around with about a dozen different ideas on how to accomplish my goal until this one, the first that worked at all. But yeah, I have been doinh a lot of fun stuff since I officially dropped Windows entirely a few weeks ago and a lot of the inner workings of how Linux works in general is just starting to make sense to me.
Pretty much the Arch wiki and the Gentoo wiki alongwith copious amounts of google fu have become an all encompasing hobby of mine as of late. I’ll get there eventually. 😁
CapillaryUpgrade@lemmy.sdf.org 9 months ago
Don’t put yourself down! Using systemd wouldn’t make it work “better”, it’s just more “proper” (and a great tool to know in general!)
Great job and keep going!
cammelspit@lemm.ee 9 months ago
Thanks! Yeah, I have noticed a lot of places where the location of things is not necessarily a requirement but it is considered “proper”. It’s a whole different paradigm compared to the rather severely rigid requirements of Windows. I went through a lot of documentation about services and the real eureka moment was when I realized it was more or less just a command being run with extra fluff around it like environment variables and such. I have the service placed in the /etc/systemd/system directory, where all the other ones valve made are. I have seen how powerful systemd can be when leveraged well but for the moment I’m pleased with the results. Thanks for the encouragement!
CapillaryUpgrade@lemmy.sdf.org 9 months ago
No problem!
I hacked this together instead of going to sleep, so it might make your deck explode, but maybe it’s a starting point for you or someone else:
I couldn’t confirm if mount units are allowed to be template units, but if not, just duplicate the service for each path and replace %i.
Say the word if you run into issues!