From a32708482e4892d6027c08f05b414ed0dbe149df Mon Sep 17 00:00:00 2001 From: Frederic CORDIER Date: Mon, 27 Oct 2025 14:00:46 +0100 Subject: [PATCH 1/2] feat: Improvement of the network cvm assistant --- cvmassistants/network-tool/network-config.sh | 70 +++++++++++--------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/cvmassistants/network-tool/network-config.sh b/cvmassistants/network-tool/network-config.sh index 322de7f..25132be 100644 --- a/cvmassistants/network-tool/network-config.sh +++ b/cvmassistants/network-tool/network-config.sh @@ -1,43 +1,53 @@ #!/usr/bin/env bash -BASEDIR="$( cd "$( dirname "$0" )" && pwd )" -function config() { +############################################################################### +# Script: network-config.sh +# Description: Configure network interface on Ubuntu system +# +# This script configures a network interface with static IP configuration +# on Ubuntu systems (TDX Trusted Domain Environment). +# +# Prerequisites: +# - Must be run with root privileges +# - Must run on Ubuntu OS (TDX Trusted Domain Environment) +# +# Environment Variables Required: +# - ifName: Network interface name (e.g., eth0) +# - ifIp: IP address to assign to the interface +# - ifNetmask: Network subnet mask +# - ifGateway: Gateway IP address +# +############################################################################### + +function configureNetwork() { + # Check if running on Ubuntu + if ! grep -q "ID=ubuntu" /etc/os-release; then + echo "This script only supports Ubuntu. Current OS is not supported." + exit 1 + fi + + # Check if all required environment variables are set + if [ -z "${ifName}" ] || [ -z "${ifIp}" ] || [ -z "${ifNetmask}" ] || [ -z "${ifGateway}" ]; then + echo "Error: Missing required environment variables." + echo "Required variables: ifName, ifIp, ifNetmask, ifGateway" + exit 1 + fi + echo "nameserver 8.8.8.8" > /etc/resolv.conf - - OS_TYPE=`cat /etc/os-release |grep -w ID |awk -F= '{print $2}'` - case "$OS_TYPE" in - ubuntu) - cat>/etc/network/interfaces</etc/network/interfaces< Date: Mon, 27 Oct 2025 14:19:13 +0100 Subject: [PATCH 2/2] chore: missing endline --- cvmassistants/network-tool/network-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvmassistants/network-tool/network-config.sh b/cvmassistants/network-tool/network-config.sh index 25132be..cf533ba 100644 --- a/cvmassistants/network-tool/network-config.sh +++ b/cvmassistants/network-tool/network-config.sh @@ -50,4 +50,4 @@ EOF fi } -configureNetwork \ No newline at end of file +configureNetwork