Compare commits

...

4 Commits

Author SHA1 Message Date
ba2807a8f8 Fix deployment 2025-03-04 20:24:34 +01:00
3ea80eda6c Nu 2do 2025-02-27 21:35:31 +01:00
b53c19929a Hard-code DB credentials to ZnoteAAC 2025-02-27 21:34:35 +01:00
d4f49c7637 Install php-apcu module 2025-02-27 21:16:09 +01:00
5 changed files with 34 additions and 125 deletions

9
2do.txt Normal file
View File

@@ -0,0 +1,9 @@
2do list:
Critical:
- When phpmyadmin install-script generates a password, it doesnt match with the password stored in '/etc/phpmyadmin/config-db.php'.
Refactor:
- Remove phpmyadmin dependencies written in install-script. Dependencies should be in the dockerfile. (Also make a copy of the original script).
- Check for more phpmyadmin errors. Proper php.ini tweaking?
- Tweak /var/www/ZnoteAAC/config.php properly.

View File

@@ -7,63 +7,31 @@ if [ "$(id -u)" -ne 0 ]; then
fi
# Update package list and install necessary packages
apt-get update -y
apt-get install -y php 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
apt-get update
apt-get install -y mariadb-server
service mariadb start
# Automatically select Apache2 during phpMyAdmin installation (without user intervention)
echo "phpmyadmin phpmyadmin/webserver select apache2" | debconf-set-selections
###
# Set debconf to non-interactive mode
export DEBIAN_FRONTEND=noninteractive
# Install phpMyAdmin (with no user interaction)
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
# Set the phpMyAdmin password (leave blank for random password)
PHPADMIN_PASSWORD=""
# Generate a random password for phpMyAdmin user
phpmyadmin_password=$(openssl rand -base64 12)
# Set the web server (1 for apache2, 2 for lighttpd)
WEB_SERVER="apache2"
# Set the MySQL root password (if not already set)
#mysql_root_password=$(openssl rand -base64 12)
mysql_root_password="forgotten"
# Preconfigure the phpMyAdmin installation
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections
echo "phpmyadmin phpmyadmin/app-password-confirm password $PHPADMIN_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/admin-pass password" | debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/app-pass password $PHPADMIN_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/reconfigure-webserver select $WEB_SERVER" | debconf-set-selections
# Set MySQL root password if not already set
echo "Setting MySQL root password"
mysqladmin -u root password "$mysql_root_password"
# Install phpMyAdmin
apt install -y phpmyadmin
# 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
# If using apache2, restart the apache2 service (adjust if using other web servers)
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
echo "phpMyAdmin installation completed successfully."

View File

@@ -1,68 +0,0 @@
#!/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

View File

@@ -30,13 +30,13 @@
// ------------------------ \\
// phpmyadmin username for OT server: (DONT USE "root" if you are hosting to public).
$config['sqlUser'] = 'tfs13';
$config['sqlUser'] = 'forgottenserver';
// phpmyadmin password for OT server:
$config['sqlPassword'] = 'tfs13';
$config['sqlPassword'] = 'forgotten';
// The database name to connect to. (This is usually same as username).
$config['sqlDatabase'] = 'tfs13';
$config['sqlDatabase'] = 'forgottenserver';
// Hostname is usually localhost or 127.0.0.1.
$config['sqlHost'] = '127.0.0.1';
@@ -637,7 +637,7 @@
// What client version and server port are you using on this OT?
// Used for the Downloads page.
$config['client'] = 1098; // 954 = client 9.54
$config['client'] = 792; // 954 = client 9.54
// Download link to client.
$config['client_download'] = 'http://tibiaclient.otslist.eu/download/tibia'. $config['client'] .'.exe';

View File

@@ -2,7 +2,7 @@ FROM debian:bullseye
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && apt-get upgrade -y && apt-get install -y git cmake build-essential libluajit-5.1-dev libmariadb-dev-compat libboost-date-time-dev libboost-system-dev libboost-iostreams-dev libpugixml-dev libcrypto++-dev libfmt-dev zlib1g-dev libgmp-dev libboost-all-dev curl iproute2 apache2 mariadb-client mariadb-server bash-completion vim php
apt update && apt-get upgrade -y && apt-get install -y git cmake build-essential libluajit-5.1-dev libmariadb-dev-compat libboost-date-time-dev libboost-system-dev libboost-iostreams-dev libpugixml-dev libcrypto++-dev libfmt-dev zlib1g-dev libgmp-dev libboost-all-dev curl iproute2 apache2 mariadb-client mariadb-server bash-completion vim php php-apcu
RUN useradd -m -s /bin/bash tibia
RUN echo "tibia:tibia" | chpasswd