Skip to content

Commit

Permalink
Merge pull request #8 from bazbill115/master
Browse files Browse the repository at this point in the history
DB password and Google token can now be set from a central location and a setup script has been created to update the different deployment. Thanks @bazbill115 and @burkeazbill for this.
  • Loading branch information
vmeoc authored Jul 25, 2019
2 parents 6353349 + ef55678 commit 15e1b35
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 14 deletions.
4 changes: 3 additions & 1 deletion asset/Deployment/Docker/docker-compose.yml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
restart: always
environment:
TITO-SQL: Tito-SQL
# The following is used by apache2-foreground to make sure updated pw is passed to config.ini.php
MYSQL_ROOT_PASSWORD: Tito2016
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 1m30s
Expand Down Expand Up @@ -54,4 +56,4 @@ services:

networks:
tito-nw:
driver: bridge
driver: bridge
5 changes: 5 additions & 0 deletions asset/Deployment/Docker/tito-fe/apache2-foreground
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ if [ -n "$TITO_VERSION" ]; then
git checkout $TITO_VERSION
fi

# Make sure the config file has the updated password:
if [ -n "$MYSQL_ROOT_PASSWORD" ]; then
sed -i "s/.*password.*/password = \"$MYSQL_ROOT_PASSWORD\"/" "./config.ini.php"
fi

#to have the apache server redirect the flow for ingress
sed -i '/<IfModule alias_module>/a Alias /tito/ "/var/www/html/"' /etc/apache2/mods-enabled/alias.conf

Expand Down
2 changes: 1 addition & 1 deletion asset/Deployment/FaaS/AWS/book/db-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ module.exports = (query) => {
con.end();
})

}
}
2 changes: 1 addition & 1 deletion asset/Deployment/FaaS/AWS/reset/db-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ module.exports = (query) => {
con.end();
})

}
}
3 changes: 3 additions & 0 deletions asset/Deployment/Scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Setup Script Info

The setup.sh is provided to allow you to specify your own password and Google Maps API Key (optional).
67 changes: 67 additions & 0 deletions asset/Deployment/Scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
cd ../../..

#filePaths=( "asset/Deployment/CloudAssembly/titodb/mysql.sh")

echo "Set database password: " && read password

read -p "Would you like to provide a Google API Key? (y/n) " useCustomKey
if [[ "$useCustomKey" =~ ^[Yy]$ ]]; then
read -p "Enter Key: " customKey
sed -i '' "s/.*GOOGLE_API_KEY.*/GOOGLE_API_KEY = $customKey/" "config.ini.php"
fi

encpass=$(echo -n "${password}" | base64)

sed -i '' "s/.*password.*/password = \"$password\"/" "config.ini.php"

sed -i '' "s/master_password.*/master_password: $password/" "asset/Deployment/CloudAssembly/Tito FE and RDS DB.yml"

sed -i '' "s/DB_ROOT_PASSWORD=.*/DB_ROOT_PASSWORD=$password/" "asset/Deployment/CloudAssembly/titodb/mysql.sh"

sed -i '' "s/db_password=.*/db_password=$password/" "asset/Deployment/CloudAssembly/titodb/tito_db.sh"

sed -i '' "s/password=.*/password=$password --database=TitoDB -e 'select count(*) from TitoTable'\"/" "asset/Deployment/Docker/docker-compose.yml"

sed -i '' "s/ROOT_PASSWORD:.*/ROOT_PASSWORD: $password/g" "asset/Deployment/Docker/docker-compose.yml"

sed -i '' "s/password:.*/password: \"$password\",/" "asset/Deployment/FaaS/AWS/book/db-connector.js"

sed -i '' "s/password:.*/password: \"$password\",/" "asset/Deployment/FaaS/AWS/read/db-connector.js"

sed -i '' "s/password:.*/password: \"$password\",/" "asset/Deployment/FaaS/AWS/reset/db-connector.js"

sed -i '' "s/password:.*/password: \"$password\",/" "asset/Deployment/FaaS/Openfaas/book/db-connector"

sed -i '' "s/password:.*/password: \"$password\",/" "asset/Deployment/FaaS/Openfaas/read/db-connector"

