From fc16e65de60d075e623f02194f815e121699dffb Mon Sep 17 00:00:00 2001 From: Maxwell Power Date: Sat, 7 Jul 2018 00:25:55 -0600 Subject: [PATCH] Version to 1.2.0 --- CHANGELOG.md | 11 ++- README.md | 14 ++-- install.sh | 174 ++++++++++++++++++++++++++----------------- resources/from2_1.sh | 3 +- resources/le.sh | 3 +- resources/php7.2.sh | 63 ++++++++++++++++ 6 files changed, 190 insertions(+), 78 deletions(-) create mode 100644 resources/php7.2.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index fad2e4e..df61eca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# Acuparse Installer +# Acuparse Installation Script # Change Log All notable changes to this project will be documented in this file. @@ -8,9 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [1.2.0] - 2018-07-06 +### Changed +- Removed Ubuntu 16.04 LTS support and replaced with 18.04 LTS. +- Support for PHP 7.2. + ## [1.1.0] - 2018-01-31 ### Added -- SSL & Let's Encrypt Support +- SSL & Let's Encrypt Support. ## [1.0.1] - 2017-08-08 ### Changed @@ -18,4 +23,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [1.0.0] - 2017-03-13 ### Added -- Initial open source release +- Initial open source release. diff --git a/README.md b/README.md index 09d02d7..5144e9f 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ -# Acuparse Installer -## Script to install Acuparse on a clean Debian based server. -> **Info:** Installer currently supports Debian Stretch(9) and Ubuntu 16.04 LTS. +# Acuparse Installation Script +## Used when installing Acuparse on a clean Debian based server. +### See the [Acuparse Repository](https://github.com/acuparse/acuparse) for more details. + +> **Info:** Supports Debian Stretch(9), Ubuntu 18.04 LTS, and Raspbian Stretch(9). # Usage: -**Requires LAMP stack. Some PHP, Apache, and GNU/Linux experience recommended.** +**Requires LAMP stack. Some PHP, Apache, and GNU/Linux experience is recommended.** -## Quick Install: +# Quick Install: Install your base operating system and update. Then download and run the installer. -``` wget https://raw.githubusercontent.com/acuparse/installer/master/install.sh && sudo sh install.sh ``` +`wget https://raw.githubusercontent.com/acuparse/installer/master/install.sh && sudo sh install.sh | tee ~/acuparse.log` # Licencing: This installer is licensed under the MIT license. diff --git a/install.sh b/install.sh index 21ba9ba..13f6514 100644 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/bin/sh ## -# Acuparse Installer +# Acuparse Installation Script # @copyright Copyright (C) 2015-2018 Maxwell Power # @author Maxwell Power # @license MIT @@ -24,90 +24,119 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. ## -printf "This script is designed to be run on a freshly installed Debian Stretch, Ubuntu 16.04 LTS, or Raspbian System\n\n" +printf "Acuparse Installation Script v1.2.0\n\n" OS=$(cat /etc/*release | grep '^ID=' | awk -F= '{ print $2 }') if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] || [ "$OS" = "raspbian" ]; then - + cd ~ if [ `id -u` != "0" ]; then - echo "Sorry, you are not root." + printf "ERROR: Installer must be run as root!\n" exit 1 fi - cd ~ - printf "Acuparse Installation Script\n\n" - - printf "First we need some database credentials ...\n" - - printf "Type your MySQL ROOT password, followed by [ENTER]:\n" + printf "Pre Install\n\n" + printf "Make a note of your Acuparse database password.\nYou will need it to complete your install!\n\n" + + printf "When ready, Press [ENTER] to continue\n" + read READY + + printf "Enter MySQL ROOT password, followed by [ENTER]:\n" stty -echo - read ROOTPW + read MYSQL_ROOT_PASSWORD stty echo - printf "Choose a password for the Acuparse database, followed by [ENTER]:\n" + printf "Enter ACUPARSE database password, followed by [ENTER]:\n" stty -echo - read DBPW + read ACUPARSE_DATABASE_PASSWORD stty echo - printf "Configure Mail?, y/N, followed by [ENTER]:\n" - read MAIL - - printf "Configure SSL with Let's Encrypt?, y/N, followed by [ENTER]:\n" - read LESSL - - if [ "$LESSL" = "y" ] || [ "$LESSL" = "Y" ]; then - printf "Enter your domain for SSL cert, followed by [ENTER]:\n" - read LE_DOMAIN + printf "Install Exim mail server?, y/N, followed by [ENTER]:\n" + read EXIM_ENABLED + + printf "Install phpMyAdmin?, y/N, followed by [ENTER]:\n" + read PHPMYADMIN_ENABLED + + printf "Configure SSL using Let's Encrypt?, y/N, followed by [ENTER]:\n" + read LE_SSL_ENABLED + + if [ "$LE_SSL_ENABLED" = "y" ] || [ "$LE_SSL_ENABLED" = "Y" ]; then + printf "\nConfiguring Let's Encrypt\n\n" + + printf "Enter FQDN(example.com/hostname.example.com), followed by [ENTER]:\n" + read LE_FQDN + + printf "Also secure www.$LE_FQDN?, y/N, followed by [ENTER]:\n" + read LE_SECURE_WWW + + if [ "$LE_SECURE_WWW" = "y" ] || [ "$LE_SECURE_WWW" = "Y" ]; then + LE_SECURE_DOMAINS="-d $LE_FQDN -d www.$LE_FQDN" + else + LE_SECURE_DOMAINS="-d $LE_FQDN" + fi - printf "Enter your email for SSL cert, followed by [ENTER]:\n" + printf "Certificate Email Address, followed by [ENTER]:\n" read LE_EMAIL printf "Redirect HTTP to HTTPS?, y/N, followed by [ENTER]:\n" - read REDIRECT + read LE_REDIRECT_ENABLED - if [ "$REDIRECT" = "y" ] || [ "$REDIRECT" = "Y" ]; then + if [ "$LE_REDIRECT_ENABLED" = "y" ] || [ "$LE_REDIRECT_ENABLED" = "Y" ]; then LE_REDIRECT="redirect" else LE_REDIRECT="no-redirect" fi - printf "Also secure www.$LE_DOMAIN?, y/N, followed by [ENTER]:\n" - read SECURE_WWW - - if [ "$SECURE_WWW" = "y" ] || [ "$SECURE_WWW" = "Y" ]; then - LE_SECURE_DOMAINS="-d $LE_DOMAIN -d www.$LE_DOMAIN" - else - LE_SECURE_DOMAINS="-d $LE_DOMAIN" - fi + fi + + printf "\nInstallation Ready!\n\nThis process will install and configure packages.\nThis is your last chance to exit.\n\n" + + printf "When ready, Press [ENTER] to continue\n" + read READY + + printf "Installing Packages\n\n" + sleep 1 + echo "mysql-server mysql-server/root_password password $MYSQL_ROOT_PASSWORD" | debconf-set-selections + echo "mysql-server mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD" | debconf-set-selections + + if [ "$OS" = "debian" ] || [ "$OS" = "raspbian" ]; then + printf "DEBIAN DETECTED! Adding DEB.SURY.ORG repository.\n" + apt-get install ca-certificates apt-transport-https -y + wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add - + echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list fi - printf "Install Packages\n" - sleep 2 - echo "mysql-server mysql-server/root_password password $ROOTPW" | sudo debconf-set-selections - echo "mysql-server mysql-server/root_password_again password $ROOTPW" | sudo debconf-set-selections - - apt-get update && apt-get install git ntp imagemagick exim4 apache2 mysql-server php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-gd php7.0-curl php7.0-json php7.0-cli -y + apt-get update + apt-get upgrade -y + apt-get install git ntp imagemagick exim4 apache2 mysql-server php7.2 libapache2-mod-php7.2 php7.2-mysql php7.2-gd php7.2-curl php7.2-json php7.2-cli php7.2-common -y - if [ "$MAIL" = "y" ] || [ "$MAIL" = "Y" ]; then - printf "Configure Mail\n" - sleep 2 + if [ "$PHPMYADMIN_ENABLED" = "y" ] || [ "$PHPMYADMIN_ENABLED" = "Y" ]; then + printf "Installing phpMyAdmin\n" + echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections + echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | debconf-set-selections + echo "phpmyadmin phpmyadmin/mysql/app-pass password " | debconf-set-selections + apt-get install phpmyadmin -y + fi + + if [ "$EXIM_ENABLED" = "y" ] || [ "$EXIM_ENABLED" = "Y" ]; then + printf "Installing Exim mail server\n" + sleep 1 apt-get install exim4 -y + printf "Launch exim configuration\n" dpkg-reconfigure exim4-config fi + printf "END: Packages\n\n" - printf "Done Installing Packages\n\n" - - printf "Getting source from Git repo\n" - sleep 2 + printf "Install Acuparse from git\n" + sleep 1 git init /opt/acuparse cd /opt/acuparse if [ -z ${1+x} ]; then GITREPO="master"; else GITREPO=$1; fi git remote add -t ${GITREPO} -f origin https://github.com/acuparse/acuparse.git git checkout ${GITREPO} chown -R www-data:www-data /opt/acuparse/src - printf "Done with Git Repo\n\n" + printf "END: Acuparse\n\n" - printf "Configuring website\n" - sleep 2 + printf "Configuring Apache\n" + sleep 1 a2dissite 000-default.conf > /dev/null 2>&1 rm /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/default-ssl.conf cp /opt/acuparse/config/acuparse.conf /etc/apache2/sites-available/ @@ -116,41 +145,52 @@ if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] || [ "$OS" = "raspbian" ]; then a2enmod ssl > /dev/null 2>&1 a2ensite acuparse.conf > /dev/null 2>&1 a2ensite acuparse-ssl.conf > /dev/null 2>&1 - systemctl restart apache2.service - if [ "$LESSL" = "y" ] || [ "$LESSL" = "Y" ]; then + if [ "$LE_SSL_ENABLED" = "y" ] || [ "$LE_SSL_ENABLED" = "Y" ]; then printf "Deploying Let's Encrypt Certificate\n" - sleep 2 + sleep 1 systemctl stop apache2.service if [ "$OS" = "ubuntu" ]; then + printf "UBUNTU DETECTED! Using certbot PPA\n" apt-get install software-properties-common -y add-apt-repository ppa:certbot/certbot -y apt-get update > /dev/null 2>&1 fi apt-get install python-certbot-apache -y - sed -i "s/#ServerName/ServerName $LE_DOMAIN\n ServerAlias www.$LE_DOMAIN/g" /etc/apache2/sites-available/acuparse-ssl.conf + sed -i "s/#ServerName/ServerName $LE_FQDN\n ServerAlias www.$LE_FQDN/g" /etc/apache2/sites-available/acuparse-ssl.conf if [ "$GITREPO" != "master" ]; then + printf "Requesting cert from STAGING server\n" certbot -n --authenticator standalone --installer apache --agree-tos --${LE_REDIRECT} --email ${LE_EMAIL} ${LE_SECURE_DOMAINS} --staging else + printf "Requesting cert from PRODUCTION server\n" certbot -n --authenticator standalone --installer apache --agree-tos --${LE_REDIRECT} --email ${LE_EMAIL} ${LE_SECURE_DOMAINS} fi - systemctl stop apache2.service fi - printf "Done with Website Config\n\n" + systemctl restart apache2.service + printf "END: Apache Config\n\n" - printf "Setting up Acuparse database\n" - sleep 2 - mysql -uroot -p${ROOTPW} -e "DELETE FROM mysql.user WHERE User='';DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';FLUSH PRIVILEGES;" > /dev/null 2>&1 - mysql -uroot -p${ROOTPW} -e "CREATE DATABASE acuparse; GRANT ALL PRIVILEGES ON acuparse.* TO acuparse@localhost IDENTIFIED BY '$DBPW'; GRANT SUPER, EVENT ON *.* TO acuparse@localhost" > /dev/null 2>&1 - printf "Done with Database\n\n" + printf "Creating Acuparse database\n" + sleep 1 + mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "DELETE FROM mysql.user WHERE User='';DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';FLUSH PRIVILEGES;" > /dev/null 2>&1 + mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "CREATE DATABASE acuparse; GRANT ALL PRIVILEGES ON acuparse.* TO acuparse@localhost IDENTIFIED BY '$ACUPARSE_DATABASE_PASSWORD'; GRANT SUPER, EVENT ON *.* TO acuparse@localhost" > /dev/null 2>&1 - printf "Installing Cronjob\n" - sleep 2 + printf "Installing Cron\n" + sleep 1 (crontab -l 2>/dev/null; echo "* * * * * php /opt/acuparse/cron/cron.php > /opt/acuparse/logs/cron.log 2>&1") | crontab - - printf "Done with Cron\n\n" - - printf "Setup Complete!\nConnect to your system using a browser to continue configuration.\n" + printf "Running Cleanup\n" + apt-get autoremove -y + apt-get clean -y + apt-get purge -y + systemctl restart apache2.service + + printf "\nAcuparse Installation Complete!\n\n" + + printf "Your system IP addresse(s):\n" + hostname -I + printf "\nYour system hostname(s):\n" + hostname -A + printf "\nConnect to your IP/Hostname with a browser to continue configuration.\n" else - printf "NO Debian Based OS!" + printf "ERROR: This script is designed to be run on a freshly installed Debian Stretch(9), Ubuntu 18.04 LTS, or Raspbian Stretch(9) based system\n" fi -exit +exit \ No newline at end of file diff --git a/resources/from2_1.sh b/resources/from2_1.sh index 801f945..63d897b 100644 --- a/resources/from2_1.sh +++ b/resources/from2_1.sh @@ -1,7 +1,8 @@ #!/bin/sh ## -# Acuparse 2.1 Migration Script +# Acuparse Installation Script +# 2.1 Apache Migration Tasks # @copyright Copyright (C) 2015-2018 Maxwell Power # @author Maxwell Power # @license MIT diff --git a/resources/le.sh b/resources/le.sh index 1e4756d..48a396c 100644 --- a/resources/le.sh +++ b/resources/le.sh @@ -1,7 +1,8 @@ #!/bin/sh ## -# Acuparse Let's Encrypt Installer +# Acuparse Installation Script +# Let's Encrypt Installer # @copyright Copyright (C) 2015-2018 Maxwell Power # @author Maxwell Power # @license MIT diff --git a/resources/php7.2.sh b/resources/php7.2.sh new file mode 100644 index 0000000..d95e395 --- /dev/null +++ b/resources/php7.2.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +## +# Acuparse Installation Script +# PHP 7.0 to 7.2 Upgrader +# @copyright Copyright (C) 2015-2018 Maxwell Power +# @author Maxwell Power +# @license MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +## + +if [ `id -u` != "0" ]; then + echo "Sorry, you are not root." + exit 1 +fi + +printf "Upgrading PHP to 7.2\n\n" + +printf "Installation Ready!\n\nThis process will remove PHP 7.0 then reinstall PHP 7.2./nThis is your last chance to exit./n/n" + +printf "When ready, Press [ENTER] to continue\n" +read READY + +OS=$(cat /etc/*release | grep '^ID=' | awk -F= '{ print $2 }') +printf "Removing PHP 7.0\n\n" +sleep 1 +apt-get remove php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-gd php7.0-curl php7.0-json php7.0-cli -y + +if [ "$OS" = "debian" ] || [ "$OS" = "raspbian" ]; then + printf "DEBIAN DETECTED!\nAdding DEB.SURY.ORG repository.\n\n" + apt-get install ca-certificates apt-transport-https -y + wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add - + echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list +fi +apt-get update +printf "\nInstalling PHP 7.2\n\n" +sleep 1 +apt-get install php7.2 libapache2-mod-php7.2 php7.2-mysql php7.2-gd php7.2-curl php7.2-json php7.2-cli php7.2-common -y + +printf "\nCleanup APT\n\n" +sleep 1 +apt purge +apt clean +apt autoremove -y + +printf "\nDONE!\n"