Files
Librography/createmysql.sh
T

87 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# ask type of instalation: 1- server / 2- client
########################## temporario ####################
#sudo apt update
#sudo apt upgrade
#sudo apt install openjdk-8-jdk # mariadb-server mariadb-client
mkdir ~/.librography
rm ~/.librography/DBUser
touch ~/.librography/DBUser
echo "Entre com o nome para o usuario do banco de dados: "
read dbuser
echo $dbuser >> ~/.librography/DBUser
rm ~/.librography/DBPass
touch ~/.librography/DBPass
echo "Entre com a senha para o usuario do banco de dados: "
read dbpass
echo $dbpass >> ~/.librography/DBPass
rm ~/.librography/ipserver
touch ~/.librography/ipserver
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_installation
echo localhost >> ~/.librography/ipserver
sudo mysql <<MYSQL_SCRIPT
CREATE DATABASE $dbuser;
CREATE USER '$dbuser'@'localhost' IDENTIFIED BY '$dbpass';
GRANT ALL PRIVILEGES ON $dbuser.* TO '$dbuser'@'localhost';
FLUSH PRIVILEGES;
MYSQL_SCRIPT
echo "MySQL user created."
echo "Username: $dbuser"
echo "Password: $dbpass"
break
;;
"client")
echo "proceed to install a cliente"
sudo apt install mariadb-client
echo "Entre com o ip do servidor com o banco de dados: "
read ipserver
echo $ipserver >> ~/.librography/ipserver
break
;;
"Quit")
break
;;
*) echo "invalid option $REPLY";;
esac
done
# is the mysql already configured?
# proceed with secure install:
#echo "Enter the user name for database: "
#read password
#echo "The Current User Name is $first_name"
#echo
#echo "Enter other users'names: "
#read name1 name2 name3
#$echo "$name1, $name2, $name3 are the other users."
#PASS=`pwgen -s 40 1`
#PASS= dbpass