Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ntp-client after wifi
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
usta
n00b
n00b


Joined: 02 Jun 2020
Posts: 6

PostPosted: Thu Mar 03, 2022 5:53 pm    Post subject: ntp-client after wifi Reply with quote

Hi,

I want to start ntp-client automatically after wifi is establihed. Is there a runlevel or easy trick for that?
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1681

PostPosted: Thu Mar 03, 2022 6:14 pm    Post subject: Reply with quote

You can try to tie ntp-client service to the net-online service with rc_need="network-online" in /etc/conf.d/ntp-client and configuring /etc/conf.d/net-online.

That only works if the network is automatically configured or will stop your boot.

Alternatively, look into using chrony instead of net-misc/ntp package. Chrony is easily configured for offline use and can be signaled when the machine goes online.
Back to top
View user's profile Send private message
usta
n00b
n00b


Joined: 02 Jun 2020
Posts: 6

PostPosted: Fri Mar 04, 2022 3:51 am    Post subject: Reply with quote

I will try that. Thank you.
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2036
Location: United Kingdom

PostPosted: Fri Mar 04, 2022 12:10 pm    Post subject: Reply with quote

If you happen to be using NetworkManager, it is possible to put a script in the directory /etc/NetworkManager/dispatcher.d/ to do it. For example:

Code:
#!/bin/bash
INTERFACE=$1 # The interface which is brought up or down
STATUS=$2 # The new state of the interface
case "$STATUS" in
    'up') # $INTERFACE is up
        rc-config restart ntp-client
        ;;
    'down') # $INTERFACE is down
        # Check for active interface and down if no one active
        if [ `nmcli c | grep -v "\-\-" | grep -v "NAME.*UUID.*TYPE.*DEVICE" | wc -l` -eq 0 ]; then
            rc-config stop ntp-client
        fi
        ;;
esac

_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.

My blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing 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