From d6e549a7c4211cfba21179c5f403bc7e3d35b6aa Mon Sep 17 00:00:00 2001 From: DokurOmkar Date: Tue, 23 Jul 2024 14:11:12 -0700 Subject: [PATCH 1/3] VH 1319 - Updated the script to support versions that have multi architecture images --- configuration/initialization.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configuration/initialization.sh b/configuration/initialization.sh index ba43e353a..7fa118d61 100755 --- a/configuration/initialization.sh +++ b/configuration/initialization.sh @@ -23,15 +23,16 @@ latest_version=$(echo "$release_info" | grep -o '"tag_name": *"[^"]*"' | cut -d # Fetching all tags from Git repository tags=$(git ls-remote --tags https://github.com/usdot-fhwa-OPS/V2X-Hub.git | awk -F/ '{print $3}' | sort -V) -# Remove curly braces, Properties found, and duplicate entries -updated_tags=$(echo "$tags" | sed 's/\^{}//' | grep -v '^Properties_Found$' | awk '!seen[$0]++') +# Remove curly braces, Properties found, duplicate entries, and show only versions above 7.0 +updated_tags=$(echo "$tags" | sed 's/\^{}//;s/^v//' | grep -v '^Properties_Found$' | awk '!seen[$0]++ && $1 >= "7.0"') # Displaying all available versions +echo "Note: V2X-Hub multi architecture deployments only work for the versions 7.0 and above." echo "Available versions:" echo "$updated_tags" # select a version or accept the latest version as default -read -r -p "Enter V2X-Hub Version (choose from the above, or press Enter to use latest version $latest_version): " chosen_version +read -r -p "Enter V2X-Hub Version (choose from the above, or press Enter to use the latest version $latest_version): " chosen_version V2XHUB_VERSION=${chosen_version:-$latest_version} # Enable Port Drayage functionality From bac1ef26980c05a92cd0063cb2585e9ca26279c7 Mon Sep 17 00:00:00 2001 From: DokurOmkar Date: Thu, 25 Jul 2024 11:18:37 -0700 Subject: [PATCH 2/3] VH 1319 - Updated the add user script to support both plain and sha2 passwords --- configuration/initialization.sh | 2 +- configuration/mysql/add_v2xhub_user.bash | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configuration/initialization.sh b/configuration/initialization.sh index 7fa118d61..996c78487 100755 --- a/configuration/initialization.sh +++ b/configuration/initialization.sh @@ -150,6 +150,6 @@ fi # Create V2X Hub user cd "$mysqlDir" || return # return in case cd fails -./add_v2xhub_user.bash +./add_v2xhub_user.bash "$V2XHUB_VERSION" chromium-browser --ignore-certificate-errors localhost > /dev/null 2>&1 & diff --git a/configuration/mysql/add_v2xhub_user.bash b/configuration/mysql/add_v2xhub_user.bash index 6ee0250e4..c3bb636e4 100755 --- a/configuration/mysql/add_v2xhub_user.bash +++ b/configuration/mysql/add_v2xhub_user.bash @@ -2,6 +2,16 @@ # Fail when any command fails #set -e +# Check if V2XHUB_VERSION is passed +if [ -n "$1" ]; then + V2XHUB_VERSION="$1" +else + # Prompt user for V2XHUB_VERSION + read -p "Enter the deployed V2X-Hub version number: " V2XHUB_VERSION +fi + +echo "Adding V2X-Hub user for version: $V2XHUB_VERSION" + # Ensure mysql-client is installed arch=$(dpkg --print-architecture) # TODO: Add a common mysql-client that works for ARM and AMD devices @@ -34,7 +44,12 @@ if [ $PASS_LENGTH -ge 8 ] && echo $PASS | grep -q [a-z] && echo $PASS | grep -q done echo "VALID PASSWORD" echo "Enter MYSQL ROOT PASSWORD: " - mysql -uroot -p --silent -h127.0.0.1 -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('$USER', SHA2('$PASS', 256), 3)" + # Check if V2XHUB_VERSION is >= 7.5.0 + if [[ "$(echo "$V2XHUB_VERSION 7.5.0" | awk '{print ($1 >= $2)}')" -eq 1 ]]; then + mysql -uroot -p --silent -h127.0.0.1 -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('$USER', SHA2('$PASS', 256), 3)" + else + mysql -uroot -p --silent -h127.0.0.1 -e "INSERT INTO IVP.user (IVP.user.username, IVP.user.password, IVP.user.accessLevel) VALUES('$USER', '$PASS', 3)" + fi echo "V2X Hub user successfully added" else echo "INVALID PASSWORD" From cfd436961df360f2c8a43cbdbb20b19996131c7b Mon Sep 17 00:00:00 2001 From: DokurOmkar Date: Fri, 26 Jul 2024 11:49:25 -0700 Subject: [PATCH 3/3] VH 1319 - Updated the script based on PR feedback --- configuration/mysql/add_v2xhub_user.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/mysql/add_v2xhub_user.bash b/configuration/mysql/add_v2xhub_user.bash index c3bb636e4..bc605c7f2 100755 --- a/configuration/mysql/add_v2xhub_user.bash +++ b/configuration/mysql/add_v2xhub_user.bash @@ -7,7 +7,7 @@ if [ -n "$1" ]; then V2XHUB_VERSION="$1" else # Prompt user for V2XHUB_VERSION - read -p "Enter the deployed V2X-Hub version number: " V2XHUB_VERSION + read -r -p "Enter the deployed V2X-Hub version number: " V2XHUB_VERSION fi echo "Adding V2X-Hub user for version: $V2XHUB_VERSION"