Major upgrade and refactor
This commit is contained in:
21
app/1mindeploy/DATABASE_CREATION_AND_INSTALLATION.sql
Normal file
21
app/1mindeploy/DATABASE_CREATION_AND_INSTALLATION.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- Create a database for ForgottenServer
|
||||
CREATE DATABASE IF NOT EXISTS forgottenserver CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
|
||||
-- Create a user for specific for the database
|
||||
CREATE USER IF NOT EXISTS forgottenserver@localhost IDENTIFIED BY 'forgotten';
|
||||
|
||||
-- Set privileges to the new user
|
||||
GRANT ALL PRIVILEGES ON forgottenserver.* TO 'forgottenserver'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
-- forgottenserver database schema installation
|
||||
USE forgottenserver;
|
||||
SOURCE /home/tibia/SabrehavenServer/sabrehaven.sql;
|
||||
|
||||
-- ZnoteAAC database schema installation
|
||||
USE forgottenserver;
|
||||
SOURCE /var/www/ZnoteAAC/engine/database/znote_schema.sql;
|
||||
|
||||
-- Install sabrehaven_znote.sql for Sabrehaven usage
|
||||
USE forgottenserver;
|
||||
SOURCE /home/tibia/SabrehavenServer/sabrehaven_znote.sql;
|
||||
2
app/1mindeploy/DBCI.sh
Normal file
2
app/1mindeploy/DBCI.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
mariadb -u root < '/home/tibia/1mindeploy/DATABASE_CREATION_AND_INSTALLATION.sql'
|
||||
4
app/1mindeploy/entrypoint.sh
Executable file
4
app/1mindeploy/entrypoint.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
service mariadb start > /dev/null 2>&1
|
||||
service apache2 start > /dev/null 2>&1
|
||||
/bin/sh
|
||||
68
app/1mindeploy/pma_install.sh
Executable file
68
app/1mindeploy/pma_install.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ensure the script runs with root privileges
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update package list and install necessary packages
|
||||
apt-get update -y
|
||||
apt-get install -y apache2 mysql-server php libapache2-mod-php php-mysqli php-json php-common php-mbstring php-zip php-xml php-gd php-curl php-bz2 php-ldap php-imagick
|
||||
|
||||
# Automatically select Apache2 during phpMyAdmin installation (without user intervention)
|
||||
echo "phpmyadmin phpmyadmin/webserver select apache2" | debconf-set-selections
|
||||
|
||||
# Install phpMyAdmin (with no user interaction)
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
|
||||
|
||||
# Generate a random password for phpMyAdmin user
|
||||
phpmyadmin_password=$(openssl rand -base64 12)
|
||||
|
||||
# Set the MySQL root password (if not already set)
|
||||
mysql_root_password=$(openssl rand -base64 12)
|
||||
|
||||
# Set MySQL root password if not already set
|
||||
echo "Setting MySQL root password"
|
||||
mysqladmin -u root password "$mysql_root_password"
|
||||
|
||||
# Check if the phpmyadmin user already exists and drop it if it does
|
||||
echo "Checking if phpMyAdmin user exists"
|
||||
existing_user=$(mysql -u root -p"$mysql_root_password" -e "SELECT COUNT(*) FROM mysql.user WHERE User = 'phpmyadmin';" | tail -n 1)
|
||||
|
||||
if [ "$existing_user" -gt 0 ]; then
|
||||
echo "Dropping existing phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "DROP USER IF EXISTS 'phpmyadmin'@'localhost';"
|
||||
fi
|
||||
|
||||
# Create phpMyAdmin user with mysql_native_password plugin
|
||||
echo "Creating phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY '$phpmyadmin_password';"
|
||||
|
||||
# Grant privileges to phpMyAdmin user
|
||||
echo "Granting privileges to phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'localhost';"
|
||||
mysql -u root -p"$mysql_root_password" -e "FLUSH PRIVILEGES;"
|
||||
|
||||
# Link phpMyAdmin to Apache's web directory (optional)
|
||||
# ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin # Uncomment if necessary
|
||||
|
||||
# Configure Apache to automatically restart and reconfigure
|
||||
echo "Reconfiguring Apache to apply changes"
|
||||
a2enmod rewrite
|
||||
|
||||
# Enable PHP module (adjust according to PHP version installed)
|
||||
a2enmod php7.4 # Adjust according to the PHP version installed (e.g., php7.4, php8.0)
|
||||
|
||||
# Restart Apache to apply changes
|
||||
service apache2 restart
|
||||
cp /home/tibia/1mindeploy/phpmyadmin.conf /etc/apache2/conf-available
|
||||
a2enconf phpmyadmin
|
||||
|
||||
# Output phpMyAdmin password and MySQL root password for user reference
|
||||
#echo "phpMyAdmin user created with the following password: $phpmyadmin_password"
|
||||
echo "MySQL root password: $mysql_root_password"
|
||||
|
||||
# Clean up and remove unnecessary packages
|
||||
#apt-get clean
|
||||
|
||||
68
app/1mindeploy/pma_install.sh.bak
Executable file
68
app/1mindeploy/pma_install.sh.bak
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ensure the script runs with root privileges
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update package list and install necessary packages
|
||||
apt-get update -y
|
||||
apt-get install -y apache2 mysql-server php libapache2-mod-php php-mysqli php-json php-common php-mbstring php-zip php-xml php-gd php-curl php-bz2 php-ldap php-imagick
|
||||
|
||||
# Automatically select Apache2 during phpMyAdmin installation (without user intervention)
|
||||
echo "phpmyadmin phpmyadmin/webserver select apache2" | debconf-set-selections
|
||||
|
||||
# Install phpMyAdmin (with no user interaction)
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
|
||||
|
||||
# Generate a random password for phpMyAdmin user
|
||||
phpmyadmin_password=$(openssl rand -base64 12)
|
||||
|
||||
# Set the MySQL root password (if not already set)
|
||||
mysql_root_password=$(openssl rand -base64 12)
|
||||
|
||||
# Set MySQL root password if not already set
|
||||
echo "Setting MySQL root password"
|
||||
mysqladmin -u root password "$mysql_root_password"
|
||||
|
||||
# Check if the phpmyadmin user already exists and drop it if it does
|
||||
echo "Checking if phpMyAdmin user exists"
|
||||
existing_user=$(mysql -u root -p"$mysql_root_password" -e "SELECT COUNT(*) FROM mysql.user WHERE User = 'phpmyadmin';" | tail -n 1)
|
||||
|
||||
if [ "$existing_user" -gt 0 ]; then
|
||||
echo "Dropping existing phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "DROP USER IF EXISTS 'phpmyadmin'@'localhost';"
|
||||
fi
|
||||
|
||||
# Create phpMyAdmin user with mysql_native_password plugin
|
||||
echo "Creating phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY '$phpmyadmin_password';"
|
||||
|
||||
# Grant privileges to phpMyAdmin user
|
||||
echo "Granting privileges to phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'localhost';"
|
||||
mysql -u root -p"$mysql_root_password" -e "FLUSH PRIVILEGES;"
|
||||
|
||||
# Link phpMyAdmin to Apache's web directory (optional)
|
||||
# ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin # Uncomment if necessary
|
||||
|
||||
# Configure Apache to automatically restart and reconfigure
|
||||
echo "Reconfiguring Apache to apply changes"
|
||||
a2enmod rewrite
|
||||
|
||||
# Enable PHP module (adjust according to PHP version installed)
|
||||
a2enmod php7.4 # Adjust according to the PHP version installed (e.g., php7.4, php8.0)
|
||||
|
||||
# Restart Apache to apply changes
|
||||
service apache2 restart
|
||||
cp phpmyadmin.conf /etc/apache2/conf-available
|
||||
a2enconf phpmyadmin
|
||||
|
||||
# Output phpMyAdmin password and MySQL root password for user reference
|
||||
echo "phpMyAdmin user created with the following password: $phpmyadmin_password"
|
||||
echo "MySQL root password: $mysql_root_password"
|
||||
|
||||
# Clean up and remove unnecessary packages
|
||||
#apt-get clean
|
||||
|
||||
Reference in New Issue
Block a user