#!/bin/bash -e APP_DB='geolite' APP_DB_PASS=$(< /dev/urandom tr -dc _A-Za-z0-9 | head -c32); ADMIN_APP_PASS='geolite'; WWW_DIR='/var/www/html' DATA_DIR='/var/www/data' #CACHE_DIR='/var/www/cache' HNAME=$(hostname -f) touch /root/auth.txt export DEBIAN_FRONTEND=noninteractive if [ ! -f /usr/bin/createdb ]; then echo "Error: Missing PG createdb! First run ./installer/postgres.sh"; exit 1; fi if [ ! -d installer ]; then echo "Usage: ./installer/app-installer.sh" exit 1 fi if [ $# -eq 1 ]; then WWW_DIR="${1}" fi mkdir -p "${WWW_DIR}" # 1. Install packages (assume PG is preinstalled) apt-get -y install apache2 libapache2-mod-php libapache2-mod-fcgid php-{pgsql,mbstring,xml,zip,gd,curl} \ gdal-bin curl \ python3 python3-psycopg2 a2enmod ssl headers expires fcgid cgi rewrite ADMIN_APP_PASS_ENCODED=$(php -r "echo password_hash('${ADMIN_APP_PASS}', PASSWORD_DEFAULT);") sed -i.save "s|ADMIN_APP_PASS|${ADMIN_APP_PASS_ENCODED}|" installer/init.sql # 2. Create db su postgres <incl/const.php < /etc/apache2/sites-available/000-default.conf PHP_VER=$(php -version | head -n 1 | cut -f2 -d' ' | cut -f1,2 -d.) sed -i.save ' s/upload_max_filesize = .*/upload_max_filesize = 10M/ s/post_max_size = .*/post_max_size = 11M/ ' /etc/php/${PHP_VER}/apache2/php.ini a2enmod ssl rewrite systemctl restart apache2 # save 1Gb of space apt-get -y clean all