From 639ad080a736aaa0151593ff1a0298264b806e9f Mon Sep 17 00:00:00 2001 From: Will Martin Date: Mon, 10 Jul 2023 14:21:08 -0400 Subject: [PATCH] modified: initialization.sh (#548) # PR Details ## Description Changes made to fix localhost address to reach V2X Hub Web UI and allow for script to be run multiple times without changing mysql password files. ## Related Issue ## Motivation and Context ## How Has This Been Tested? ## Types of changes - [ ] Defect fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that cause existing functionality to change) ## Checklist: - [ ] I have added any new packages to the sonar-scanner.properties file - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [ ] I have read the **CONTRIBUTING** document. [V2XHUB Contributing Guide](https://github.com/usdot-fhwa-OPS/V2X-Hub/blob/develop/Contributing.md) - [ ] I have added tests to cover my changes. - [ ] All new and existing tests passed. --- configuration/amd64/initialization.sh | 38 +++++++++++++++++--------- configuration/arm64/initialization.sh | 39 ++++++++++++++++++--------- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/configuration/amd64/initialization.sh b/configuration/amd64/initialization.sh index 03660e9d5..eea35fc48 100755 --- a/configuration/amd64/initialization.sh +++ b/configuration/amd64/initialization.sh @@ -1,4 +1,6 @@ #!/bin/bash +directory=$(pwd) +mysqlDir="$directory/mysql" # update and upgrade commands to update linux OS sudo apt update -y && sudo apt upgrade -y @@ -11,21 +13,31 @@ sudo apt install curl -y #Curl for downloading files over i curl -L https://raw.githubusercontent.com/usdot-fhwa-stol/carma-platform/develop/engineering_tools/install-docker.sh | bash #make passwords for mysql -mkdir secrets && cd secrets +mkdir -p secrets && cd secrets #creates password files where user inputs password -read -p "enter password for the mysql_root_password: " sql_root_pass -echo "$sql_root_pass" > sql_root_pass.txt - -read -p "enter password for mysql_password: " sql_pass -echo "$sql_pass" > sql_pass.txt - -#remove endline characters from password files -tr -d '\n' mysql_root_password.txt && tr -d '\n' mysql_password.txt -rm sql_root_pass.txt && rm sql_pass.txt +FILE1=mysql_root_password.txt +FILE2=mysql_password.txt +if test -f "$FILE1"; then + echo "$FILE1 exists." +else + read -p "enter password for the mysql_root_password: " sql_root_pass + echo "$sql_root_pass" > sql_root_pass.txt + #remove endline characters from password files + tr -d '\n' mysql_root_password.txt && rm sql_root_pass.txt +fi + +if test -f "$FILE2"; then + echo "$FILE2 exists." +else + read -p "enter password for mysql_password: " sql_pass + echo "$sql_pass" > sql_pass.txt + #remove endline characters from password files + tr -d '\n' mysql_password.txt && rm sql_pass.txt +fi #AMD64 initialzation -cd .. +cd $directory sudo apt-get -y remove docker docker-engine docker.io containerd runc sudo apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - @@ -38,8 +50,8 @@ sudo apt update -y && sudo apt upgrade -y sudo docker-compose up -d #create v2xhub user -cd mysql +cd $mysqlDir ./add_v2xhub_user.bash -chromium-browser "https://127.0.0.1" > /dev/null 2>&1 & +chromium-browser "http://127.0.0.1" > /dev/null 2>&1 & chromium-browser "https://127.0.0.1:19760" > /dev/null 2>&1 & diff --git a/configuration/arm64/initialization.sh b/configuration/arm64/initialization.sh index 2430a1641..7769004df 100755 --- a/configuration/arm64/initialization.sh +++ b/configuration/arm64/initialization.sh @@ -1,4 +1,7 @@ #!/bin/bash +directory=$(pwd) +mysqlDir="$directory/mysql" + # update and upgrade commands to update linux OS sudo apt update -y && sudo apt upgrade -y @@ -10,21 +13,31 @@ sudo apt install curl -y #Curl for downloading files over i curl -L https://raw.githubusercontent.com/usdot-fhwa-stol/carma-platform/develop/engineering_tools/install-docker.sh | bash #make passwords for mysql -mkdir secrets && cd secrets +mkdir -p secrets && cd secrets #creates password files where user inputs password -read -p "enter password for the mysql_root_password: " sql_root_pass -echo "$sql_root_pass" > sql_root_pass.txt - -read -p "enter password for mysql_password: " sql_pass -echo "$sql_pass" > sql_pass.txt - -#remove endline characters from password files -tr -d '\n' mysql_root_password.txt && tr -d '\n' mysql_password.txt -rm sql_root_pass.txt && rm sql_pass.txt +FILE1=mysql_root_password.txt +FILE2=mysql_password.txt +if test -f "$FILE1"; then + echo "$FILE1 exists." +else + read -p "enter password for the mysql_root_password: " sql_root_pass + echo "$sql_root_pass" > sql_root_pass.txt + #remove endline characters from password files + tr -d '\n' mysql_root_password.txt && rm sql_root_pass.txt +fi + +if test -f "$FILE2"; then + echo "$FILE2 exists." +else + read -p "enter password for mysql_password: " sql_pass + echo "$sql_pass" > sql_pass.txt + #remove endline characters from password files + tr -d '\n' mysql_password.txt && rm sql_pass.txt +fi #ARM initialization -cd .. +cd $directory sudo apt-get -y remove docker docker-engine docker.io containerd runc sudo apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common OS=$(lsb_release -i | awk 'FS=":" {print $3;}' | awk '{print tolower($0)}') @@ -38,8 +51,8 @@ sudo apt update -y && sudo apt upgrade -y sudo docker-compose up -d #create v2xhub user -cd mysql +cd $mysqlDir ./add_v2xhub_user.bash -chromium-browser "https://127.0.0.1" > /dev/null 2>&1 & +chromium-browser "http://127.0.0.1" > /dev/null 2>&1 & chromium-browser "https://127.0.0.1:19760" > /dev/null 2>&1 &