Skip to content

Commit

Permalink
VH 1319 - Updated the add user script to support both plain and sha2 …
Browse files Browse the repository at this point in the history
…passwords
  • Loading branch information
DokurOmkar committed Jul 25, 2024
1 parent d6e549a commit bac1ef2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion configuration/initialization.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
17 changes: 16 additions & 1 deletion configuration/mysql/add_v2xhub_user.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit bac1ef2

Please sign in to comment.