From bf5d07169d9c27fd7d0d8f11ed0a52cc04bf5455 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Wed, 18 Aug 2021 14:44:35 +0200 Subject: [PATCH] ReWriten MySQL Module for MariaDB --- MySQL-ModInst.sh => MariaDB-ModInst.sh | 4 +- README.md | 13 +-- Update-PhpMyAdmin.sh | 2 +- conf.sh | 24 +++-- generic.pkg.list | 2 +- mysql-8.0.sh | 137 ------------------------- preconf.sh | 15 +-- 7 files changed, 24 insertions(+), 173 deletions(-) rename MySQL-ModInst.sh => MariaDB-ModInst.sh (93%) delete mode 100644 mysql-8.0.sh diff --git a/MySQL-ModInst.sh b/MariaDB-ModInst.sh similarity index 93% rename from MySQL-ModInst.sh rename to MariaDB-ModInst.sh index fc88ced..b198293 100644 --- a/MySQL-ModInst.sh +++ b/MariaDB-ModInst.sh @@ -56,7 +56,7 @@ unset dist_ver dist APTMODE #Repo Vars -repo=https://git.ictmaatwerk.com/VPS-scripts/MySQL +repo=https://git.ictmaatwerk.com/VPS-scripts/MariaDB branch=master ###Select Module type @@ -84,7 +84,7 @@ fi msg "Starting installer." 8 78 $PKGI curl > $OUTPUT 2>&1 -curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/General/raw/branch/Main/Setup-Repo.sh |repo=init osrel=$shortdist bash > $OUTPUT 2>&1 + ##-------------------------## diff --git a/README.md b/README.md index 48b2d8b..4f8db7b 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,12 @@ -# MySQL +# MariaDB Only install this module, download and run MySQL-ModInst.sh -#### This repo is a dependency of: -``` -* Ubuntu-Web -* Ubuntu-Mail -``` ------ +Alternative for MySQL module (Not validated for Production, and not maintained after testing for debian 11 is conpleted ) +Made for testing Web-V2 on debian 11 since the offical MySQL repo was not avalible yet, and mysql-server did not resolve as a alias + ### Validated to work on: - * Ubuntu 18.04 * Ubuntu 20.04 * Debian 10 + * Debian 11 * CentOS 8 \ No newline at end of file diff --git a/Update-PhpMyAdmin.sh b/Update-PhpMyAdmin.sh index eddc66f..f951621 100644 --- a/Update-PhpMyAdmin.sh +++ b/Update-PhpMyAdmin.sh @@ -1,7 +1,7 @@ #!/bin/bash #MySQL GIT repo Settings -mrepo=https://git.ictmaatwerk.com/VPS-scripts/MySQL +mrepo=https://git.ictmaatwerk.com/VPS-scripts/MariaDB mbranch=master #Removing old version diff --git a/conf.sh b/conf.sh index 91fa3e8..47fbb50 100644 --- a/conf.sh +++ b/conf.sh @@ -1,30 +1,34 @@ ###Fetch Config -mrepo=https://git.ictmaatwerk.com/VPS-scripts/MySQL +mrepo=https://git.ictmaatwerk.com/VPS-scripts/MariaDB mbranch=master if [ -z ${password+x} ]; then echo 'Error $password is not set' > $OUTPUT 2>&1 ; fi if [ -z ${PHPMyadmin+x} ]; then echo 'Error $PHPMyadmin is not set, Setting default OFF' > $OUTPUT 2>&1 && PHPMyadmin=0;fi #check if Var is set +if [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] || [ "$shortdist" = "deb11" ] ; then + mv /etc/mysql/debian-start /tmp/debian-start + mv /etc/mysql/debian.cnf /tmp/debian.cnf +fi + rm -rf /etc/mysql/ /etc/my.cnf.d/ /etc/my.cnf mkdir /etc/mysql/ touch /etc/mysql/my.cnf.fallback curl --retry 7 --retry-delay 5 -s "$mrepo"/raw/branch/"$mbranch"/config/MySQL/mysqld-V8.cnf -o /etc/mysql/my.cnf -if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then - MYSQLSNAME=mysql - systemctl stop $MYSQLSNAME - sed -i 's#MySQLlog#/var/log/mysql/error.log#g' /etc/mysql/my.cnf -elif [ "$shortdist" = "el8" ]; then - MYSQLSNAME=mysqld +MYSQLSNAME=mariadb systemctl stop $MYSQLSNAME +if [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] || [ "$shortdist" = "deb11" ] ; then + sed -i 's#MySQLlog#/var/log/mysql/error.log#g' /etc/mysql/my.cnf + mv /tmp/debian-start /etc/mysql/debian-start + mv /tmp/debian.cnf /etc/mysql/debian.cnf +elif [ "$shortdist" = "el8" ]; then sed -i 's#MySQLlog#/var/log/mysqld.log#g' /etc/mysql/my.cnf fi systemctl start $MYSQLSNAME systemctl enable $MYSQLSNAME -if [ "$shortdist" = "el8" ]; then - mysql -u root -p$(awk '/A temporary password is generated for/ {a=$0} END{ print a }' /var/log/mysqld.log | awk '{print $(NF)}') --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$password'"; -fi +mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$password'; flush privileges"; + if [ $PHPMyadmin = 1 ]; then mkdir -p /usr/share/phpmyadmin/ diff --git a/generic.pkg.list b/generic.pkg.list index aabe309..c040b65 100644 --- a/generic.pkg.list +++ b/generic.pkg.list @@ -1 +1 @@ -mysql-server \ No newline at end of file +mariadb-server \ No newline at end of file diff --git a/mysql-8.0.sh b/mysql-8.0.sh deleted file mode 100644 index ed681f2..0000000 --- a/mysql-8.0.sh +++ /dev/null @@ -1,137 +0,0 @@ -########################### -# MySQL 8.0 Installer # -########################### - - -##-----------------## -# Defining Vars # -##-----------------## - -#Enforcing Legacy Mode -if [ -z ${OUTPUT+x} ]; then OUTPUT='/dev/tty' ; fi -if [ -z ${IMODE+x} ]; then IMODE=l ; fi - -#PackageManager-config - -dist_ver=$(grep --color=never -Po "^VERSION_ID=\K.*" "/etc/os-release") -dist=$(grep --color=never -Po "^ID=\K.*" "/etc/os-release") - -if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then - echo "Ubuntu 18.04 Detected" - PKGM="$APTMODE" - PKGI="${PKGM} install -y --no-install-recommends" - PKGLIST="apt.pkg.list" - shortdist=ubu1804 -elif [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"20.04"* ]]; then - echo "Ubuntu 20.04 Detected" - PKGM="$APTMODE" - PKGI="${PKGM} install -y --no-install-recommends" - PKGLIST="apt.pkg.list" - echo "This os in not supported" - exit - shortdist=ubu2004 -elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then - echo "Debian 10 Detected" - PKGM="$APTMODE" - PKGI="${PKGM} install -y --no-install-recommends" - PKGLIST="apt.pkg.list" - shortdist=deb10 - echo "This os in not supported" - exit -elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then - echo "Centos 8 Detected" - PKGM="dnf" - PKGI="${PKGM} install --setopt=install_weak_deps=False --best -y" - PKGLIST="dnf.pkg.list" - shortdist=el8 - echo "This os in not supported" - exit -else -echo "This os in not supported" -exit -fi - -unset dist_ver dist APTMODE - - -#Repo Vars -mrepo=https://git.ictmaatwerk.com/VPS-scripts/MySQL -mbranch=master - -###Select Module type -mtype=""$mrepo"/raw/branch/"$mbranch"" - -#SelfBuilding Vars -if [ -z ${PKGI+x} ]; then PKGI="${PKGM} install -y" ; fi - - - - -##---------------## -# Functions # -##---------------## - -msg () { -echo "$1" -} - -##--------------------------## -# Installer-Requirements # -##--------------------------## - -msg "Starting installer." 8 78 -$PKGI curl > $OUTPUT 2>&1 -curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/General/raw/branch/Main/Setup-Repo.sh |repo=init osrel=$shortdist bash > $OUTPUT 2>&1 - - - - -##-------------------------## -# Generating APT list # -##-------------------------## -#Webserver specific aptList -if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/generic.pkg.list; then - curl "$mtype"/generic.pkg.list >>/tmp/pkg.list -fi - - -##--------------------## -# Pre-Requirements # -##--------------------## - -msg "Preconfiguring." -$PKGM update -y -$PKGM upgrade -y - - -##-------------------## -# Pre-configuring # -##-------------------## - -if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/preconf.sh; then - source <(curl --retry 7 --retry-delay 5 -s "$mtype"/preconf.sh) -fi - -##-------------## -# Installer # -##-------------## - -$PKGM update -sed -i 's/PHPver/'$phpver'/g' /tmp/pkg.list -cat /tmp/pkg.list | xargs $PKGI - - -##---------------## -# Configuring # -##---------------## - -if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/conf.sh; then - source <(curl --retry 7 --retry-delay 5 -s "$mtype"/conf.sh) -fi - - -##-------## -# end # -##-------## - -msg "done" diff --git a/preconf.sh b/preconf.sh index b61e6c7..50dd7f0 100644 --- a/preconf.sh +++ b/preconf.sh @@ -1,19 +1,6 @@ -mrepo=https://git.ictmaatwerk.com/VPS-scripts/MySQL +mrepo=https://git.ictmaatwerk.com/VPS-scripts/MariaDB mbranch=master if [ -z ${password+x} ]; then echo 'Error $password is not set'; fi -if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then - if [ -z ${DEBIAN_FRONTEND+x} ]; then echo 'dpkg env not set' > $OUTPUT 2>&1 ; else CurDebFrond="$DEBIAN_FRONTEND"; fi #checking and saving DEBIAN_FRONTEND - export DEBIAN_FRONTEND=noninteractive - - debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password $password" - debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password $password" - debconf-set-selections <<< "mysql-community-server mysql-server/default-auth-override select Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)" - - if [ -z ${CurDebFrond+x} ]; then unset DEBIAN_FRONTEND ; else export DEBIAN_FRONTEND=$CurDebFrond; fi #Restore DEBIAN_FRONTEND -fi - -curl --retry 7 --retry-delay 5 -s https://git.ictmaatwerk.com/VPS-scripts/General/raw/branch/Main/Setup-Repo.sh |repo=mysql osrel=$shortdist bash - unset mrepo unset mbranch \ No newline at end of file