mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 15:32:35 +00:00
Merge (#127)
This commit is contained in:
12
app/SSH/Services/Database/scripts/mariadb/install-10.3.sh
Executable file
12
app/SSH/Services/Database/scripts/mariadb/install-10.3.sh
Executable file
@ -0,0 +1,12 @@
|
||||
wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
|
||||
|
||||
chmod +x mariadb_repo_setup
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive ./mariadb_repo_setup \
|
||||
--mariadb-server-version="mariadb-10.3"
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install mariadb-server mariadb-backup -y
|
||||
|
||||
sudo service mysql start
|
12
app/SSH/Services/Database/scripts/mariadb/install-10.4.sh
Executable file
12
app/SSH/Services/Database/scripts/mariadb/install-10.4.sh
Executable file
@ -0,0 +1,12 @@
|
||||
wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
|
||||
|
||||
chmod +x mariadb_repo_setup
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive ./mariadb_repo_setup \
|
||||
--mariadb-server-version="mariadb-10.4"
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install mariadb-server mariadb-backup -y
|
||||
|
||||
sudo service mysql start
|
11
app/SSH/Services/Database/scripts/mysql/backup.sh
Normal file
11
app/SSH/Services/Database/scripts/mysql/backup.sh
Normal file
@ -0,0 +1,11 @@
|
||||
if ! sudo DEBIAN_FRONTEND=noninteractive mysqldump -u root __database__ > __file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! DEBIAN_FRONTEND=noninteractive zip __file__.zip __file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! rm __file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
9
app/SSH/Services/Database/scripts/mysql/create-user.sh
Executable file
9
app/SSH/Services/Database/scripts/mysql/create-user.sh
Executable file
@ -0,0 +1,9 @@
|
||||
if ! sudo mysql -e "CREATE USER IF NOT EXISTS '__username__'@'__host__' IDENTIFIED BY '__password__'"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mysql -e "FLUSH PRIVILEGES"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Command executed"
|
5
app/SSH/Services/Database/scripts/mysql/create.sh
Executable file
5
app/SSH/Services/Database/scripts/mysql/create.sh
Executable file
@ -0,0 +1,5 @@
|
||||
if ! sudo mysql -e "CREATE DATABASE IF NOT EXISTS __name__ CHARACTER SET utf8 COLLATE utf8_general_ci"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Command executed"
|
9
app/SSH/Services/Database/scripts/mysql/delete-user.sh
Executable file
9
app/SSH/Services/Database/scripts/mysql/delete-user.sh
Executable file
@ -0,0 +1,9 @@
|
||||
if ! sudo mysql -e "DROP USER IF EXISTS '__username__'@'__host__'"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mysql -e "FLUSH PRIVILEGES"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Command executed"
|
5
app/SSH/Services/Database/scripts/mysql/delete.sh
Executable file
5
app/SSH/Services/Database/scripts/mysql/delete.sh
Executable file
@ -0,0 +1,5 @@
|
||||
if ! sudo mysql -e "DROP DATABASE IF EXISTS __name__"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Command executed"
|
13
app/SSH/Services/Database/scripts/mysql/install-5.7.sh
Executable file
13
app/SSH/Services/Database/scripts/mysql/install-5.7.sh
Executable file
@ -0,0 +1,13 @@
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install mysql-server -y
|
||||
|
||||
sudo service mysql enable
|
||||
|
||||
sudo service mysql start
|
||||
|
||||
if ! sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mysql -e "FLUSH PRIVILEGES"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
19
app/SSH/Services/Database/scripts/mysql/install-8.0.sh
Executable file
19
app/SSH/Services/Database/scripts/mysql/install-8.0.sh
Executable file
@ -0,0 +1,19 @@
|
||||
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config_0.8.22-1_all.deb
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install mysql-server -y
|
||||
|
||||
sudo service mysql enable
|
||||
|
||||
sudo service mysql start
|
||||
|
||||
if ! sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mysql -e "FLUSH PRIVILEGES"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
9
app/SSH/Services/Database/scripts/mysql/link.sh
Executable file
9
app/SSH/Services/Database/scripts/mysql/link.sh
Executable file
@ -0,0 +1,9 @@
|
||||
if ! sudo mysql -e "GRANT ALL PRIVILEGES ON __database__.* TO '__username__'@'__host__'"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mysql -e "FLUSH PRIVILEGES"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Linking to __database__ finished"
|
11
app/SSH/Services/Database/scripts/mysql/restore.sh
Normal file
11
app/SSH/Services/Database/scripts/mysql/restore.sh
Normal file
@ -0,0 +1,11 @@
|
||||
if ! DEBIAN_FRONTEND=noninteractive unzip __file__.zip; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo DEBIAN_FRONTEND=noninteractive mysql -u root __database__ < __file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! rm __file__.sql __file__.zip; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
5
app/SSH/Services/Database/scripts/mysql/unlink.sh
Executable file
5
app/SSH/Services/Database/scripts/mysql/unlink.sh
Executable file
@ -0,0 +1,5 @@
|
||||
if ! sudo mysql -e "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '__username__'@'__host__'"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Command executed"
|
19
app/SSH/Services/Database/scripts/postgresql/backup.sh
Normal file
19
app/SSH/Services/Database/scripts/postgresql/backup.sh
Normal file
@ -0,0 +1,19 @@
|
||||
if ! sudo -u postgres pg_dump -d __database__ -f /var/lib/postgresql/__file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mv /var/lib/postgresql/__file__.sql /home/vito/__file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo chown vito:vito /home/vito/__file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! DEBIAN_FRONTEND=noninteractive zip __file__.zip __file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! rm __file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
5
app/SSH/Services/Database/scripts/postgresql/create-user.sh
Executable file
5
app/SSH/Services/Database/scripts/postgresql/create-user.sh
Executable file
@ -0,0 +1,5 @@
|
||||
if ! sudo -u postgres psql -c "CREATE ROLE __username__ WITH LOGIN PASSWORD '__password__';"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "User __username__ created"
|
6
app/SSH/Services/Database/scripts/postgresql/create.sh
Normal file
6
app/SSH/Services/Database/scripts/postgresql/create.sh
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
if ! sudo -u postgres psql -c "CREATE DATABASE __name__"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Database __name__ created"
|
5
app/SSH/Services/Database/scripts/postgresql/delete-user.sh
Executable file
5
app/SSH/Services/Database/scripts/postgresql/delete-user.sh
Executable file
@ -0,0 +1,5 @@
|
||||
if ! sudo -u postgres psql -c "DROP USER __username__"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "User __username__ deleted"
|
5
app/SSH/Services/Database/scripts/postgresql/delete.sh
Executable file
5
app/SSH/Services/Database/scripts/postgresql/delete.sh
Executable file
@ -0,0 +1,5 @@
|
||||
if ! sudo -u postgres psql -c "DROP DATABASE __name__"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Database __name__ deleted"
|
11
app/SSH/Services/Database/scripts/postgresql/install-12.sh
Normal file
11
app/SSH/Services/Database/scripts/postgresql/install-12.sh
Normal file
@ -0,0 +1,11 @@
|
||||
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install postgresql-12 -y
|
||||
|
||||
systemctl status postgresql
|
||||
|
||||
sudo -u postgres psql -c "SELECT version();"
|
11
app/SSH/Services/Database/scripts/postgresql/install-13.sh
Normal file
11
app/SSH/Services/Database/scripts/postgresql/install-13.sh
Normal file
@ -0,0 +1,11 @@
|
||||
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install postgresql-13 -y
|
||||
|
||||
systemctl status postgresql
|
||||
|
||||
sudo -u postgres psql -c "SELECT version();"
|
11
app/SSH/Services/Database/scripts/postgresql/install-14.sh
Normal file
11
app/SSH/Services/Database/scripts/postgresql/install-14.sh
Normal file
@ -0,0 +1,11 @@
|
||||
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install postgresql-14 -y
|
||||
|
||||
systemctl status postgresql
|
||||
|
||||
sudo -u postgres psql -c "SELECT version();"
|
11
app/SSH/Services/Database/scripts/postgresql/install-15.sh
Normal file
11
app/SSH/Services/Database/scripts/postgresql/install-15.sh
Normal file
@ -0,0 +1,11 @@
|
||||
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install postgresql-15 -y
|
||||
|
||||
systemctl status postgresql
|
||||
|
||||
sudo -u postgres psql -c "SELECT version();"
|
11
app/SSH/Services/Database/scripts/postgresql/install-16.sh
Normal file
11
app/SSH/Services/Database/scripts/postgresql/install-16.sh
Normal file
@ -0,0 +1,11 @@
|
||||
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install postgresql-16 -y
|
||||
|
||||
systemctl status postgresql
|
||||
|
||||
sudo -u postgres psql -c "SELECT version();"
|
5
app/SSH/Services/Database/scripts/postgresql/link.sh
Executable file
5
app/SSH/Services/Database/scripts/postgresql/link.sh
Executable file
@ -0,0 +1,5 @@
|
||||
if ! sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE __database__ TO __username__;"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Linking to __database__ finished"
|
11
app/SSH/Services/Database/scripts/postgresql/restore.sh
Normal file
11
app/SSH/Services/Database/scripts/postgresql/restore.sh
Normal file
@ -0,0 +1,11 @@
|
||||
if ! DEBIAN_FRONTEND=noninteractive unzip __file__.zip; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo -u postgres psql -d __database__ -f __file__.sql; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! rm __file__.sql __file__.zip; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
10
app/SSH/Services/Database/scripts/postgresql/unlink.sh
Executable file
10
app/SSH/Services/Database/scripts/postgresql/unlink.sh
Executable file
@ -0,0 +1,10 @@
|
||||
USER_TO_REVOKE='__username__'
|
||||
|
||||
DATABASES=$(sudo -u postgres psql -t -c "SELECT datname FROM pg_database WHERE datistemplate = false;")
|
||||
|
||||
for DB in $DATABASES; do
|
||||
echo "Revoking privileges in database: $DB"
|
||||
sudo -u postgres psql -d "$DB" -c "REVOKE ALL PRIVILEGES ON DATABASE \"$DB\" FROM $USER_TO_REVOKE;"
|
||||
done
|
||||
|
||||
echo "Privileges revoked from $USER_TO_REVOKE"
|
Reference in New Issue
Block a user