#!/bin/bash
#######################################################################
# #
# Script to install lggr.io on a FRESH and CLEAN Debian 11 Server. #
# Adjust the Variables section to your needs, or leave the defaults. #
# #
# rev 1.1 - 16.01.2022 ~ lggr.io@bachmann-lan.de #
# rev 1.0 - 02.01.2021 ~ lggr.io@bachmann-lan.de #
# #
#######################################################################
# bash colors
blue='\e[94m'
red='\e[91m'
white='\e[97m'
green='\e[92m'
bluebackground='\e[44m'
redbackground='\e[101m'
reset='\033[0m'
# check if we are root
if [[ $EUID -ne 0 ]]; then
echo -e $red"This script must be run as root!" 2>&1 $reset
echo
exit 1
fi
# header warning
clear
echo -e $redbackground"######################################################################"
echo -e "# #"
echo -e "# !THIS SCRIPT SHOULD ONLY BE EXECUTED ON A CLEAN INSTALLED SERVER! #"
echo -e "# #"
echo -e "######################################################################"$reset
echo
read -p "$(echo -e $green**$white Are you sure to start the installation of the lggr.io Server? "(Y/N)"$reset) " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo
exit 1
else
# header info
function header {
clear
echo -e $bluebackground"######################################################################"
echo -e "# _ _ _ _ _ _ #"
echo -e "# | | __ _ __ _ _ __(_) ___ (_)_ __ ___| |_ __ _| | | #"
echo -e "# | |/ _\` |/ _\` | '__| |/ _ \ | | '_ \/ __| __/ _\` | | | #"
echo -e "# | | (_| | (_| | |_ | | (_) | | | | | \__ \ || (_| | | | #"
echo -e "# |_|\__, |\__, |_(_)|_|\___/ |_|_| |_|___/\__\__,_|_|_| #"
echo -e "# |___/ |___/ #"
echo -e "# #"
echo -e "######################################################################"$reset
}
#######################################################################
# Variables - ADJUST, OR GO WITH THE DEFAULTS #
#######################################################################
locale="en_US" # set language (en_US, de_DE)
lggrwebdir="lggr" # directory to install lggr.io in /var/www/html
lggrwebuser="lggr" # lggr webinterface user
lggrwebpass="lggradmin" # lggr webinterface password
lggrdbname="lggr" # lggr database name
lggrdbuser="lggr" # lggr user (used by syslog-ng for inserting new data)
lggrdbpass="34fGtir3" # lggr database password (used by syslog-ng for inserting new data)
lggrdbviewer="lggrviewer" # lggr logviewer user (used by the web gui for normal viewing)
lggrdbviewerpass="efH34q30" # lggr logviewer password (used by the web gui for normal viewing)
lggrdbadmin="lggradmin" # lggr admin user (used by clean up cron job and for archiving)
lggrdbadminpass="92gHu338" # lggr admin password (used by clean up cron job and for archiving)
# update system
header
echo -e $white*$green update system$reset
apt-get update && apt-get upgrade -y
# install all required packages
header
echo -e $white*$green install all required packages$reset
apt install -y apache2 mariadb-server mariadb-client php7.4 php7.4-cli php7.4-mysql php-redis redis-server syslog-ng libdbd-mysql wget git
#######################################################################
# add de_DE and update locales #
#######################################################################
header
echo -e $white*$green add and update locales$reset
# enable locales de_DE.UTF-8
sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/' /etc/locale.gen
/usr/sbin/locale-gen
#######################################################################
# Apache & PHP #
#######################################################################
header
echo -e $white*$green Apache and PHP$reset
# set date and timezone
sed -i -e "s/^;date.timezone =/date.timezone = Europe\/Berlin/" /etc/php/7.4/apache2/php.ini
sed -i -e "s/^;date.timezone =/date.timezone = Europe\/Berlin/" /etc/php/7.4/cli/php.ini
# create Apache configuration
mv /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf_ORG
cat << EOF > /etc/apache2/sites-available/000-default.conf