added some un-tested scripts
db setup and password change auto ssh key gen
This commit is contained in:
5
commands/db-change-root-password.sh
Normal file
5
commands/db-change-root-password.sh
Normal 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
41
commands/db-setup.sh
Normal 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;"
|
@ -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
7
ssh/ssh-setup.sh
Normal 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
|
Reference in New Issue
Block a user