View previous topic :: View next topic |
Author |
Message |
usta n00b
Joined: 02 Jun 2020 Posts: 6
|
Posted: Thu Mar 03, 2022 5:53 pm Post subject: ntp-client after wifi |
|
|
Hi,
I want to start ntp-client automatically after wifi is establihed. Is there a runlevel or easy trick for that? |
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 1681
|
Posted: Thu Mar 03, 2022 6:14 pm Post subject: |
|
|
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 |
|
|
usta n00b
Joined: 02 Jun 2020 Posts: 6
|
Posted: Fri Mar 04, 2022 3:51 am Post subject: |
|
|
I will try that. Thank you. |
|
Back to top |
|
|
Fitzcarraldo Advocate
Joined: 30 Aug 2008 Posts: 2036 Location: United Kingdom
|
Posted: Fri Mar 04, 2022 12:10 pm Post subject: |
|
|
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 |
|
|
|