From c0ec1bee8431ecea721dc1f9951115aababa1fe3 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Thu, 9 Jan 2020 15:00:58 +0100 Subject: [PATCH] Upload files to '' --- MySQL-ModInst.sh | 110 +++++++++++++++++++++++++++++++++++++++++++++++ apt.list | 1 + conf.sh | 47 ++++++++++++++++++++ mysql-8.0.sh | 96 +++++++++++++++++++++++++++++++++++++++++ preconf.sh | 27 ++++++++++++ 5 files changed, 281 insertions(+) create mode 100644 MySQL-ModInst.sh create mode 100644 apt.list create mode 100644 conf.sh create mode 100644 mysql-8.0.sh create mode 100644 preconf.sh diff --git a/MySQL-ModInst.sh b/MySQL-ModInst.sh new file mode 100644 index 0000000..5ab6fd9 --- /dev/null +++ b/MySQL-ModInst.sh @@ -0,0 +1,110 @@ +############################# +# MySQL ModuleInstaller # +############################# + + +##-----------------## +# Defining Vars # +##-----------------## + +#MySQL module specific Var +PHPMyadmin=1 +phpmyadminver="4.9.2" + +#SMI specific Vars +SMI_config=no + +#Enforcing Legacy Mode +PKGM="apt" +OUTPUT='/dev/tty' +IMODE=l + +#Web-V2 Vars +password=TestP@ssword123 + +#Repo Vars +repo=https://git.ictmaatwerk.com/VPS-scripts/MySQL +branch=master + +###Select Module type +mtype=""$repo"/raw/branch/"$branch"" + +#SelfBuilding Vars +PKGI="${PKGM} install -y" + + + +##---------------## +# Functions # +##---------------## + +msg () { +echo "$1" +} + +#Checking if Config var has been set +if [ $SMI_config = no ]; then +msg "Script is not configured" +exit +fi + + +##--------------------------## +# Installer-Requirements # +##--------------------------## + +msg "Starting installer." 8 78 +$PKGM update > $OUTPUT 2>&1 +$PKGI curl > $OUTPUT 2>&1 + + +##-------------------------## +# Generating APT list # +##-------------------------## +#Webserver specific aptList +if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/apt.list; then + curl "$mtype"/apt.list >>/tmp/apt.list +fi + + +##--------------------## +# Pre-Requirements # +##--------------------## + +msg "Preconfiguring." +$PKGI software-properties-common gnupg > $OUTPUT 2>&1 +$PKGM update +$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/apt.list +cat /tmp/apt.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/apt.list b/apt.list new file mode 100644 index 0000000..aabe309 --- /dev/null +++ b/apt.list @@ -0,0 +1 @@ +mysql-server \ No newline at end of file diff --git a/conf.sh b/conf.sh new file mode 100644 index 0000000..c6ecb53 --- /dev/null +++ b/conf.sh @@ -0,0 +1,47 @@ +###Fetch Config +mrepo=https://git.ictmaatwerk.com/VPS-scripts/MySQL +mbranch=master + +if [ -z ${PHPMyadmin+x} ]; then echo 'Error $PHPMyadmin is not set, Setting default OFF' && PHPMyadmin=0;fi #check if Var is set +if [ -z ${phpmyadminver+x} ]; then echo 'Error $phpmyadminver is not set, Setting default' && phpmyadminver="4.9.2" ; fi #check if Var is set + +systemctl stop mysql + +rm /etc/mysql/mysql.conf.d/mysqld.cnf +wget -q -t7 "$repo"/raw/branch/"$branch"/config/MySQL/mysqld-V8.cnf -O /etc/mysql/mysql.conf.d/mysqld.cnf + +systemctl start mysql +systemctl enable mysql + + +if [ $PHPMyadmin = 1 ]; then + mkdir -p /usr/share/phpmyadmin/ + mkdir -p /etc/phpmyadmin + mkdir -p /var/lib/phpmyadmin/tmp/ + wget -q -t7 https://files.phpmyadmin.net/phpMyAdmin/$phpmyadminver/phpMyAdmin-$phpmyadminver-all-languages.tar.gz -O /tmp/phpMyAdmin.tar.gz + tar xzf /tmp/phpMyAdmin.tar.gz -C /tmp/ + mv /tmp/phpMyAdmin-$phpmyadminver-all-languages/* /usr/share/phpmyadmin + + wget -q -t7 "$mrepo"/raw/branch/"$mbranch"/config/phpmyadmin/vendor_config.php -O /usr/share/phpmyadmin/libraries/vendor_config.php + wget -q -t7 "$mrepo"/raw/branch/"$mbranch"/config/phpmyadmin/config.footer.inc.php -O /etc/phpmyadmin/config.footer.inc.php + wget -q -t7 "$mrepo"/raw/branch/"$mbranch"/config/phpmyadmin/config.header.inc.php -O /etc/phpmyadmin/config.header.inc.php + wget -q -t7 "$mrepo"/raw/branch/"$mbranch"/config/phpmyadmin/config.inc.php -O /etc/phpmyadmin/config.inc.php + touch /var/lib/phpmyadmin/config.inc.php + touch /etc/phpmyadmin/config-db.php + + chown -R www-data:www-data /var/lib/phpmyadmin/ + + blowsec=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) + echo -e "" >> /var/lib/phpmyadmin/blowfish_secret.inc.php + + mysql -u root --password="$password" < /usr/share/phpmyadmin/sql/create_tables.sql +fi + + +#Running Spesific WebPReconf +if curl --output /dev/null --silent --head --fail "$mrepo"/raw/branch/"$mbranch"/"$webserv"-conf.sh; then + source <(curl -s "$mrepo"/raw/branch/"$mbranch"/"$webserv"-conf.sh) +fi + +unset mrepo +unset mbranch diff --git a/mysql-8.0.sh b/mysql-8.0.sh new file mode 100644 index 0000000..9f1813c --- /dev/null +++ b/mysql-8.0.sh @@ -0,0 +1,96 @@ +########################### +# MySQL 8.0 Installer # +########################### + + +##-----------------## +# Defining Vars # +##-----------------## + +#Enforcing Legacy Mode +if [ -z ${PKGM+x} ]; then PKGM="apt" ; fi +if [ -z ${OUTPUT+x} ]; then OUTPUT='/dev/tty' ; fi +if [ -z ${IMODE+x} ]; then IMODE=l ; fi + + + +#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 +$PKGM update > $OUTPUT 2>&1 +$PKGI curl > $OUTPUT 2>&1 + + +##-------------------------## +# Generating APT list # +##-------------------------## +#Webserver specific aptList +if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$mtype"/apt.list; then + curl "$mtype"/apt.list >>/tmp/apt.list +fi + + +##--------------------## +# Pre-Requirements # +##--------------------## + +msg "Preconfiguring." +$PKGI software-properties-common gnupg > $OUTPUT 2>&1 +$PKGM update +$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/apt.list +cat /tmp/apt.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 new file mode 100644 index 0000000..fbd7ce9 --- /dev/null +++ b/preconf.sh @@ -0,0 +1,27 @@ +mrepo=https://git.ictmaatwerk.com/VPS-scripts/MySQL +mbranch=master +if [ -z ${DEBIAN_FRONTEND+x} ]; then echo 'env not set' ; else CurDebFrond="$DEBIAN_FRONTEND"; fi #checking and saving DEBIAN_FRONTEND +export DEBIAN_FRONTEND=noninteractive + +if [ -z ${password+x} ]; then echo 'Error $password is not set'; fi + +debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/repo-codename select bionic' +debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/repo-distro select ubuntu' +debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/repo-url string http://repo.mysql.com/apt/' +debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-preview select ' +debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-product select Ok' +debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-server select mysql-8.0' +debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-tools select ' +debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/unsupported-platform select abort' +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)" + +$PKGM update +wget -q -t7 https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb -O /tmp/mysql-apt-conf.deb +dpkg -i /tmp/mysql-apt-conf.deb > $OUTPUT 2>&1 + + +if [ -z ${CurDebFrond+x} ]; then unset DEBIAN_FRONTEND ; else export DEBIAN_FRONTEND=$CurDebFrond; fi #Restore DEBIAN_FRONTEND +unset mrepo +unset mbranch