Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 3 additions & 68 deletions source/scripts/init/service.d/service_ntpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ NTP_CONF_TMP=/tmp/ntp.conf
NTP_CONF_QUICK_SYNC=/tmp/ntp_quick_sync.conf
LOCKFILE=/var/tmp/service_ntpd.pid
BIN=ntpd
WAN_IPv6_UP=0
QUICK_SYNC_PID=""
QUICK_SYNC_DONE=0

Expand Down Expand Up @@ -171,33 +170,7 @@ wan_wait ()
#Make sure WAN interface has an IPv4 or IPv6 address before telling NTP to listen on Interface
WAN_IPv4=`ifconfig -a "$WAN_INTERFACE" | grep inet | grep -v inet6 | tr -s " " | cut -d ":" -f2 | cut -d " " -f1 | head -n1`

if [ "$BOX_TYPE" = "HUB4" ] || [ "$BOX_TYPE" = "SR300" ] || [ "$BOX_TYPE" = "SE501" ] || [ "$BOX_TYPE" = "SR213" ] || [ "$BOX_TYPE" = "WNXL11BWL" ] || [ "$LANIPV6Support" = "true" ]; then
CURRENT_WAN_IPV6_STATUS=`sysevent get ipv6_connection_state`
if [ "up" = "$CURRENT_WAN_IPV6_STATUS" ] ; then
ULAprefix=`sysevent get ula_address |cut -d ':' -f1`
if [ -z "$ULAprefix" ]; then
WAN_IPv6=`ifconfig "$NTPD_IPV6_INTERFACE" | grep inet6 | grep Global | awk '/inet6/{print $3}' | grep -v 'fdd7' | cut -d '/' -f1 | head -n1`
else
WAN_IPv6=`ifconfig "$NTPD_IPV6_INTERFACE" | grep inet6 | grep Global | awk '/inet6/{print $3}' | grep -v 'fdd7' | grep -v "$ULAprefix" | cut -d '/' -f1 | head -n1`
fi
WAN_IPv6_UP=1
# SHARMAN-2301
#This change is for UK MAP-T SR213. When NTP servers are IPv4 only and there is no IPv4 WAN IP on the interface we will use $NTPD_IPV6_INTERFACE(currently brlan0) ipv4 ip to sort ntpd daemon socket problems and routing.
if [ "$BOX_TYPE" = "SR213" ] || [ "$LANIPV6Support" == "true" ]; then
MAPT_STATS=$(sysevent get mapt_config_flag)
echo_t "SERVICE_NTPD : MAPT_STATS=$MAPT_STATS"
if [ x"$MAPT_STATS" = x"set" ]; then
IPV4_CONN_STATE=$(sysevent get ipv4_connection_state)
echo_t "SERVICE_NTPD : IPV4_CONN_STATE=$IPV4_CONN_STATE"
if [ x"$IPV4_CONN_STATE" != x"up" ]; then
WAN_IPv4=`ifconfig "$NTPD_IPV6_INTERFACE" | grep inet\ \addr | cut -d ':' -f2 |cut -d ' ' -f1`
fi
fi
fi
fi
else
WAN_IPv6=`ifconfig "$WAN_INTERFACE" | grep inet6 | grep Global | awk '/inet6/{print $3}' | cut -d '/' -f1 | head -n1`
fi
WAN_IPv6=`ifconfig "$WAN_INTERFACE" | grep inet6 | grep Global | awk '/inet6/{print $3}' | cut -d '/' -f1 | head -n1`

