11#! /bin/sh
22
33# #
4- # Acuparse Installer
4+ # Acuparse Installation Script
55# @copyright Copyright (C) 2015-2018 Maxwell Power
66# @author Maxwell Power <[email protected] >77# @license MIT
2424# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525# SOFTWARE.
2626# #
27- printf " This script is designed to be run on a freshly installed Debian Stretch, Ubuntu 16.04 LTS, or Raspbian System \n\n"
27+ printf " Acuparse Installation Script v1.2.0 \n\n"
2828
2929OS=$( cat /etc/* release | grep ' ^ID=' | awk -F= ' { print $2 }' )
3030if [ " $OS " = " debian" ] || [ " $OS " = " ubuntu" ] || [ " $OS " = " raspbian" ]; then
31-
31+ cd ~
3232 if [ ` id -u` != " 0" ]; then
33- echo " Sorry, you are not root. "
33+ printf " ERROR: Installer must be run as root!\n "
3434 exit 1
3535 fi
3636
37- cd ~
38- printf " Acuparse Installation Script\n\n"
39-
40- printf " First we need some database credentials ...\n"
41-
42- printf " Type your MySQL ROOT password, followed by [ENTER]:\n"
37+ printf " Pre Install\n\n"
38+ printf " Make a note of your Acuparse database password.\nYou will need it to complete your install!\n\n"
39+
40+ printf " When ready, Press [ENTER] to continue\n"
41+ read READY
42+
43+ printf " Enter MySQL ROOT password, followed by [ENTER]:\n"
4344 stty -echo
44- read ROOTPW
45+ read MYSQL_ROOT_PASSWORD
4546 stty echo
4647
47- printf " Choose a password for the Acuparse database, followed by [ENTER]:\n"
48+ printf " Enter ACUPARSE database password , followed by [ENTER]:\n"
4849 stty -echo
49- read DBPW
50+ read ACUPARSE_DATABASE_PASSWORD
5051 stty echo
5152
52- printf " Configure Mail?, y/N, followed by [ENTER]:\n"
53- read MAIL
54-
55- printf " Configure SSL with Let's Encrypt?, y/N, followed by [ENTER]:\n"
56- read LESSL
57-
58- if [ " $LESSL " = " y" ] || [ " $LESSL " = " Y" ]; then
59- printf " Enter your domain for SSL cert, followed by [ENTER]:\n"
60- read LE_DOMAIN
53+ printf " Install Exim mail server?, y/N, followed by [ENTER]:\n"
54+ read EXIM_ENABLED
55+
56+ printf " Install phpMyAdmin?, y/N, followed by [ENTER]:\n"
57+ read PHPMYADMIN_ENABLED
58+
59+ printf " Configure SSL using Let's Encrypt?, y/N, followed by [ENTER]:\n"
60+ read LE_SSL_ENABLED
61+
62+ if [ " $LE_SSL_ENABLED " = " y" ] || [ " $LE_SSL_ENABLED " = " Y" ]; then
63+ printf " \nConfiguring Let's Encrypt\n\n"
64+
65+ printf " Enter FQDN(example.com/hostname.example.com), followed by [ENTER]:\n"
66+ read LE_FQDN
67+
68+ printf " Also secure www.$LE_FQDN ?, y/N, followed by [ENTER]:\n"
69+ read LE_SECURE_WWW
70+
71+ if [ " $LE_SECURE_WWW " = " y" ] || [ " $LE_SECURE_WWW " = " Y" ]; then
72+ LE_SECURE_DOMAINS=" -d $LE_FQDN -d www.$LE_FQDN "
73+ else
74+ LE_SECURE_DOMAINS=" -d $LE_FQDN "
75+ fi
6176
62- printf " Enter your email for SSL cert , followed by [ENTER]:\n"
77+ printf " Certificate Email Address , followed by [ENTER]:\n"
6378 read LE_EMAIL
6479
6580 printf " Redirect HTTP to HTTPS?, y/N, followed by [ENTER]:\n"
66- read REDIRECT
81+ read LE_REDIRECT_ENABLED
6782
68- if [ " $REDIRECT " = " y" ] || [ " $REDIRECT " = " Y" ]; then
83+ if [ " $LE_REDIRECT_ENABLED " = " y" ] || [ " $LE_REDIRECT_ENABLED " = " Y" ]; then
6984 LE_REDIRECT=" redirect"
7085 else
7186 LE_REDIRECT=" no-redirect"
7287 fi
73- printf " Also secure www.$LE_DOMAIN ?, y/N, followed by [ENTER]:\n"
74- read SECURE_WWW
75-
76- if [ " $SECURE_WWW " = " y" ] || [ " $SECURE_WWW " = " Y" ]; then
77- LE_SECURE_DOMAINS=" -d $LE_DOMAIN -d www.$LE_DOMAIN "
78- else
79- LE_SECURE_DOMAINS=" -d $LE_DOMAIN "
80- fi
88+ fi
89+
90+ printf " \nInstallation Ready!\n\nThis process will install and configure packages.\nThis is your last chance to exit.\n\n"
91+
92+ printf " When ready, Press [ENTER] to continue\n"
93+ read READY
94+
95+ printf " Installing Packages\n\n"
96+ sleep 1
97+ echo " mysql-server mysql-server/root_password password $MYSQL_ROOT_PASSWORD " | debconf-set-selections
98+ echo " mysql-server mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD " | debconf-set-selections
99+
100+ if [ " $OS " = " debian" ] || [ " $OS " = " raspbian" ]; then
101+ printf " DEBIAN DETECTED! Adding DEB.SURY.ORG repository.\n"
102+ apt-get install ca-certificates apt-transport-https -y
103+ wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
104+ echo " deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list
81105 fi
82106
83- printf " Install Packages\n"
84- sleep 2
85- echo " mysql-server mysql-server/root_password password $ROOTPW " | sudo debconf-set-selections
86- echo " mysql-server mysql-server/root_password_again password $ROOTPW " | sudo debconf-set-selections
87-
88- 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
107+ apt-get update
108+ apt-get upgrade -y
109+ 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
89110
90- if [ " $MAIL " = " y" ] || [ " $MAIL " = " Y" ]; then
91- printf " Configure Mail\n"
92- sleep 2
111+ if [ " $PHPMYADMIN_ENABLED " = " y" ] || [ " $PHPMYADMIN_ENABLED " = " Y" ]; then
112+ printf " Installing phpMyAdmin\n"
113+ echo " phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections
114+ echo " phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | debconf-set-selections
115+ echo " phpmyadmin phpmyadmin/mysql/app-pass password " | debconf-set-selections
116+ apt-get install phpmyadmin -y
117+ fi
118+
119+ if [ " $EXIM_ENABLED " = " y" ] || [ " $EXIM_ENABLED " = " Y" ]; then
120+ printf " Installing Exim mail server\n"
121+ sleep 1
93122 apt-get install exim4 -y
123+ printf " Launch exim configuration\n"
94124 dpkg-reconfigure exim4-config
95125 fi
126+ printf " END: Packages\n\n"
96127
97- printf " Done Installing Packages\n\n"
98-
99- printf " Getting source from Git repo\n"
100- sleep 2
128+ printf " Install Acuparse from git\n"
129+ sleep 1
101130 git init /opt/acuparse
102131 cd /opt/acuparse
103132 if [ -z ${1+x} ]; then GITREPO=" master" ; else GITREPO=$1 ; fi
104133 git remote add -t ${GITREPO} -f origin https://github.com/acuparse/acuparse.git
105134 git checkout ${GITREPO}
106135 chown -R www-data:www-data /opt/acuparse/src
107- printf " Done with Git Repo \n\n"
136+ printf " END: Acuparse \n\n"
108137
109- printf " Configuring website \n"
110- sleep 2
138+ printf " Configuring Apache \n"
139+ sleep 1
111140 a2dissite 000-default.conf > /dev/null 2>&1
112141 rm /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/default-ssl.conf
113142 cp /opt/acuparse/config/acuparse.conf /etc/apache2/sites-available/
@@ -116,41 +145,52 @@ if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] || [ "$OS" = "raspbian" ]; then
116145 a2enmod ssl > /dev/null 2>&1
117146 a2ensite acuparse.conf > /dev/null 2>&1
118147 a2ensite acuparse-ssl.conf > /dev/null 2>&1
119- systemctl restart apache2.service
120- if [ " $LESSL " = " y" ] || [ " $LESSL " = " Y" ]; then
148+ if [ " $LE_SSL_ENABLED " = " y" ] || [ " $LE_SSL_ENABLED " = " Y" ]; then
121149 printf " Deploying Let's Encrypt Certificate\n"
122- sleep 2
150+ sleep 1
123151 systemctl stop apache2.service
124152 if [ " $OS " = " ubuntu" ]; then
153+ printf " UBUNTU DETECTED! Using certbot PPA\n"
125154 apt-get install software-properties-common -y
126155 add-apt-repository ppa:certbot/certbot -y
127156 apt-get update > /dev/null 2>&1
128157 fi
129158 apt-get install python-certbot-apache -y
130- sed -i " s/#ServerName/ServerName $LE_DOMAIN \n ServerAlias www.$LE_DOMAIN /g" /etc/apache2/sites-available/acuparse-ssl.conf
159+ sed -i " s/#ServerName/ServerName $LE_FQDN \n ServerAlias www.$LE_FQDN /g" /etc/apache2/sites-available/acuparse-ssl.conf
131160 if [ " $GITREPO " != " master" ]; then
161+ printf " Requesting cert from STAGING server\n"
132162 certbot -n --authenticator standalone --installer apache --agree-tos --${LE_REDIRECT} --email ${LE_EMAIL} ${LE_SECURE_DOMAINS} --staging
133163 else
164+ printf " Requesting cert from PRODUCTION server\n"
134165 certbot -n --authenticator standalone --installer apache --agree-tos --${LE_REDIRECT} --email ${LE_EMAIL} ${LE_SECURE_DOMAINS}
135166 fi
136- systemctl stop apache2.service
137167 fi
138- printf " Done with Website Config\n\n"
168+ systemctl restart apache2.service
169+ printf " END: Apache Config\n\n"
139170
140- printf " Setting up Acuparse database\n"
141- sleep 2
142- 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
143- 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
144- printf " Done with Database\n\n"
171+ printf " Creating Acuparse database\n"
172+ sleep 1
173+ 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
174+ 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
145175
146- printf " Installing Cronjob \n"
147- sleep 2
176+ printf " Installing Cron \n"
177+ sleep 1
148178 (crontab -l 2> /dev/null; echo " * * * * * php /opt/acuparse/cron/cron.php > /opt/acuparse/logs/cron.log 2>&1" ) | crontab -
149- printf " Done with Cron\n\n"
150-
151- printf " Setup Complete!\nConnect to your system using a browser to continue configuration.\n"
152179
180+ printf " Running Cleanup\n"
181+ apt-get autoremove -y
182+ apt-get clean -y
183+ apt-get purge -y
184+ systemctl restart apache2.service
185+
186+ printf " \nAcuparse Installation Complete!\n\n"
187+
188+ printf " Your system IP addresse(s):\n"
189+ hostname -I
190+ printf " \nYour system hostname(s):\n"
191+ hostname -A
192+ printf " \nConnect to your IP/Hostname with a browser to continue configuration.\n"
153193else
154- printf " NO Debian Based OS! "
194+ 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 "
155195fi
156- exit
196+ exit
0 commit comments