diff --git a/configuration/initialization.sh b/configuration/initialization.sh index ba43e353a..996c78487 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 @@ -149,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..bc605c7f2 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 -r -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"