#!/bin/bash apt install -y mariadb-server apache2 unzip apt install -y php7.4 php7.4-gd php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php-geoip # apt install php php-curl php-gd php-cli php-mysql php-xml php-mbstring DBNAME=$(whiptail --title "DB" --inputbox "DB Name :" 0 30 "matomo" 3>&1 1>&2 2>&3) DBUSER=$(whiptail --title "DB" --inputbox "DB User :" 0 30 "matomo" 3>&1 1>&2 2>&3) DBPASS=$(whiptail --title "DB" --inputbox "DB Pass :" 0 30 "matomo" 3>&1 1>&2 2>&3) mysql -e "CREATE DATABASE ${DBNAME};CREATE USER '${DBUSER}'@'localhost' IDENTIFIED BY '${DBPASS}';GRANT ALL ON ${DBNAME}.* TO '${DBUSER}'@'localhost' WITH GRANT OPTION;FLUSH PRIVILEGES;" a2dissite 000-default a2dissite default-ssl.conf a2enmod ssl mkdir matomo cd matomo wget https://builds.matomo.org/matomo.zip && unzip matomo.zip mv matomo /var/www chown -R www-data:www-data /var/www/matomo cd .. rm -R matomo cat > /etc/apache2/sites-available/matomo.conf << "EOF" ServerAdmin webmaster@localhost DocumentRoot /var/www/matomo ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SSLEngine on SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key SSLOptions +StdEnvVars SSLOptions +StdEnvVars EOF systemctl reload apache2 a2ensite matomo systemctl restart apache2 if [ -f "/etc/iptables/rules.v4" ]; then sed -i '/^-A INPUT -i lo -j ACCEPT.*/a -A INPUT -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT' /etc/iptables/rules.v4 sed -i '/^-A INPUT -i lo -j ACCEPT.*/a # Matomo' /etc/iptables/rules.v4 iptables-restore /etc/iptables/rules.v4 fi