Incorporated changes for release 1.4.0

This commit is contained in:
2026-02-24 20:34:15 -05:00
parent eb8829af47
commit 4d95710f43
117 changed files with 594 additions and 12056 deletions

View File

@@ -2,12 +2,12 @@
# install.sh
# OpenDRS Online Discrepancy Reporting System
# Copyright (C) 2023 Rod Wright
# Copyright (C) 2024 Rod Wright
# SPDX-License-Identifier: GPL-2.0
DRS_VERSION="1.3.3"
DRS_VERSION="1.4.0"
DOC_ROOT="/var/www"
INSTALL_LOC="opendrs"
APACHE_USER="www-data"
@@ -21,7 +21,15 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
# initial stuff
# Prevent unattended-upgrades from interfering
restart_uu=false
while systemctl status unattended-upgrades >/dev/null 2>&1
do
systemctl stop unattended-upgrades
sleep 5
restart_uu=true
done
echo ""
echo ""
echo "* * * * * Welcome to OpenDRS $DRS_VERSION Installation * * * * *"
@@ -29,7 +37,304 @@ echo ""
echo ""
echo "Just press enter at the prompts to accept the defaults shown."
echo ""
# Check for prerequisites and prompt to install
echo "Checking for prerequisites..."
echo ""
echo ""
echo " Checking for apache2 installation..."
echo ""
if dpkg -l|grep apache2 >/dev/null 2>&1
then
echo ""
echo "apache2 is installed. Continuing."
echo ""
else
echo "OpenDRS requires the apache2 http server, but it doesn't seem"
echo -n "to be installed. Install it now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "OpenDRS requires apache2, but you have elected not to install it."
echo "Installation cannot continue."
exit 1
else
echo ""
echo "###################################################################"
echo ""
echo "Proceeding with apache2 installation"
echo ""
echo "###################################################################"
sleep 3
apt-get install -y apache2
echo ""
echo "###################################################################"
echo ""
echo "Finished with apache2 installation"
echo ""
echo "###################################################################"
sleep 3
fi
fi
echo ""
echo " Checking for php installation..."
echo ""
if dpkg -l|grep php >/dev/null 2>&1
then
echo ""
echo "php is installed. Continuing."
echo ""
else
echo ""
echo ""
echo "OpenDRS requires php, but it doesn't seem to be installed."
echo -n "Install it now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "OpenDRS requires php, but you have elected not to install it."
echo "Installation cannot continue."
exit 1
else
echo ""
echo "###################################################################"
echo ""
echo "Proceeding with php installation"
echo ""
echo "###################################################################"
sleep 3
apt-get install -y php
echo ""
echo "###################################################################"
echo ""
echo "Finished with php installation"
echo ""
echo "###################################################################"
sleep 3
fi
fi
echo ""
echo " Checking for mariadb or mysql installation..."
echo ""
if dpkg -l|grep mariadb-server >/dev/null 2>&1
then
echo ""
echo "mariadb-server is installed. Continuing."
echo ""
elif dpkg -l|grep mysql-server >/dev/null 2>&1
then
echo ""
echo "mysql-server is installed. Continuing."
echo ""
else
echo ""
echo ""
echo "OpenDRS requires either mariadb or mysql server, but neither seem"
echo -n "to be installed. Install mariadb-server now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "OpenDRS requires either mariadb or mysql server, but you have elected not to install it."
echo "Installation cannot continue."
exit 1
else
echo ""
echo "###################################################################"
echo ""
echo "Proceeding with mariadb-server installation"
echo ""
echo "###################################################################"
sleep 3
apt-get install -y mariadb-server
echo ""
echo "###################################################################"
echo ""
echo "Finished with mariadb-server installation"
echo ""
echo "###################################################################"
sleep 3
echo ""
echo "###################################################################"
echo ""
echo "Proceeding with mariadb configuration"
echo ""
echo "###################################################################"
sleep 3
echo ""
echo "Configuring the MariaDB installation. There will be some more prompts:"
echo ""
echo "- You'll be prompted for the current password for the root user. You've"
echo " just installed MariaDB and you haven't set one yet, so just press enter."
echo ""
echo "- You'll be prompted to switch to unix_socket authentication. Answer Y."
echo ""
echo "- You'll be prompted to change the root password. Answer Y and enter a password."
echo " Note that this is just the password for the MariaDB root user, not the root login."
echo " DO NOT FORGET THIS PASSWORD. You'll need it later during OpenDRS install."
echo ""
echo "- Answer Y to remove anonymous users, disallow root login remotely, remove"
echo " test database and access, and reload privilege tables."
echo ""
echo -n "Press enter to proceed."
read continueok
echo ""
mysql_secure_installation
echo ""
echo "###################################################################"
echo ""
echo "Finished with mariadb configuration."
echo ""
echo "###################################################################"
sleep 3
fi
fi
echo ""
echo " Checking for phpmyadmin installation..."
echo ""
if dpkg -l|grep phpmyadmin >/dev/null 2>&1
then
echo ""
echo "phpmyadmin is installed. Continuing."
echo ""
else
echo "phpmyadmin is optional, but doesn't seem to be installed."
echo "It is an optional package that enables administration of the mysql/mariadb"
echo "database server using a friendly GUI. It is highly recommended."
echo "Note that this has the potential to be a security risk, especially"
echo "if your passwords aren't sufficiently strong."
echo -n "Install it now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "Proceeding without installing phpmyadmin. Database administration"
echo "will require the use of the mysql/mariadb command line tools."
else
echo ""
echo "###################################################################"
echo ""
echo "Proceeding with phpmyadmin installation"
echo ""
echo "###################################################################"
sleep 3
echo ""
echo "During the following installation of phpmyadmin:"
echo ""
echo "- Select apache2 as the web server to configure automatically."
echo ""
echo "- Choose Yes when prompted to install phpmyadmin database and allow it to"
echo " generate a random password(leave the field blank)."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
apt-get install -y phpmyadmin
echo ""
echo ""
echo "You can now access phpmyadmin using a web browser pointed to:"
echo "http://$HOSTNAME/phpmyadmin"
echo "*** WARNING!! this url is accessible via unencrypted (http), not"
echo "encrypted SSL (https) connections. This is a huge security risk"
echo "since the username and password you enter will be sent in the"
echo "clear for any potential attacker to sniff! You should enable"
echo "redirection to https for phpmyadmin in your apache2 configuration."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
echo "###################################################################"
echo ""
echo "Finished with phpmyadmin installation"
echo ""
echo "###################################################################"
sleep 3
fi
fi
echo ""
echo " Checking for webmin installation..."
echo ""
if dpkg -l|grep webmin >/dev/null 2>&1
then
echo ""
echo "webmin is installed. Continuing."
echo ""
else
echo "webmin is optional, but doesn't seem to be installed."
echo "It is an optional package that enables system administration"
echo "using a friendly GUI. It is highly recommended, especially for"
echo "headless servers without any way to log in directly on the machine."
echo "Note that this has the potential to be a security risk, especially"
echo "if your passwords aren't sufficiently strong."
echo -n "Install it now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "Proceeding without installing webmin. System administration"
echo "will require login to the server either directly or via ssh."
else
echo ""
echo "###################################################################"
echo ""
echo "Proceeding with webmin installation"
echo ""
echo "###################################################################"
sleep 3
echo "Installing webmin..."
skipwebmin="false"
if ! curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
then
echo "Warning: failed to download Webmin repo setup script."
echo -n "Ignore and [c]ontinue or [A]bort? [c/A]: "
read wmfailchoice
if [ "$wmfailchoice" = "C" -o "$wmfailchoice" = "c" ]
then
skipwebmin="true"
echo "Continuing without installing Webmin. You should investigate the failure"
echo "and install Webmin manually after the server is set up if you would like"
echo "to be able to manage the server from another computer with a GUI instead"
echo "of through ssh only."
echo -n "Press enter to continue."
read continueok
echo ""
fi
fi
if [ "$skipwebmin" = "false" ]
then
sh setup-repos.sh -f
apt-get install -y --install-recommends webmin
fi
echo "...done."
echo ""
echo "You can now access webmin using a web browser pointed to:"
echo "https://$HOSTNAME:10000"
echo "Unless you have obtained valid ssl certificates, your server is"
echo "using self-signed certs. This is not necessarily a problem, but"
echo "your browser will complain. You can tell the browser to accept the"
echo "self signed certificates and the traffic will still be encrypted,"
echo "however you may be vulnerable to man-in-the-middle attacks. You can"
echo "get free valid certificates through LetsEncrypt."
echo "See http://letsencrypt.org for more information."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
echo "###################################################################"
echo ""
echo "Finished with webmin installation"
echo ""
echo "###################################################################"
sleep 3
fi
fi
echo ""
echo ""
echo "Finished checking for and installing prerequisites..."
echo ""
echo ""
sleep 3
# prompt for install location
echo "Where would you like to install this version of OpenDRS? This should"
echo "be somewhere the webserver can find it. If you don't know, refer to the"
@@ -57,10 +362,7 @@ then
if [ -e "$install_path/db.php" ]
then
# A db.php file was found in the install path
prev_inst_present=1
grep -q -e "OpenDRS" -e "OpenMTS" $install_path/db.php
prev_inst_present=$?
if [ "$prev_inst_present" -eq 0 ]
if grep -q -e "OpenDRS" -e "OpenMTS" $install_path/db.php
then
# the db.php file is part of an OpenDRS/OpenMTS installation
echo "The installation path you chose already exists."
@@ -135,8 +437,8 @@ else
# This is a fresh install
operation="installed"
# prompt for mysql information
bad_mysql_adm=1
while [ $bad_mysql_adm -eq 1 ]
bad_mysql_adm=true
while $bad_mysql_adm
do
admintestdb="drsadm`date +%Y%m%d`"
echo "We need to know the username and password of a MySQL administrator"
@@ -148,10 +450,9 @@ else
echo -n "MySQL admin password: "
read -s mysql_adm_pass
export MYSQL_PWD="$mysql_adm_pass"
mysql -u"$mysql_adm_user" -e "create database $admintestdb;drop database $admintestdb"
if [ $? -eq 0 ]
if mysql -u"$mysql_adm_user" -e "create database $admintestdb;drop database $admintestdb"
then
bad_mysql_adm=0
bad_mysql_adm=false
else
echo "ERROR: Either the username/password you supplied were incorrect or the user"
echo -n "is not a MySQL administrator. Try again? [Y/N]: "
@@ -176,8 +477,8 @@ else
echo ""
# Create initial database
db_create_fail=1
while [ $db_create_fail -eq 1 ]
db_create_fail=true
while $db_create_fail
do
echo "What would you like to call the database for this installation of OpenDRS?"
echo "If you accept the default, it will be called opendrs. Again, this is fine"
@@ -192,10 +493,9 @@ else
fi
echo ""
export MYSQL_PWD="$mysql_adm_pass"
mysql -u"$mysql_adm_user" -e "create database $new_db_name"
if [ $? -eq 0 ]
if mysql -u"$mysql_adm_user" -e "create database $new_db_name"
then
db_create_fail=0
db_create_fail=false
else
echo "An error was encountered when trying to create the database."
echo "This probably means the database already exists."
@@ -238,7 +538,7 @@ else
# copy distribution to install location
echo "Installing distribution . . ."
cp -Rv distfiles/* $install_path
cp -R distfiles/* $install_path
if [ ! -L "$install_path/jquery-ui" ]
then
ln -s $install_path/jquery-ui* $install_path/jquery-ui
@@ -287,7 +587,7 @@ then
read enconf
if [ "$enconf" = "" -o "$enconf" = "Y" -o "$enconf" = "y" ]
then
a2enconf $base_url.conf
a2enconf $base_url.conf >/dev/null
service apache2 reload
echo "You can now point a web browser to $base_url on your web server "
echo "to set up and configure OpenDRS."
@@ -312,3 +612,5 @@ else
echo "to use your upgraded OpenDRS."
fi
# Re-enable unattended-upgrades
if $restart_uu; then systemctl start unattended-upgrades; fi