From eefc2de70cc022304ba64fa8aa44b47a47443f70 Mon Sep 17 00:00:00 2001
From: Eric MacDonald <eric.macdonald@windriver.com>
Date: Mon, 12 Jun 2023 13:27:48 +0000
Subject: [PATCH] Update update-iso.sh script with Debian network interface
 setup example

The functional changes made to update-iso.sh over the transition from
CentOS to Debian did not change the example in the tool's help output.

This update modifies the network setup example in the update-iso.sh
script to reflect the method used in Debian.

Test Plan: Create a ks-addon.cfg script and add it to the iso
           using the update-iso.sh script.

PASS: Run the update-iso.sh to add the ks-addon.cfg file
PASS: Verify help output content and format
PASS: Verify addon execution and interface file setup over USB install
PASS: Verify addon execution and interface setup over pxeboot install
      ... with pxeboot addon support added to the kickstart
PASS: Verify network scripts created properly on install
PASS: Verify networking automatically setup over post install reboot
      ... using the example provided in this update

Closes-Bug: 2023486
Change-Id: I42d13c1ef0ad12b435c52c1bb312a21f30cf7fcd
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
---
 utilities/platform-util/scripts/update-iso.sh | 66 ++++++++++++++-----
 1 file changed, 49 insertions(+), 17 deletions(-)

diff --git a/utilities/platform-util/scripts/update-iso.sh b/utilities/platform-util/scripts/update-iso.sh
index bc26f34f..e031581d 100755
--- a/utilities/platform-util/scripts/update-iso.sh
+++ b/utilities/platform-util/scripts/update-iso.sh
@@ -89,30 +89,62 @@ function usage {
         -h      Display this help
 
 Kickstart Addon Example:
-    What: Define a VLAN on initial OAM interface setup:
-    How : Create and pass a file containing the following
-          kind of code using the -a <filename> option.
+    Create addon file containing the desired kickstart operations.
+Example:
+    Create Debian network interface config files that automatically setup
+    ipv6 oam and management network vlans on a physical interface and
+    add the addon file the ISO image with the '-a <ks-addon.cfg>' option.
+
+    $ ./update-iso.sh -i <iso> -o <updated-iso> -a ks-addon.cfg [other options]
 
 #### start ks-addon.cfg
-OAM_DEV=enp0s3
-OAM_VLAN=1234
+RAW_DEV=enp24s0f0
+OAM_VLAN=103
+MGMT_VLAN=163
 
-cat << EOF > /etc/sysconfig/network-scripts/ifcfg-\$OAM_DEV
-DEVICE=\$OAM_DEV
-BOOTPROTO=none
-ONBOOT=yes
-LINKDELAY=20
+cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/auto
+auto ${RAW_DEV} lo vlan${OAM_VLAN} vlan${MGMT_VLAN}
 EOF
 
-cat << EOF > /etc/sysconfig/network-scripts/ifcfg-\$OAM_DEV.\$OAM_VLAN
-DEVICE=\$OAM_DEV.\$OAM_VLAN
-BOOTPROTO=dhcp
-ONBOOT=yes
-VLAN=yes
-LINKDELAY=20
+cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-${RAW_DEV}
+iface ${RAW_DEV} inet manual
+mtu 9000
+post-up echo 0 > /proc/sys/net/ipv6/conf/${RAW_DEV}/autoconf;\
+echo 0 > /proc/sys/net/ipv6/conf/${RAW_DEV}/accept_ra;\
+echo 0 > /proc/sys/net/ipv6/conf/${RAW_DEV}/accept_redirects
+pre-up echo 0 > /sys/class/net/${RAW_DEV}/device/sriov_numvfs;\
+echo 32 > /sys/class/net/${RAW_DEV}/device/sriov_numvfs
 EOF
+
+cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-vlan${OAM_VLAN}
+iface vlan${OAM_VLAN} inet6 static
+vlan-raw-device ${RAW_DEV}
+address <__address__>
+netmask 64
+gateway <__address__>
+mtu 1500
+post-up /usr/sbin/ip link set dev vlan${OAM_VLAN} mtu 1500;\
+echo 0 > /proc/sys/net/ipv6/conf/vlan${OAM_VLAN}/autoconf;\
+echo 0 > /proc/sys/net/ipv6/conf/vlan${OAM_VLAN}/accept_ra;\
+echo 0 > /proc/sys/net/ipv6/conf/vlan${OAM_VLAN}/accept_redirects
+pre-up /sbin/modprobe -q 8021q
+EOF
+
+cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-vlan${MGMT_VLAN}
+iface vlan${MGMT_VLAN} inet6 static
+vlan-raw-device ${RAW_DEV}
+address <__address__>
+netmask 64
+mtu 1500
+post-up /usr/local/bin/tc_setup.sh vlan${MGMT_VLAN} mgmt 10000 > /dev/null;\
+/usr/sbin/ip link set dev vlan${MGMT_VLAN} mtu 1500;\
+echo 0 > /proc/sys/net/ipv6/conf/vlan${MGMT_VLAN}/autoconf;\
+echo 0 > /proc/sys/net/ipv6/conf/vlan${MGMT_VLAN}/accept_ra;\
+echo 0 > /proc/sys/net/ipv6/conf/vlan${MGMT_VLAN}/accept_redirects
+pre-up /sbin/modprobe -q 8021q
+EOF
+
 #### end ks-addon.cfg
-
 ENDUSAGE
     exit 0
 }