Modify

Opened 10 years ago

Closed 9 years ago

#3027 closed defect (fixed)

openntpd hotplug script fails to run ntpd

Reported by: uentin@… Owned by: developers
Priority: normal Milestone:
Component: packages Version:
Keywords: Cc:

Description

The ntpd.hotplug script (/etc/hotplug.d/iface/20-ntpd) contains 2 errors:

  1. ps does not take the x option
  2. ps | grep 'ntpd' >&- will always find a match, being the grep ntpd command itself.

Solution:
Change line

ps x | grep 'ntpd' >&-
{

to

ps | grep -v grep | grep -v 20-ntpd | grep 'ntpd' >&-
{

Also, every time ntpd is started, /etc/TZ is written, causing unnecessary writes to flash.
Change line

echo "$posixtx" > /etc/TZ

to

if [ ! -f /etc/TZ ]
then

echo "$posixtz" > /etc/TZ

fi

See attached ntpd.hotplug with changes.

Attachments (2)

ntpd.hotplug (676 bytes) - added by quentin@… 10 years ago.
20-ntpd (419 bytes) - added by thomas@… 9 years ago.
fixed 20-ntpd file

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by quentin@…

comment:1 in reply to: ↑ description Changed 10 years ago by anonymous

Replying to uentin@armitage.org.uk:

Also, every time ntpd is started, /etc/TZ is written, causing unnecessary writes to flash.

This is not true if /etc/TZ is a symlink to /tmp/TZ.

comment:2 Changed 9 years ago by thomas@…

The script is broken in more ways:

1) There is a ntpd.config file in subversion which is not installed to /etc/config/, thus the variables timezone and zoneinfo do not exist, and the hotplug script aborts.

2) The script reads a zoneinfo variable which is not used.

As there is now a global timezone parameter for openwrt, it does not make sense to write the timzone every time ntpd is launched, as it is written by openwrt at boot time. Instead, no configuration should be parsed at all. The following should work I think:

case "${ACTION:-ifup}" in

ifup)

ps | grep -v 'grep' | grep -v '20-ntpd' | grep -q 'ntpd'
{

route -n 2>&- | grep -q '0.0.0.0' && {

/etc/init.d/ntpd start

}

}

;;
ifdown)

route -n 2>&- | grep '0.0.0.0' >&-
/etc/init.d/ntpd stop 2>&- >&-

;;

esac

Changed 9 years ago by thomas@…

fixed 20-ntpd file

comment:3 Changed 9 years ago by nbd

  • Resolution set to fixed
  • Status changed from new to closed

fixed in r12538

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.