Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to modify init script dependencies
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
maxxim
n00b
n00b


Joined: 03 Feb 2015
Posts: 27

PostPosted: Thu Sep 02, 2021 10:38 am    Post subject: How to modify init script dependencies Reply with quote

Hi fellow Gentoonians,

I need to add the dependency 'need net' to both '/etc/init.d/ntp-client' and '/etc/init.d/samba'. Thus far, I have modified the init scripts directly

Code:
depend() {
   ...
   need net
}


but I wonder if that's really the right way to do this. Can this also somehow be done via the configuration files, i.e. by modifying '/etc/conf.d/ntp-client' and '/etc/conf.d/samba'?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9691
Location: almost Mile High in the USA

PostPosted: Thu Sep 02, 2021 2:08 pm    Post subject: Reply with quote

I believe this is the right way - adding the dependency to the init scripts - though I thought most of these packages that don't have these dependencies already written in their init scripts, well, autodetect interfaces dynamically, as in they will notice new interfaces added and open sockets on them?

Is this not happening? Or not fast enough? Yeah it's annoying that it may take a while to be ready with a correct date and serve samba requests but they should work. The dependencies were omitted mostly to speed up boot times...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21724

PostPosted: Thu Sep 02, 2021 4:18 pm    Post subject: Reply with quote

According to man openrc-run, yes, this can be done through conf.d.
Code:
     With the exception of /etc/rc.conf, the configuration files can also in‐
     fluence the dependencies of the service through variables. Simply prefix
     the name of the dependency with rc_.
For example:
Code:
# grep rc_need -r /etc/conf.d/
/etc/conf.d/sshd:rc_need="net.eth0"
Back to top
View user's profile Send private message
maxxim
n00b
n00b


Joined: 03 Feb 2015
Posts: 27

PostPosted: Thu Sep 02, 2021 4:59 pm    Post subject: Reply with quote

eccerr0r wrote:
I believe this is the right way - adding the dependency to the init scripts - though I thought most of these packages that don't have these dependencies already written in their init scripts, well, autodetect interfaces dynamically, as in they will notice new interfaces added and open sockets on them?

Is this not happening? Or not fast enough? Yeah it's annoying that it may take a while to be ready with a correct date and serve samba requests but they should work. The dependencies were omitted mostly to speed up boot times...


I'm using ifplugd, which means ethernet will start in the background during boot and not synchronously. I added 'need net' to ntp-client so it would also be started in the background once ethernet is ready (without this, it would stall booting and/or fail, iirc).

As for samba, I was experiencing issues regarding suspend/resume. Samba shares would be unreachable after resuming. Even restarting samba right after resume using an elogind hook script wouldn't work. Adding 'need net' + restarting ethernet after resume fixed this (also see https://forums.gentoo.org/viewtopic-p-8653804.html#8653804).


Last edited by maxxim on Thu Sep 02, 2021 5:03 pm; edited 3 times in total
Back to top
View user's profile Send private message
maxxim
n00b
n00b


Joined: 03 Feb 2015
Posts: 27

PostPosted: Thu Sep 02, 2021 5:01 pm    Post subject: Reply with quote

Hu wrote:
According to man openrc-run, yes, this can be done through conf.d.
Code:
     With the exception of /etc/rc.conf, the configuration files can also in‐
     fluence the dependencies of the service through variables. Simply prefix
     the name of the dependency with rc_.
For example:
Code:
# grep rc_need -r /etc/conf.d/
/etc/conf.d/sshd:rc_need="net.eth0"


YES, that would be it. I knew I read something like this a while ago, but I couldn't remember the details. This is better than modifying the init scripts in my opinion as it makes upgrades easier.

I'll give it try. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum