Files
VPS-scripts_MariaDB/conf.sh
Bram Prieshof 6ebd297a23 Fixed oopsie
2020-09-30 13:17:36 +02:00

60 lines
2.6 KiB
Bash

###Fetch Config
mrepo=https://git.ictmaatwerk.com/VPS-scripts/MySQL
mbranch=master
if [ -z ${password+x} ]; then echo 'Error $password is not set'; fi
if [ -z ${PHPMyadmin+x} ]; then echo 'Error $PHPMyadmin is not set, Setting default OFF' && PHPMyadmin=0;fi #check if Var is set
rm -rf /etc/mysql/ /etc/my.cnf.d/ /etc/my.cnf
mkdir /etc/mysql/
wget -q -t7 "$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" = "cent8" ]; then
MYSQLSNAME=mysqld
systemctl stop $MYSQLSNAME
sed -i 's#MySQLlog#/var/log/mysqld.log#g' /etc/mysql/my.cnf
fi
systemctl start $MYSQLSNAME
systemctl enable $MYSQLSNAME
if [ "$shortdist" = "cent8" ]; 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
if [ $PHPMyadmin = 1 ]; then
mkdir -p /usr/share/phpmyadmin/
mkdir -p /etc/phpmyadmin
mkdir -p /var/log/PhpMyAdmin
mkdir -p /var/lib/phpmyadmin/tmp/
wget -q -t7 http://mirror.nxdi.nl/resources/phpmyadmin/phpMyAdmin-latest-english.tar.gz -O /tmp/phpmya.tar.gz
tar -C /usr/share/phpmyadmin -xzf /tmp/phpmya.tar.gz --strip 1
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/
chown -R www-data:www-data /var/lib/phpmyadmin/tmp/
blowsec=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo -e "<?php\n\n\$cfg['blowfish_secret'] = '$blowsec';\n\n?>" >> /var/lib/phpmyadmin/blowfish_secret.inc.php
mysql -u root --password="$password" < /usr/share/phpmyadmin/sql/create_tables.sql > $OUTPUT 2>&1
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