updated creatmysqlscript
This commit is contained in:
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo mv /var/lib/mysql /var/lib/mysql_old
|
||||||
|
sudo mv /etc/mysql /etc/mysql_backup
|
||||||
|
mv ~/.librography ~/.librography_backup
|
||||||
|
sudo apt remove mariadb
|
||||||
|
sudo apt remove mariadb-server
|
||||||
|
sudo apt remove mariadb-client
|
||||||
|
sudo apt remove openjdk-8-jdk
|
||||||
+83
-48
@@ -1,65 +1,106 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Now we will need update your system and install dependencies, do you want to proceed? "
|
||||||
|
PS3='Choose a option '
|
||||||
|
options=("proceed" "Quit")
|
||||||
|
select opt in "${options[@]}"
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
"proceed")
|
||||||
|
|
||||||
# ask type of instalation: 1- server / 2- client
|
|
||||||
|
|
||||||
########################## temporario ####################
|
########################## temporario ####################
|
||||||
#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
|
||||||
mkdir ~/.librography
|
|
||||||
|
|
||||||
rm ~/.librography/DBUser
|
echo "What is the current configuration for this machine?"
|
||||||
touch ~/.librography/DBUser
|
PS3='Choose a option '
|
||||||
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")
|
options=("server" "client" "Quit")
|
||||||
select opt in "${options[@]}"
|
select opt in "${options[@]}"
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
"server")
|
"server")
|
||||||
echo "proceed to install server"
|
echo "proceed to install server"
|
||||||
|
|
||||||
|
if [ -d /var/lib/mysql/mysql ] ; then
|
||||||
|
echo "mysql already installed, skipping!"
|
||||||
|
else
|
||||||
sudo apt install mariadb-server
|
sudo apt install mariadb-server
|
||||||
echo "now we will proceed with the secure instalaltion and configuration of the database"
|
echo "now we will proceed with the secure installation and configuration of the database"
|
||||||
echo "you can answer in order: n - y - y - y - y."
|
#echo "first you will choose the password for Mysql server"
|
||||||
|
echo "Next you can answer in order: n - y - y - y - y "
|
||||||
read -p "Press enter to continue"
|
read -p "Press enter to continue"
|
||||||
sudo mysql_secure_installation
|
sudo mysql_secure_installation
|
||||||
echo localhost >> ~/.librography/ipserver
|
fi
|
||||||
|
|
||||||
|
if [ -d /var/lib/mysql/gowl ] ; then
|
||||||
|
echo " database gowl exist! skipping "
|
||||||
|
else
|
||||||
|
rm ~/.librography/IPSERVER
|
||||||
|
touch ~/.librography/IPSERVER
|
||||||
|
touch ~/.librography/DefaultPrinter
|
||||||
|
|
||||||
|
mkdir ~/.librography
|
||||||
|
rm ~/.librography/DBUSER
|
||||||
|
touch ~/.librography/DBUSER
|
||||||
|
DBUSER=gowl
|
||||||
|
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
|
||||||
|
|
||||||
sudo mysql <<MYSQL_SCRIPT
|
sudo mysql <<MYSQL_SCRIPT
|
||||||
CREATE DATABASE $dbuser;
|
CREATE DATABASE $DBUSER;
|
||||||
CREATE USER '$dbuser'@'localhost' IDENTIFIED BY '$dbpass';
|
CREATE USER '$DBUSER'@'localhost' IDENTIFIED BY '$DBPASS';
|
||||||
GRANT ALL PRIVILEGES ON $dbuser.* TO '$dbuser'@'localhost';
|
GRANT ALL PRIVILEGES ON $DBUSER.* TO '$DBUSER'@'localhost';
|
||||||
|
source script.sql
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
MYSQL_SCRIPT
|
MYSQL_SCRIPT
|
||||||
|
|
||||||
echo "MySQL user created."
|
echo "MySQL user created."
|
||||||
echo "Username: $dbuser"
|
echo "Username: $DBUSER"
|
||||||
echo "Password: $dbpass"
|
echo "Password: $DBPASS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
IPSERVER=localhost
|
||||||
|
echo $IPSERVER >> ~/.librography/IPSERVER
|
||||||
|
|
||||||
|
echo "-------- Installation finished! ------------"
|
||||||
|
echo " DataBase Url/ip: $IPSERVER"
|
||||||
|
echo " DataBase Username : $DBUSER"
|
||||||
|
echo " DataBase Password : $DBPASS"
|
||||||
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
"client")
|
"client")
|
||||||
echo "proceed to install a cliente"
|
echo "proceed to install a cliente"
|
||||||
sudo apt install mariadb-client
|
sudo apt install mariadb-client
|
||||||
|
mkdir ~/.librography
|
||||||
|
rm ~/.librography/IPSERVER
|
||||||
|
touch ~/.librography/IPSERVER
|
||||||
|
touch ~/.librography/DefaultPrinter
|
||||||
|
echo "Enter the database server ip: "
|
||||||
|
read IPSERVER
|
||||||
|
echo $IPSERVER >> ~/.librography/IPSERVER
|
||||||
|
|
||||||
echo "Entre com o ip do servidor com o banco de dados: "
|
rm ~/.librography/DBUSER
|
||||||
read ipserver
|
touch ~/.librography/DBUSER
|
||||||
echo $ipserver >> ~/.librography/ipserver
|
DBUSER=gowl
|
||||||
|
echo $DBUSER >> ~/.librography/DBUSER
|
||||||
|
|
||||||
|
rm ~/.librography/DBPASS
|
||||||
|
touch ~/.librography/DBPASS
|
||||||
|
echo "Entre com a senha do usuario do banco de dados: "
|
||||||
|
read DBPASS
|
||||||
|
echo $DBPASS >> ~/.librography/DBPASS
|
||||||
|
|
||||||
|
echo "-------- Installation finished! ------------"
|
||||||
|
echo " DataBase Url/ip: $IPSERVER"
|
||||||
|
echo " DataBase Username : $DBUSER"
|
||||||
|
echo " DataBase Password : $DBPASS"
|
||||||
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
@@ -70,20 +111,14 @@ MYSQL_SCRIPT
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"Quit")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*) echo "invalid option $REPLY";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# create shortcut on desktop
|
||||||
# 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user