2017-01-29 13:33:33 -06:00
|
|
|
#!/bin/bash
|
|
|
|
## This script is to automate loading of vendor specific docker images
|
|
|
|
## and instalation of configuration files and vendor specific packages
|
|
|
|
## to debian file system.
|
|
|
|
##
|
|
|
|
## USAGE:
|
2017-02-27 15:08:41 -06:00
|
|
|
## ./sonic_debian_extension.sh FILESYSTEM_ROOT PLATFORM_DIR
|
2017-01-29 13:33:33 -06:00
|
|
|
## PARAMETERS:
|
|
|
|
## FILESYSTEM_ROOT
|
|
|
|
## Path to debian file system root directory
|
|
|
|
|
|
|
|
FILESYSTEM_ROOT=$1
|
|
|
|
[ -n "$FILESYSTEM_ROOT" ] || {
|
|
|
|
echo "Error: no or empty FILESYSTEM_ROOT argument"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-02-27 15:08:41 -06:00
|
|
|
PLATFORM_DIR=$2
|
|
|
|
[ -n "$PLATFORM_DIR" ] || {
|
|
|
|
echo "Error: no or empty PLATFORM_DIR argument"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
## Enable debug output for script
|
|
|
|
set -x -e
|
|
|
|
|
|
|
|
. functions.sh
|
|
|
|
BUILD_TEMPLATES=files/build_templates
|
|
|
|
IMAGE_CONFIGS=files/image_config
|
2018-08-22 15:02:32 -05:00
|
|
|
SCRIPTS_DIR=files/scripts
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2018-02-27 14:15:56 -06:00
|
|
|
# Define target fold macro
|
|
|
|
FILESYSTEM_ROOT_USR="$FILESYSTEM_ROOT/usr"
|
|
|
|
FILESYSTEM_ROOT_USR_SHARE="$FILESYSTEM_ROOT_USR/share"
|
|
|
|
FILESYSTEM_ROOT_USR_SHARE_SONIC="$FILESYSTEM_ROOT_USR_SHARE/sonic"
|
|
|
|
FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES="$FILESYSTEM_ROOT_USR_SHARE_SONIC/templates"
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
clean_sys() {
|
|
|
|
sudo umount $FILESYSTEM_ROOT/sys/fs/cgroup/* \
|
|
|
|
$FILESYSTEM_ROOT/sys/fs/cgroup \
|
|
|
|
$FILESYSTEM_ROOT/sys || true
|
|
|
|
}
|
|
|
|
trap_push clean_sys
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT mount sysfs /sys -t sysfs
|
|
|
|
|
2019-01-04 22:47:43 -06:00
|
|
|
sudo bash -c "echo \"DOCKER_OPTS=\"--storage-driver=overlay2\"\" >> $FILESYSTEM_ROOT/etc/default/docker"
|
|
|
|
sudo cp files/docker/docker $FILESYSTEM_ROOT/etc/init.d/
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo chroot $FILESYSTEM_ROOT service docker start
|
|
|
|
|
|
|
|
# Apply apt configuration files
|
|
|
|
sudo cp $IMAGE_CONFIGS/apt/sources.list $FILESYSTEM_ROOT/etc/apt/
|
|
|
|
sudo cp -R $IMAGE_CONFIGS/apt/sources.list.d/ $FILESYSTEM_ROOT/etc/apt/
|
|
|
|
cat $IMAGE_CONFIGS/apt/sonic-dev.gpg.key | sudo LANG=C chroot $FILESYSTEM_ROOT apt-key add -
|
|
|
|
|
2017-02-27 02:13:36 -06:00
|
|
|
# Update apt's snapshot of its repos
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get update
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Apply environtment configuration files
|
|
|
|
sudo cp $IMAGE_CONFIGS/environment/environment $FILESYSTEM_ROOT/etc/
|
|
|
|
sudo cp $IMAGE_CONFIGS/environment/motd $FILESYSTEM_ROOT/etc/
|
|
|
|
|
2017-02-27 02:13:36 -06:00
|
|
|
# Create all needed directories
|
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic/
|
2018-11-21 10:08:37 -06:00
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/etc/modprobe.d/
|
2018-07-06 04:50:42 -05:00
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/var/cache/sonic/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2017-02-27 02:13:36 -06:00
|
|
|
|
2018-11-20 21:27:56 -06:00
|
|
|
# Install dependencies for SONiC config engine
|
2017-02-27 02:13:36 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install \
|
2017-03-17 16:51:42 -05:00
|
|
|
python-dev \
|
2017-02-27 02:13:36 -06:00
|
|
|
python-lxml \
|
2017-03-17 16:51:42 -05:00
|
|
|
python-yaml \
|
|
|
|
python-bitarray
|
2017-02-27 02:13:36 -06:00
|
|
|
|
2017-04-04 01:56:15 -05:00
|
|
|
# Install SONiC config engine Python package
|
|
|
|
CONFIG_ENGINE_WHEEL_NAME=$(basename {{config_engine_wheel_path}})
|
|
|
|
sudo cp {{config_engine_wheel_path}} $FILESYSTEM_ROOT/$CONFIG_ENGINE_WHEEL_NAME
|
2017-12-24 01:34:15 -06:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $CONFIG_ENGINE_WHEEL_NAME
|
2017-04-04 01:56:15 -05:00
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$CONFIG_ENGINE_WHEEL_NAME
|
2017-03-23 14:18:52 -05:00
|
|
|
|
|
|
|
# Install Python client for Redis
|
2018-11-19 14:03:15 -06:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install "redis==2.10.6"
|
2018-11-20 21:27:56 -06:00
|
|
|
|
|
|
|
# Install redis-dump-load Python 2 package
|
|
|
|
REDIS_DUMP_LOAD_PY2_WHEEL_NAME=$(basename {{redis_dump_load_py2_wheel_path}})
|
|
|
|
sudo cp {{redis_dump_load_py2_wheel_path}} $FILESYSTEM_ROOT/$REDIS_DUMP_LOAD_PY2_WHEEL_NAME
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $REDIS_DUMP_LOAD_PY2_WHEEL_NAME
|
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$REDIS_DUMP_LOAD_PY2_WHEEL_NAME
|
2017-02-27 02:13:36 -06:00
|
|
|
|
2017-04-04 01:56:15 -05:00
|
|
|
# Install SwSS SDK Python 2 package
|
|
|
|
SWSSSDK_PY2_WHEEL_NAME=$(basename {{swsssdk_py2_wheel_path}})
|
|
|
|
sudo cp {{swsssdk_py2_wheel_path}} $FILESYSTEM_ROOT/$SWSSSDK_PY2_WHEEL_NAME
|
2017-12-24 01:34:15 -06:00
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $SWSSSDK_PY2_WHEEL_NAME
|
2017-04-04 01:56:15 -05:00
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$SWSSSDK_PY2_WHEEL_NAME
|
|
|
|
|
2018-01-17 19:11:31 -06:00
|
|
|
# Install sonic-platform-common Python 2 package
|
|
|
|
PLATFORM_COMMON_PY2_WHEEL_NAME=$(basename {{platform_common_py2_wheel_path}})
|
|
|
|
sudo cp {{platform_common_py2_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2_WHEEL_NAME
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install $PLATFORM_COMMON_PY2_WHEEL_NAME
|
|
|
|
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2_WHEEL_NAME
|
|
|
|
|
2018-06-29 11:59:46 -05:00
|
|
|
# Install built Python Click package (and its dependencies via 'apt-get -y install -f')
|
|
|
|
# Do this before installing sonic-utilities so that it doesn't attempt to install
|
|
|
|
# an older version as part of its dependencies
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i target/debs/python-click*_all.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
|
2018-08-15 23:41:12 -05:00
|
|
|
# Install python pexpect used by sonic-utilities consutil
|
|
|
|
# using pip install instead to get a more recent version than is available through debian
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install pexpect
|
|
|
|
|
2018-10-08 20:36:37 -05:00
|
|
|
# Install tabulate >= 0.8.1 via pip in order to support multi-line row output for sonic-utilities
|
|
|
|
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip install tabulate==0.8.2
|
|
|
|
|
2017-10-06 14:46:47 -05:00
|
|
|
# Install SONiC Utilities (and its dependencies via 'apt-get -y install -f')
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i target/debs/python-sonic-utilities_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
2017-02-27 02:13:36 -06:00
|
|
|
|
2017-03-02 14:17:04 -06:00
|
|
|
# SONiC utilities installs bash-completion as a dependency. However, it is disabled by default
|
|
|
|
# in bash.bashrc, so we copy a version of the file with it enabled here.
|
|
|
|
sudo cp -f $IMAGE_CONFIGS/bash/bash.bashrc $FILESYSTEM_ROOT/etc/
|
|
|
|
|
2017-02-27 02:13:36 -06:00
|
|
|
# Install SONiC Device Data (and its dependencies via 'apt-get -y install -f')
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i target/debs/sonic-device-data_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
|
2017-12-07 05:36:17 -06:00
|
|
|
# Install pam-tacplus and nss-tacplus
|
2017-12-11 13:05:03 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i target/debs/libtac2_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i target/debs/libpam-tacplus_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i target/debs/libnss-tacplus_*.deb || \
|
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
2017-12-07 05:36:17 -06:00
|
|
|
# Disable tacplus by default
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT pam-auth-update --remove tacplus
|
|
|
|
sudo sed -i -e '/^passwd/s/ tacplus//' $FILESYSTEM_ROOT/etc/nsswitch.conf
|
|
|
|
|
2017-04-21 10:22:44 -05:00
|
|
|
# Copy crontabs
|
|
|
|
sudo cp -f $IMAGE_CONFIGS/cron.d/* $FILESYSTEM_ROOT/etc/cron.d/
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy NTP configuration files and templates
|
|
|
|
sudo cp $IMAGE_CONFIGS/ntp/ntp-config.service $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable ntp-config.service
|
|
|
|
sudo cp $IMAGE_CONFIGS/ntp/ntp-config.sh $FILESYSTEM_ROOT/usr/bin/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/ntp/ntp.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2019-04-01 16:16:31 -05:00
|
|
|
# Copy warmboot-finalizer files
|
|
|
|
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/finalize-warmboot.sh $FILESYSTEM_ROOT/usr/local/bin/finalize-warmboot.sh
|
|
|
|
sudo LANG=C cp $IMAGE_CONFIGS/warmboot-finalizer/warmboot-finalizer.service $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable warmboot-finalizer.service
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy rsyslog configuration files and templates
|
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.service $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable rsyslog-config.service
|
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/
|
|
|
|
|
2017-04-21 10:22:44 -05:00
|
|
|
# Copy logrotate.d configuration files
|
2017-08-10 18:24:57 -05:00
|
|
|
sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate.d/
|
2017-04-21 10:22:44 -05:00
|
|
|
|
|
|
|
# Copy systemd-journald configuration files
|
|
|
|
sudo cp -f $IMAGE_CONFIGS/systemd/journald.conf $FILESYSTEM_ROOT/etc/systemd/
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy interfaces configuration files and templates
|
|
|
|
sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.service $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable interfaces-config.service
|
|
|
|
sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.sh $FILESYSTEM_ROOT/usr/bin/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2017-02-17 15:47:01 -06:00
|
|
|
# Copy initial interfaces configuration file, will be overwritten on first boot
|
2018-11-27 16:35:17 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/interfaces/init_interfaces $FILESYSTEM_ROOT/etc/network/interfaces
|
2017-02-17 15:47:01 -06:00
|
|
|
|
2017-12-12 05:45:44 -06:00
|
|
|
# Copy hostcfgd files
|
|
|
|
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd.service $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable hostcfgd.service
|
|
|
|
sudo cp $IMAGE_CONFIGS/hostcfgd/hostcfgd $FILESYSTEM_ROOT/usr/bin/
|
2018-02-27 14:15:56 -06:00
|
|
|
sudo cp $IMAGE_CONFIGS/hostcfgd/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
|
|
|
|
|
|
|
# Copy the buffer configuration template
|
|
|
|
sudo cp $BUILD_TEMPLATES/buffers_config.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
2017-12-12 05:45:44 -06:00
|
|
|
|
2018-10-17 16:10:34 -05:00
|
|
|
# Copy the qos configuration template
|
|
|
|
sudo cp $BUILD_TEMPLATES/qos_config.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
|
|
|
|
|
2017-11-22 16:36:25 -06:00
|
|
|
# Copy hostname configuration scripts
|
|
|
|
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.service $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable hostname-config.service
|
|
|
|
sudo cp $IMAGE_CONFIGS/hostname/hostname-config.sh $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
|
2017-02-17 15:47:01 -06:00
|
|
|
# Copy updategraph script and service file
|
2018-07-23 17:51:03 -05:00
|
|
|
j2 files/build_templates/updategraph.service.j2 | sudo tee $FILESYSTEM_ROOT/etc/systemd/system/updategraph.service
|
2017-02-17 15:47:01 -06:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable updategraph.service
|
|
|
|
sudo cp $IMAGE_CONFIGS/updategraph/updategraph $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
{% if enable_dhcp_graph_service == "y" %}
|
|
|
|
sudo bash -c "echo enabled=true > $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
|
|
|
sudo bash -c "echo src=dhcp >> $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
|
|
|
sudo bash -c "echo dhcp_as_static=true >> $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
|
|
|
{% else %}
|
|
|
|
sudo bash -c "echo enabled=false > $FILESYSTEM_ROOT/etc/sonic/updategraph.conf"
|
|
|
|
{% endif %}
|
2018-03-27 15:37:02 -05:00
|
|
|
sudo bash -c "echo '{ \"DEVICE_METADATA\": { \"localhost\": { \"default_bgp_status\": {% if shutdown_bgp_on_start == "y" %}\"down\"{% else %}\"up\"{% endif %}, \"default_pfcwd_status\": {% if enable_pfcwd_on_start == "y" %}\"enable\"{% else %}\"disable\"{% endif %} } },
|
|
|
|
{%- print ' \\"CRM\\": { \\"Config\\": { \\"polling_interval\\": \\"300\\", ' %}
|
|
|
|
{%- for crm_res in ["ipv4_route", "ipv6_route", "ipv4_nexthop", "ipv6_nexthop", "ipv4_neighbor", "ipv6_neighbor", "nexthop_group_member", "nexthop_group", "acl_table", "acl_group", "acl_entry", "acl_counter", "fdb_entry"] -%}
|
|
|
|
\"{{crm_res}}_threshold_type\": \"percentage\", \"{{crm_res}}_low_threshold\": \"70\", \"{{crm_res}}_high_threshold\": \"85\"{% if not loop.last %}, {% endif %}
|
|
|
|
{%- endfor %} } } }' >> $FILESYSTEM_ROOT/etc/sonic/init_cfg.json"
|
2018-03-06 01:55:37 -06:00
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy SNMP configuration files
|
|
|
|
sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/
|
|
|
|
|
2017-06-21 20:52:50 -05:00
|
|
|
# Copy ASN configuration files
|
|
|
|
sudo cp $IMAGE_CONFIGS/asn/deployment_id_asn_map.yml $FILESYSTEM_ROOT/etc/sonic/
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
# Copy sudoers configuration file
|
|
|
|
sudo cp $IMAGE_CONFIGS/sudoers/sudoers $FILESYSTEM_ROOT/etc/
|
2018-06-21 12:41:50 -05:00
|
|
|
sudo cp $IMAGE_CONFIGS/sudoers/sudoers.lecture $FILESYSTEM_ROOT/etc/
|
2017-01-29 13:33:33 -06:00
|
|
|
|
2018-01-09 19:55:10 -06:00
|
|
|
# Copy control plane ACL management daemon files
|
|
|
|
sudo cp $IMAGE_CONFIGS/caclmgrd/caclmgrd.service $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable caclmgrd.service
|
|
|
|
sudo cp $IMAGE_CONFIGS/caclmgrd/caclmgrd $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
|
2017-02-10 09:39:05 -06:00
|
|
|
## Install package without starting service
|
|
|
|
## ref: https://wiki.debian.org/chroot
|
|
|
|
sudo tee -a $FILESYSTEM_ROOT/usr/sbin/policy-rc.d > /dev/null <<EOF
|
|
|
|
#!/bin/sh
|
|
|
|
exit 101
|
|
|
|
EOF
|
|
|
|
sudo chmod a+x $FILESYSTEM_ROOT/usr/sbin/policy-rc.d
|
|
|
|
|
2017-02-27 15:08:41 -06:00
|
|
|
{% if installer_debs.strip() -%}
|
2017-01-29 13:33:33 -06:00
|
|
|
{% for deb in installer_debs.strip().split(' ') -%}
|
2017-04-03 21:13:29 -05:00
|
|
|
{% if sonic_asic_platform == "mellanox" %}
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo dpkg --extract {{deb}} $FILESYSTEM_ROOT
|
2017-04-03 21:13:29 -05:00
|
|
|
{% else %}
|
2017-02-10 09:39:05 -06:00
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i {{deb}} || sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
|
2017-04-03 21:13:29 -05:00
|
|
|
{% endif %}
|
2017-01-29 13:33:33 -06:00
|
|
|
{% endfor %}
|
2017-02-27 15:08:41 -06:00
|
|
|
{% endif %}
|
2017-02-10 09:39:05 -06:00
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
## Run depmod command for target kernel modules
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT depmod -a {{kversion}}
|
2017-02-27 15:08:41 -06:00
|
|
|
|
|
|
|
## download all dependency packages for platform debian packages
|
|
|
|
{% if lazy_installer_debs.strip() -%}
|
|
|
|
{% for file in lazy_installer_debs.strip().split(' ') -%}
|
|
|
|
|
|
|
|
{% set dev = file.split('@')[0] -%}
|
|
|
|
{% set deb = file.split('@')[1] -%}
|
|
|
|
{% set debfilename = deb.split('/')|last -%}
|
|
|
|
{% set debname = debfilename.split('_')|first -%}
|
|
|
|
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -i {{deb}} || sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f --download-only
|
|
|
|
|
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}
|
|
|
|
sudo cp {{ deb }} $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/
|
2017-04-04 01:56:15 -05:00
|
|
|
for f in $(find $FILESYSTEM_ROOT/var/cache/apt/archives -name "*.deb"); do
|
2017-02-27 15:08:41 -06:00
|
|
|
sudo mv $f $FILESYSTEM_ROOT/$PLATFORM_DIR/{{dev}}/
|
|
|
|
done
|
|
|
|
|
|
|
|
sudo dpkg --root=$FILESYSTEM_ROOT -P {{ debname }}
|
|
|
|
|
|
|
|
{% endfor %}
|
2017-01-29 13:33:33 -06:00
|
|
|
{% endif %}
|
2017-02-27 15:08:41 -06:00
|
|
|
|
|
|
|
sudo rm -f $FILESYSTEM_ROOT/usr/sbin/policy-rc.d
|
|
|
|
|
2018-11-23 19:06:23 -06:00
|
|
|
## Revise /etc/init.d/networking and /lib/systemd/system/networking.service for Arista switches
|
2017-10-30 20:04:40 -05:00
|
|
|
if [ "$image_type" = "aboot" ]; then
|
|
|
|
sudo sed -i 's/udevadm settle/udevadm settle -E \/sys\/class\/net\/eth0/' $FILESYSTEM_ROOT/etc/init.d/networking
|
2018-11-23 19:06:23 -06:00
|
|
|
sudo sed -i 's/udevadm settle/udevadm settle -E \/sys\/class\/net\/eth0/' $FILESYSTEM_ROOT/lib/systemd/system/networking.service
|
2017-10-30 20:04:40 -05:00
|
|
|
fi
|
|
|
|
|
2017-02-27 15:08:41 -06:00
|
|
|
## copy platform rc.local
|
|
|
|
sudo cp $IMAGE_CONFIGS/platform/rc.local $FILESYSTEM_ROOT/etc/
|
|
|
|
|
2018-11-21 10:08:37 -06:00
|
|
|
## copy blacklist file
|
|
|
|
sudo cp $IMAGE_CONFIGS/platform/linux_kernel_bde.conf $FILESYSTEM_ROOT/etc/modprobe.d/
|
|
|
|
|
2017-01-29 13:33:33 -06:00
|
|
|
{% if installer_images.strip() -%}
|
2018-08-24 12:33:56 -05:00
|
|
|
sudo chroot $FILESYSTEM_ROOT docker info
|
2017-01-29 13:33:33 -06:00
|
|
|
{% for image in installer_images.strip().split(' ') -%}
|
2017-10-08 04:10:14 -05:00
|
|
|
{% set imagefilename = image.split('/')|last -%}
|
|
|
|
{% set imagename = imagefilename.split('.')|first -%}
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT docker load < {{image}}
|
2017-10-08 04:10:14 -05:00
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT docker tag {{imagename}}:latest {{imagename}}:$(sonic_get_version)
|
2017-01-29 13:33:33 -06:00
|
|
|
{% endfor %}
|
|
|
|
sudo chroot $FILESYSTEM_ROOT service docker stop
|
2019-01-04 22:47:43 -06:00
|
|
|
sudo rm $FILESYSTEM_ROOT/etc/init.d/docker
|
2017-04-04 01:56:15 -05:00
|
|
|
{% for script in installer_start_scripts.split(' ') -%}
|
2017-01-29 13:33:33 -06:00
|
|
|
sudo cp {{script}} $FILESYSTEM_ROOT/usr/bin/
|
|
|
|
{% endfor %}
|
|
|
|
{% for service in installer_services.split(' ') -%}
|
2017-03-01 12:57:35 -06:00
|
|
|
if [ -f {{service}} ]; then
|
|
|
|
sudo cp {{service}} $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable {{service}}
|
|
|
|
fi
|
2017-01-29 13:33:33 -06:00
|
|
|
{% endfor %}
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /sys || true
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys
|
|
|
|
{% endif %}
|
|
|
|
|
2018-09-24 18:35:01 -05:00
|
|
|
# Copy swss and syncd service script
|
2018-08-22 15:02:32 -05:00
|
|
|
sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh
|
2018-09-24 18:35:01 -05:00
|
|
|
sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh
|
2018-08-22 15:02:32 -05:00
|
|
|
|
2018-06-22 21:53:51 -05:00
|
|
|
# Copy systemd timer configuration
|
|
|
|
# It implements delayed start of services
|
|
|
|
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
|
|
|
|
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable snmp.timer
|
|
|
|
|
2018-11-20 21:27:56 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get remove -y python-dev
|
2017-03-17 16:51:42 -05:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y
|
2018-11-20 21:27:56 -06:00
|
|
|
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get autoremove -y
|
2017-03-17 16:51:42 -05:00
|
|
|
|
2017-02-07 02:33:20 -06:00
|
|
|
{% for file in installer_extra_files.split(' ') -%}
|
|
|
|
{% if file.strip() -%}
|
|
|
|
{% set src = file.split(':')[0] -%}
|
|
|
|
{% set dst = file.split(':')[1] -%}
|
|
|
|
sudo cp {{src}} $FILESYSTEM_ROOT/{{dst}}
|
|
|
|
{% endif -%}
|
|
|
|
{% endfor -%}
|
2017-07-28 12:57:51 -05:00
|
|
|
|
|
|
|
{% if sonic_asic_platform == "mellanox" %}
|
|
|
|
sudo mkdir -p $FILESYSTEM_ROOT/etc/mlnx/
|
2017-08-22 10:08:07 -05:00
|
|
|
sudo cp target/files/$MLNX_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC.mfa
|
2019-01-17 16:41:32 -06:00
|
|
|
sudo cp target/files/$ISSU_VERSION_FILE $FILESYSTEM_ROOT/etc/mlnx/issu-version
|
2018-12-04 12:11:24 -06:00
|
|
|
sudo cp target/files/$MLNX_FFB_SCRIPT $FILESYSTEM_ROOT/usr/bin/mlnx-ffb.sh
|
2017-08-22 10:08:07 -05:00
|
|
|
j2 platform/mellanox/mlnx-fw-upgrade.j2 | sudo tee $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh
|
|
|
|
sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh
|
2017-07-28 12:57:51 -05:00
|
|
|
{% endif %}
|
2018-11-26 20:19:12 -06:00
|
|
|
|
|
|
|
{%- if SONIC_ROUTING_STACK == "frr" %}
|
|
|
|
sudo mkdir $FILESYSTEM_ROOT/etc/sonic/frr
|
|
|
|
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/frr.conf
|
|
|
|
sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/vtysh.conf
|
|
|
|
sudo cp dockers/docker-fpm-frr/daemons.conf $FILESYSTEM_ROOT/etc/sonic/frr/
|
|
|
|
sudo cp dockers/docker-fpm-frr/daemons $FILESYSTEM_ROOT/etc/sonic/frr/
|
|
|
|
sudo chown -R $FRR_USER_UID:$FRR_USER_GID $FILESYSTEM_ROOT/etc/sonic/frr
|
|
|
|
sudo chmod 750 $FILESYSTEM_ROOT/etc/sonic/frr
|
|
|
|
sudo chmod -R 640 $FILESYSTEM_ROOT/etc/sonic/frr/
|
|
|
|
{%- endif %}
|