update script to install mysql
This commit is contained in:
+44
-8
@@ -5,9 +5,44 @@
|
|||||||
|
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt upgrade
|
sudo apt upgrade
|
||||||
sudo apt install openjdk-8-jdk mariadb-server mariadb-client
|
sudo apt install openjdk-8-jdk # mariadb-server mariadb-client
|
||||||
mkdir ~/.librography
|
mkdir ~/.librography
|
||||||
touch ~/.librography/
|
|
||||||
|
touch ~/.librography/DBUser
|
||||||
|
echo "Entre com o nome para o usuario do banco de dados: "
|
||||||
|
read dbuser
|
||||||
|
echo $dbuser >> ~/.librography/DBUser
|
||||||
|
|
||||||
|
touch ~/.librography/DBPass
|
||||||
|
echo "Entre com a senha para o usuario do banco de dados: "
|
||||||
|
read dbpass
|
||||||
|
echo $dbpass >> ~/.librography/DBPass
|
||||||
|
|
||||||
|
|
||||||
|
touch ~/.Librography/DefaultPrinter
|
||||||
|
|
||||||
|
PS3='What is the current configuration for this machine? '
|
||||||
|
options=("server" "client" "Quit")
|
||||||
|
select opt in "${options[@]}"
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
"server")
|
||||||
|
echo "proceed to install server"
|
||||||
|
sudo apt install mariadb-server
|
||||||
|
sudo mysql_secure_install
|
||||||
|
;;
|
||||||
|
"client")
|
||||||
|
echo "proceed to install a cliente"
|
||||||
|
sudo apt install mariadb-client
|
||||||
|
;;
|
||||||
|
"Quit")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "invalid option $REPLY";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# is the mysql already configured?
|
# is the mysql already configured?
|
||||||
# proceed with secure install:
|
# proceed with secure install:
|
||||||
@@ -20,15 +55,16 @@ echo "Enter other users'names: "
|
|||||||
read name1 name2 name3
|
read name1 name2 name3
|
||||||
echo "$name1, $name2, $name3 are the other users."
|
echo "$name1, $name2, $name3 are the other users."
|
||||||
|
|
||||||
PASS=`pwgen -s 40 1`
|
#PASS=`pwgen -s 40 1`
|
||||||
|
#PASS= dbpass
|
||||||
|
|
||||||
mysql -uroot <<MYSQL_SCRIPT
|
mysql -uroot <<MYSQL_SCRIPT
|
||||||
CREATE DATABASE $1;
|
CREATE DATABASE $dbuser;
|
||||||
CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
|
CREATE USER '$dbuser'@'localhost' IDENTIFIED BY '$dbpass';
|
||||||
GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';
|
GRANT ALL PRIVILEGES ON $dbuser.* TO '$dbuser'@'localhost';
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
MYSQL_SCRIPT
|
MYSQL_SCRIPT
|
||||||
|
|
||||||
echo "MySQL user created."
|
echo "MySQL user created."
|
||||||
echo "Username: $1"
|
echo "Username: $dbuser"
|
||||||
echo "Password: $PASS"
|
echo "Password: $dbpass"
|
||||||
Reference in New Issue
Block a user