if [ -n "$WAN_IPv4" ] || [ -n "$WAN_IPv6" ]; then
if [ "$2" = "quickSync" ];then
Expand Down Expand Up @@ -572,19 +545,6 @@ service_start ()
echo "interface ignore wildcard" >> $NTP_CONF_TMP
echo "interface listen 127.0.0.1" >> $NTP_CONF_TMP
echo "interface listen ::1" >> $NTP_CONF_TMP
#SHARMAN-2301
#This change is for UK MAP-T SR213. Since we will not have any of the global IP on WAN interface, We need to add the IPv6 interface (currently brlan0) to the config file
if [ "$BOX_TYPE" = "SR213" ] || [ "$LANIPV6Support" = "true" ]; then
MAPT_STATS=$(sysevent get mapt_config_flag)
echo_t "SERVICE_NTPD : MAPT_STATS=$MAPT_STATS"
if [ x"$MAPT_STATS" = x"set" ]; then
IPV4_CONN_STATE=$(sysevent get ipv4_connection_state)
echo_t "SERVICE_NTPD : IPV4_CONN_STATE=$IPV4_CONN_STATE"
if [ x"$IPV4_CONN_STATE" != x"up" ]; then
echo "interface listen $NTPD_IPV6_INTERFACE" >> $NTP_CONF_TMP
fi
fi
fi

if [ -n "$WAN_IP" ]; then
echo "interface listen $WAN_IP" >> $NTP_CONF_TMP
Expand All @@ -593,21 +553,6 @@ service_start ()
fi
fi

if [ "$BOX_TYPE" = "HUB4" ] || [ "$BOX_TYPE" = "SR300" ] || [ "$BOX_TYPE" = "SE501" ] || [ "$BOX_TYPE" = "SR213" ] || [ "$BOX_TYPE" = "WNXL11BWL" ] || [ "$LANIPV6Support" = "true" ]; then
# SKYH4-2006: To listen v6 server, update the conf file after getting valid v6 IP(CURRENT_WAN_V6_PREFIX)
CURRENT_WAN_IPV6_STATUS=`sysevent get ipv6_connection_state`

if [ "up" = "$CURRENT_WAN_IPV6_STATUS" ] ; then
CURRENT_WAN_V6_PREFIX=`syscfg get ipv6_prefix_address`
if [ -n "$CURRENT_WAN_V6_PREFIX" ]; then
echo "interface listen $CURRENT_WAN_V6_PREFIX" >> $NTP_CONF_TMP
sysevent set ntp_ipv6_listen "set"
else
sysevent set ntp_ipv6_listen "unset"
fi
fi
fi

if [ "$MULTI_CORE" = "yes" ] && [ "$NTPD_IMMED_PEER_SYNC" != "true" ]; then
echo "interface listen $HOST_INTERFACE_IP" >> $NTP_CONF_TMP
fi
Expand All @@ -630,18 +575,8 @@ service_start ()
uptime_ms=$((uptime*1000))
echo_t "SERVICE_NTPD : Starting NTP Quick Sync" >> $NTPD_LOG_NAME
t2ValNotify "SYS_INFO_NTPSTART_split" $uptime_ms
if [ "$BOX_TYPE" = "HUB4" ] || [ "$BOX_TYPE" = "SR300" ] || [ "$BOX_TYPE" = "SE501" ] || [ "$BOX_TYPE" = "SR213" ] || [ "$BOX_TYPE" = "WNXL11BWL" ] || [ "$ntpHealthCheck" = "true" ]; then
if [ $WAN_IPv6_UP -eq 1 ]; then
$BIN -c $NTP_CONF_QUICK_SYNC --interface "$QUICK_SYNC_WAN_IP" -x -gq -l $NTPD_LOG_NAME &
QUICK_SYNC_PID=$!
else
$BIN -c $NTP_CONF_QUICK_SYNC --interface "$QUICK_SYNC_WAN_IP" -x -gq -4 -l $NTPD_LOG_NAME &
QUICK_SYNC_PID=$!
fi
else
$BIN -c $NTP_CONF_QUICK_SYNC --interface "$QUICK_SYNC_WAN_IP" -x -gq -l $NTPD_LOG_NAME &
QUICK_SYNC_PID=$!
fi
$BIN -c $NTP_CONF_QUICK_SYNC --interface "$QUICK_SYNC_WAN_IP" -x -gq -l $NTPD_LOG_NAME &
QUICK_SYNC_PID=$!
if [ -n "$QUICK_SYNC_PID" ];then
set_ntp_quicksync_status
fi
Expand Down
Loading