mirror of
https://github.com/openwrt/packages.git
synced 2026-12-03 07:05:31 +04:00
- ptp4l.init: bound wait_disciplined with clock_sync_max_tries (default 8 attempts, ~2 min) so a server-role device with no time source does not stall rcS indefinitely; set to 0 to wait without limit - ptp4l.init: validate that at least one [interface] section was written to ptp4l.conf (by counting section headers); a config with only [global] is now rejected with a clear error rather than launching ptp4l into a respawn loop - phc2sys.init: require phc_device to be explicitly configured; removes the /dev/ptp0 default so phc2sys does not auto-start on upgrade and slew CLOCK_REALTIME from an undisciplined PHC - linuxptp.config: comment out the config ptp_interface section header so the shipped default contains no load-bearing anonymous section; validation is now in the init script rather than the config structure - linuxptp.config: comment out phc_device so both daemons require explicit admin opt-in before starting - linuxptp.config: document clock_sync_max_tries option Signed-off-by: Aleks Mariusz <a+git-commit@alek.cx>
74 lines
1.7 KiB
Bash
74 lines
1.7 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
# Init script for phc2sys from linuxptp
|
|
|
|
START=55
|
|
USE_PROCD=1
|
|
PROG=/usr/sbin/phc2sys
|
|
|
|
ID=phc2sys
|
|
ID_PTP4L=ptp4l
|
|
|
|
log() {
|
|
local loglevel=$1; shift; local msg="$*"
|
|
logger -t phc2sys-init -p daemon.$loglevel "$msg"
|
|
}
|
|
|
|
make_cmdline() {
|
|
local cfg=$1
|
|
local args dev dir loglevel ptp4l_role stats_set syncdir
|
|
|
|
echo $PROG
|
|
|
|
config_get dev $cfg "phc_device" ""
|
|
[ -z "$dev" ] && { log err "phc_device not configured. Set 'option phc_device' in /etc/config/linuxptp."; return 1; }
|
|
! [ -c "$dev" ] && { log crit "PHC device '$dev' not found!"; return 1; }
|
|
|
|
dir='phc_to_sys'
|
|
config_get ptp4l_role $ID_PTP4L "role" "auto"
|
|
[ "$ptp4l_role" = "server" ] && dir='sys_to_phc'
|
|
|
|
config_get syncdir $cfg "sync_direction" "$dir"
|
|
if [ "$syncdir" = "phc_to_sys" ]; then
|
|
echo "-s $dev -w"
|
|
elif [ "$syncdir" = "sys_to_phc" ]; then
|
|
echo "-s CLOCK_REALTIME -c $dev -w -O 0"
|
|
else
|
|
log err "Invalid sync_direction '$syncdir'! valid values: 'sys_to_phc', 'phc_to_sys'"; return 1
|
|
fi
|
|
|
|
echo "-m"
|
|
echo "-q"
|
|
|
|
config_get stats_set $cfg "stats_interval" "0"
|
|
[ "$stats_set" -ge 1 ] && echo "-u $stats_set"
|
|
|
|
config_get loglevel $cfg "loglevel" "5"
|
|
[ "$stats_set" -ge 1 ] && config_get loglevel $cfg "loglevel" "6"
|
|
echo "-l $loglevel"
|
|
|
|
config_list_foreach $cfg "extra_args" echo
|
|
}
|
|
|
|
service_triggers() {
|
|
procd_add_reload_trigger "linuxptp"
|
|
}
|
|
|
|
start_service() {
|
|
local cmdline
|
|
|
|
config_load linuxptp
|
|
|
|
cmdline=$(make_cmdline $ID) || return 1
|
|
log info "Starting phc2sys: $cmdline"
|
|
|
|
procd_open_instance phc2sys
|
|
procd_set_param command $cmdline
|
|
procd_set_param stdout 1
|
|
procd_set_param stderr 1
|
|
procd_close_instance
|
|
}
|
|
|
|
stop_service() {
|
|
log info "phc2sys exiting (if running)."
|
|
}
|