added some un-tested scripts

db setup and password change
auto ssh key gen
This commit is contained in:
2019-10-29 02:10:00 -06:00
parent 69e0bd8963
commit 2705f2dc94
4 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,5 @@
read -sp "Old Password: " oldPassword
read -sp "New Password: " newPassword
mysql -u root -p "$oldPassword" -e "SET PASSWORD FOR root@'localhost' = PASSWORD($newPassword);"

41
commands/db-setup.sh Normal file
View File

@ -0,0 +1,41 @@
if [ "$1" == "-h" ]; then
echo "Usage:"
echo " ./db-setup.sh <rootPassword> <main-db-user> <main-db-user-password>"
echo " or"
echo " ./db-setup.sh"
exit 0
fi
if [ -z "$1" ] && [ -z "$2" ] && [ -z "$3" ]; then
read -sp "Set root password: " rootPassword
read -sp $'\n'"Confirm root password: " confirmPassword
read -p $'\n'"Main Username: " MAINDB
read -sp "Main user's password: " PASSWDDB
else
rootPassword="$1"
confirmPassword="$1"
MAINDB="$2"
PASSWDDB="$3"
fi
if ["$rootPassword" == "$confirmPassword"]
then
debconf-set-selections <<< "mysql-server mysql-server/root_password password $rootPassword"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $rootPassword"
apt-get -y install mysql-server
else
echo "Passwords do not match cancelling the installation"
exit 1
fi
# Adapted from https://stackoverflow.com/questions/33470753/create-mysql-database-and-user-in-bash-script
# create random password
#PASSWDDB="$(openssl rand -base64 12)"
# replace "-" with "_" for database username
#MAINDB=${USER_NAME//[^a-zA-Z0-9]/_}
mysql -uroot -p${rootPassword} -e "CREATE DATABASE ${MAINDB} /*\!40100 DEFAULT CHARACTER SET utf8 */;"
mysql -uroot -p${rootPassword} -e "CREATE USER ${MAINDB}@* IDENTIFIED BY '${PASSWDDB}';"
mysql -uroot -p${rootPassword} -e "GRANT ALL PRIVILEGES ON ${MAINDB}.* TO '${MAINDB}'@'*';"
mysql -uroot -p${rootPassword} -e "FLUSH PRIVILEGES;"

View File

@ -8,7 +8,7 @@ It will monitor the resource usage and response times and react when predetermin
* Easy setup and deployment of an entire environment
* Deploy new services and code with the click of a button or automate the whole thing
* Monitor resources and scale up horizonally or vertically as needed
* Monitor resources and scale up horizontally or vertically as needed
* Scale down when resources are under utilized
* Allow manual scaling
* In public cloud environments manage VM sizes and usage

7
ssh/ssh-setup.sh Normal file
View File

@ -0,0 +1,7 @@
# To be run on the server
ssh-keygen -t rsa -b 4096 -C "Auto-generated by Marshal" -N "" -f ~/.ssh/id_rsa
# start the ssh-agent in the background
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa