Skip to content

Commit

Permalink
Enable NTP flag (sonic-net#3)
Browse files Browse the repository at this point in the history
* Enable NTP flag

Signed-off-by: Maksym Hedeon <maksym@githedgehog.com>

* script fix

Signed-off-by: Maksym Hedeon <maksym@githedgehog.com>

Signed-off-by: Maksym Hedeon <maksym@githedgehog.com>
  • Loading branch information
Maksym Hedeon committed Feb 1, 2023
1 parent b258066 commit eb0476a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
22 changes: 19 additions & 3 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ echo '[INFO] Install docker'
## Install apparmor utils since they're missing and apparmor is enabled in the kernel
## Otherwise Docker will fail to start
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install apparmor
if [ $INCLUDE_NTP == y ]; then
sudo cp files/image_config/ntp/ntp-apparmor $FILESYSTEM_ROOT/etc/apparmor.d/local/usr.sbin.ntpd
fi
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install apt-transport-https \
ca-certificates \
curl \
Expand Down Expand Up @@ -288,6 +290,11 @@ SYSLOG_PACKAGE=""
if [ $INCLUDE_SYSLOG == y ]; then
SYSLOG_PACKAGE=rsyslog
fi
NTPSTAT_PACKAGE=""
if [ $INCLUDE_NTP == y ]; then
NTPSTAT_PACKAGE=ntpstat
fi

## Pre-install the fundamental packages
## Note: gdisk is needed for sgdisk in install.sh
## Note: parted is needed for partprobe in install.sh
Expand All @@ -304,7 +311,7 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
vim \
tcpdump \
dbus \
ntpstat \
$NTPSTAT_PACKAGE \
openssh-server \
python3-apt \
traceroute \
Expand Down Expand Up @@ -385,11 +392,16 @@ sudo sed -i '/^#.* en_US.* /s/^#//' $FILESYSTEM_ROOT/etc/locale.gen && \
sudo LANG=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT update-locale "LANG=en_US.UTF-8"
sudo LANG=C chroot $FILESYSTEM_ROOT bash -c "find /usr/share/i18n/locales/ ! -name 'en_US' -type f -exec rm -f {} +"

NTP_PACKAGE=""
if [ $INCLUDE_NTP == y ]; then
NTP_PACKAGE=ntpstat
fi

sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install \
picocom \
systemd \
systemd-sysv \
ntp
$NTP_PACKAGE \
systemd-sysv

if [[ $CONFIGURED_ARCH == amd64 ]]; then
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y download \
Expand Down Expand Up @@ -497,14 +509,18 @@ sudo cp files/dhcp/sethostname6 $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/
sudo cp files/dhcp/graphserviceurl $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/
sudo cp files/dhcp/snmpcommunity $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/
sudo cp files/dhcp/vrf $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/
if [ $INCLUDE_NTP == y ]; then
if [ -f files/image_config/ntp/ntp ]; then
sudo cp ./files/image_config/ntp/ntp $FILESYSTEM_ROOT/etc/init.d/
fi
fi

if [ $INCLUDE_NTP == y ]; then
if [ -f files/image_config/ntp/ntp-systemd-wrapper ]; then
sudo mkdir -p $FILESYSTEM_ROOT/usr/lib/ntp/
sudo cp ./files/image_config/ntp/ntp-systemd-wrapper $FILESYSTEM_ROOT/usr/lib/ntp/
fi
fi

## Version file
sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic
Expand Down
4 changes: 4 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ sudo mkdir -p $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/ifupdown2_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f

{% if include_ntp == "y" %}
# Install a patched version of ntp (and its dependencies via 'apt-get -y install -f')
sudo dpkg --root=$FILESYSTEM_ROOT --force-confdef --force-confold -i $debs_path/ntp_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install -f
{% endif %}

# Install dependencies for SONiC config engine
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install \
Expand Down Expand Up @@ -348,6 +350,7 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/flashrom_*.deb
# Copy crontabs
sudo cp -f $IMAGE_CONFIGS/cron.d/* $FILESYSTEM_ROOT/etc/cron.d/

{% if include_ntp == "y" %}
# Copy NTP configuration files and templates
sudo cp $IMAGE_CONFIGS/ntp/ntp-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
echo "ntp-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
Expand All @@ -356,6 +359,7 @@ sudo cp $IMAGE_CONFIGS/ntp/ntp.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATE
sudo cp $IMAGE_CONFIGS/ntp/ntp-systemd-wrapper $FILESYSTEM_ROOT/usr/lib/ntp/
sudo cp $IMAGE_CONFIGS/ntp/ntp.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
echo "ntp.service" | sudo tee -a $GENERATED_SERVICE_FILE
{% endif %}

# Copy warmboot-finalizer files
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/finalize-warmboot.sh $FILESYSTEM_ROOT/usr/local/bin/finalize-warmboot.sh
Expand Down
6 changes: 6 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,9 @@ INCLUDE_SYSLOG = y

# INCLUDE_RADIUS - build and install radius package
INCLUDE_RADIUS = y
# INCLUDE_NTP:
# * build ntp_*.deb from src/ntp
# * install ntp_*.deb
# * install ntp/ntpstat (build_debian.sh)
# * copy files from files/image_config/ntp (build_debian.sh, sonic_debian_extension.sh)
INCLUDE_NTP = y
2 changes: 2 additions & 0 deletions rules/ntp.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ntp package

ifeq ($(INCLUDE_NTP), y)
NTP_VERSION = 4.2.8p15+dfsg
export NTP_VERSION

Expand All @@ -9,3 +10,4 @@ SONIC_MAKE_DEBS += $(NTP)
SONIC_STRETCH_DEBS += $(NTP)

export NTP
endif
2 changes: 2 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ $(info "INCLUDE_MACSEC" : "$(INCLUDE_MACSEC)")
$(info "INCLUDE_MUX" : "$(INCLUDE_MUX)")
$(info "INCLUDE_SYSLOG" : "$(INCLUDE_SYSLOG)")
$(info "INCLUDE_RADIUS" : "$(INCLUDE_RADIUS)")
$(info "INCLUDE_NTP" : "$(INCLUDE_NTP)")
$(info "TELEMETRY_WRITABLE" : "$(TELEMETRY_WRITABLE)")
$(info "ENABLE_AUTO_TECH_SUPPORT" : "$(ENABLE_AUTO_TECH_SUPPORT)")
$(info "PDDF_SUPPORT" : "$(PDDF_SUPPORT)")
Expand Down Expand Up @@ -1034,6 +1035,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export include_radius="$(INCLUDE_RADIUS)"
export enable_auto_tech_support="$(ENABLE_AUTO_TECH_SUPPORT)"
export include_macsec="$(INCLUDE_MACSEC)"
export include_ntp="$(INCLUDE_NTP)"
export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)"
export include_iccpd="$(INCLUDE_ICCPD)"
export pddf_support="$(PDDF_SUPPORT)"
Expand Down

0 comments on commit eb0476a

Please sign in to comment.