freebsd-dev/usr.sbin/xntpd/refclocks/rconfig

131 lines
4.0 KiB
Plaintext
Raw Normal View History

1993-12-21 18:36:48 +00:00
#!/bin/sh -
#
# Refclock configuration script
#
# batch configuration options (optional arg 1)
# pps related
# PPS - general PPS support
# CLK - CLK line discipline or streams module
# CD - ppsclock or ppsclockd streams module
# LINE - dedicated line
PATH=refclocks:${PATH}
export PATH
RCONFIG=rconf
DLOCAL=dlocal
REFCONF=${1-""}
. refclocks/setup
rcfg="`echo refclocks/rclk.*`"
if [ "$rcfg" = "refclocks/rclk.*" ]; then
echo "no reference clock configuration information available"
else
config="`egrep '^[ ]*CLOCKDEFS[ ]*=' Config.local | sed 's/\([^#]*\)#.*$/\1/g; s/[ ]*CLOCKDEFS[ ]*=//g; s/-D//g; s/[ ][ ]*/ /g; s/^ *//g; s/ *$//g;'`"
DEFS="`egrep '^[ ]*DEFS[ ]*=' Config | sed 's/\([^#]*\)#.*$/\1/g; s/[ ]*DEFS[ ]*=//g; s/-D//g; s/[ ][ ]*/ /g; s/^ *//g; s/ *$//g;'`"
1994-09-29 23:04:24 +00:00
DEFSLOCAL="`egrep '^[ ]*DEFS_LOCAL[ ]*=' Config.local | sed 's/\([^#]*\)#.*$/\1/g; s/[ ]*DEFS_LOCAL[ ]*=//g; s/-D//g; s/[ ][ ]*/ /g; s/^ *//g; s/ *$//g;'`"
1993-12-21 18:36:48 +00:00
if [ ! "$REFCONF" ]; then
echo
echo "Current configuration"
echo
1994-09-29 23:04:24 +00:00
if check "$DEFSLOCAL" '$0 ~ /MCAST/'; then
echo "==> MULTICAST SUPPORT (if available)"
echo
fi
1993-12-21 18:36:48 +00:00
for i in $rcfg
do
sh $i check "$config" "" "" "$DEFS" "$REFCONF"
done
echo
fi
if [ "$REFCONF" ] || query "Change Configuration" n; then
if [ ! "$REFCONF" ]; then
echo
echo 'Available reference clock drivers'
for i in $rcfg
do
sh $i info "" "" "" "$DEFS" "$REFCONF"
done
echo
fi
:>"$RCONFIG"
PPS=""
PPSFEATURES=""
PPSOK=0
if check "$REFCONF" '$0 ~ /PLL/' ||
( [ ! "$REFCONF" ] && query "Include support for Kernel PLL" n); then
PPS="-DKERNEL_PLL $PPS"
fi
if check "$REFCONF" '$0 ~ /[^A-Za-z]PPS/' ||
( [ ! "$REFCONF" ] && query "Do you have a PPS (pulse per second) signal" n); then
if check "$DEFS" '$0 ~ /HAVE_BSD_TTYS|STREAM/' &&
(check "$REFCONF" '$0 ~ /CLK/' ||
( [ ! "$REFCONF" ] && query "Is the clk line discipline available" n)); then
PPSFEATURES="CLK"
else
if check "$DEFS" '$0 ~ /STREAM/' &&
(check "$REFCONF" '$0 ~ /CD/' ||
( [ ! "$REFCONF" ] && query "Is the ppsclock or ppsclocd STREAMS module available" n)); then
PPSFEATURES="CD $PPSFEATURES"
fi
fi
if check "$PPSFEATURES" '$0 ~ /CLK|CD/' &&
(check "$REFCONF" '$0 ~ /LINE/' ||
( [ ! "$REFCONF" ] && query "Do you want to use a dedicated serial port for PPS signal" n)); then
if check "$PPSFEATURES" '$0 ~ /CLK/'; then
PPS="-DPPSCLK $PPS"
fi
if check "$PPSFEATURES" '$0 ~ /CD/'; then
PPS="-DPPSCD $PPS"
fi
else
PPSOK=1
PPS="-DPPS $PPS"
fi
fi
1994-09-29 23:04:24 +00:00
if (check "$REFCONF" '$0 ~ /MCAST/' ||
( [ ! "$REFCONF" ] && query "Do you want allow for multicast support (if available) ?" y)); then
MCAST="-DMCAST"
else
MCAST=""
fi
1993-12-21 18:36:48 +00:00
for i in $rcfg
do
sh $i config "$RCONFIG" "$PPSFEATURES" "$PPSOK" "$DEFS" "$REFCONF"
1994-02-03 22:09:07 +00:00
if [ "$PPSOK" -eq 1 ] && egrep -e '-D..*PPS' "$RCONFIG" >/dev/null 2>&1; then
1993-12-21 18:36:48 +00:00
PPSOK=0
fi
done
1994-02-03 22:09:07 +00:00
if egrep -e '-D..*PPS' "$RCONFIG" >/dev/null 2>&1; then
1993-12-21 18:36:48 +00:00
PPS="-DPPSPPS $PPS"
fi
CLOCKDEFS="`tr '\012' ' ' < $RCONFIG`"
if check "$CLOCKDEFS" '$0 !~ /^[ ]*$/'; then
PPS="-DREFCLOCK $PPS"
if [ ! "$REFCONF" ]; then
echo
echo "Do not forget to set up the appropriate device links in the /dev directory"
echo
fi
fi
if sed -e 's/^[ ]*CLOCKDEFS[ ]*=.*$/CLOCKDEFS='"$CLOCKDEFS"'/;' \
1994-09-29 23:04:24 +00:00
-e 's/^[ ]*DEFS_LOCAL[ ]*=.*$/DEFS_LOCAL= $(DEFS_OPT) '"$PPS $MCAST"'/;' \
1993-12-21 18:36:48 +00:00
Config.local > Config.local.new; then
mv Config.local Config.local.old &&
mv Config.local.new Config.local &&
rm -f Config.local.old
echo
echo "New configuration defines:"
echo " CLOCKDEFS=$CLOCKDEFS"
1994-09-29 23:04:24 +00:00
echo " DEFS_LOCAL="'$(DEFS_OPT)'" $PPS $MCAST"
1993-12-21 18:36:48 +00:00
echo
echo "Configuration updated"
else
echo "Configuration update FAILED"
fi
rm -f "$RCONFIG"
else
:;
fi
fi