diff --git a/commands/db-change-root-password.sh b/commands/db-change-root-password.sh new file mode 100644 index 0000000..ad499c9 --- /dev/null +++ b/commands/db-change-root-password.sh @@ -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’);" diff --git a/commands/db-setup.sh b/commands/db-setup.sh new file mode 100644 index 0000000..e3eb956 --- /dev/null +++ b/commands/db-setup.sh @@ -0,0 +1,41 @@ +if [ "$1" == "-h" ]; then + echo "Usage:" + echo " ./db-setup.sh " + 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;" diff --git a/readme.md b/readme.md index 173351d..db66109 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/ssh/ssh-setup.sh b/ssh/ssh-setup.sh new file mode 100644 index 0000000..27d83db --- /dev/null +++ b/ssh/ssh-setup.sh @@ -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