1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-25 11:37:56 +00:00
freebsd/usr.sbin/xntpd/refclocks/rconfig
1994-09-29 23:04:24 +00:00

131 lines
4.0 KiB
Bash

#!/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;'`"
DEFSLOCAL="`egrep '^[ ]*DEFS_LOCAL[ ]*=' Config.local | sed 's/\([^#]*\)#.*$/\1/g; s/[ ]*DEFS_LOCAL[ ]*=//g; s/-D//g; s/[ ][ ]*/ /g; s/^ *//g; s/ *$//g;'`"
if [ ! "$REFCONF" ]; then
echo
echo "Current configuration"
echo
if check "$DEFSLOCAL" '$0 ~ /MCAST/'; then
echo "==> MULTICAST SUPPORT (if available)"
echo
fi
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
if (check "$REFCONF" '$0 ~ /MCAST/' ||
( [ ! "$REFCONF" ] && query "Do you want allow for multicast support (if available) ?" y)); then
MCAST="-DMCAST"
else
MCAST=""
fi
for i in $rcfg
do
sh $i config "$RCONFIG" "$PPSFEATURES" "$PPSOK" "$DEFS" "$REFCONF"
if [ "$PPSOK" -eq 1 ] && egrep -e '-D..*PPS' "$RCONFIG" >/dev/null 2>&1; then
PPSOK=0
fi
done
if egrep -e '-D..*PPS' "$RCONFIG" >/dev/null 2>&1; then
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"'/;' \
-e 's/^[ ]*DEFS_LOCAL[ ]*=.*$/DEFS_LOCAL= $(DEFS_OPT) '"$PPS $MCAST"'/;' \
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"
echo " DEFS_LOCAL="'$(DEFS_OPT)'" $PPS $MCAST"
echo
echo "Configuration updated"
else
echo "Configuration update FAILED"
fi
rm -f "$RCONFIG"
else
:;
fi
fi