sed -i '' "s/password:.*/password: \"$password\",/" "asset/Deployment/FaaS/Openfaas/reset/db-connector"

#Note: The sed command may not work properly in future changes to the file if any more value tags are added
sed -i '' "s/value:.*/value: $password/" "asset/Deployment/K8/Ingress/pks/tito-sql-pod.yml"

# idk what to do for Titocopy.yaml

sed -i '' "s/password:.*/password: $encpass/" "asset/Deployment/K8/Ingress/PKSCloud/tito-full-ing-dev.yml"

sed -i '' "s/password:.*/password: $encpass/" "asset/Deployment/K8/Ingress/PKSCloud/tito-full-ing-prod.yml"

sed -i '' "s/password:.*/password: $encpass/" "asset/Deployment/K8/LB/tito-full-lb.yml"

line=$(sed -n '/DB_ROOT_PASSWORD:/=' 'asset/Deployment/vRA Blueprint/VM based/old/composite-blueprint/Titocopy.yaml')

line=$((line + 1))

sed -i '' "${line} s/default:.*/default: $password/" "asset/Deployment/vRA Blueprint/VM based/old/composite-blueprint/Titocopy.yaml"

sed -i '' "s/DB_PASSWORD:.*/DB_PASSWORD: $password/" "asset/Deployment/vRA Blueprint/VM based/old/composite-blueprint/Titocopy.yaml"

line=$(sed -n '/type: "secureString"/=' 'asset/Deployment/vRA Blueprint/VM based/old/software-component/Software.TitoDBconf.yaml')

l_one=$(echo $line | cut -d " " -f 1)
l_one=$((l_one + 1))
l_two=$(echo $line | cut -d " " -f 2)
l_two=$((l_two + 1))

sed -i '' "${l_one} s/value:.*/value: \"$password\"/" "asset/Deployment/vRA Blueprint/VM based/old/software-component/Software.TitoDBconf.yaml"
sed -i '' "${l_two} s/value:.*/value: \"$password\"/" "asset/Deployment/vRA Blueprint/VM based/old/software-component/Software.TitoDBconf.yaml"
10 changes: 10 additions & 0 deletions config.ini.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
;<?php echo "Configuration is Required!"; die(); ?>

GOOGLE_API_KEY = AIzaSyA5ZDRG9r8hBWrtlGsEuJKU2KBg_cCV_Qk
username = root
password = "Tito2016"
tablename = TitoTable
dbname = TitoDB



12 changes: 8 additions & 4 deletions db_dump.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?php

// Retrieve variables from config file
$ini = parse_ini_file("config.ini.php");

$servername = getenv('TITO-SQL');
$password = "Tito2016";
$username = "root";
$tablename = "TitoTable";
$dbname = "TitoDB";
$password = $ini['password'];
$username = $ini['username'];
$tablename = $ini['tablename'];
$dbname = $ini['dbname'];

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
Expand Down
11 changes: 7 additions & 4 deletions form_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@


//**************SQL variables*********************
$ini = parse_ini_file('config.ini.php');

$servername = getenv('TITO-SQL');
$username = "root";
$password = "Tito2016";
$tablename = "TitoTable";
$dbname = "TitoDB";
$username = $ini['username'];
$password = $ini['password'];
$tablename = $ini['tablename'];
$dbname = $ini['dbname'];

//*************************************************
/*
// Réception des variables
Expand Down
5 changes: 2 additions & 3 deletions getTrafficData.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

const GOOGLE_API_KEY = "AIzaSyA5ZDRG9r8hBWrtlGsEuJKU2KBg_cCV_Qk";
$ini = parse_ini_file('config.ini.php');
define('GOOGLE_API_KEY', $ini['GOOGLE_API_KEY']);

$metric_name = "google_maps_call_duration";
$tag_name = "TitoTier";
Expand All @@ -9,7 +9,6 @@
// Extract parameters from URL
$needed_params = array("home_addr", "home_time", "work_addr", "work_time","home_range");


$params = extractParametersFromUrl($needed_params);

$result = getTrafficData($params);
Expand Down

0 comments on commit 15e1b35

Please sign in to comment.