Incorporated changes for release 1.1.1

This commit is contained in:
2026-02-14 11:26:01 -05:00
parent a6331f7fed
commit 16d1ff9bb8
45 changed files with 459 additions and 155 deletions

View File

@@ -2,12 +2,12 @@
# install.sh
# OpenDRS Online Discrepancy Reporting System
# Copyright (C) 2018 Rod Wright
# Copyright (C) 2020 Rod Wright
# SPDX-License-Identifier: GPL-2.0
DRS_VERSION="1.1.0"
DRS_VERSION="1.1.1"
DOC_ROOT="/var/www"
INSTALL_LOC="opendrs"
APACHE_USER="www-data"
@@ -42,15 +42,6 @@ echo ""
echo -n "Enter name of OpenDRS installation directory [$INSTALL_LOC] :"
read install_loc_in
echo ""
echo "In order to set the ownership correctly, we need to know the user and"
echo "group that the webserver expects its files to be owned by. This is"
echo "usually not the root account. Refer to the ownership of other files in"
echo "your webserver's document tree to see what this should be."
echo "Enter the user and group separated by a colon (username:groupname)."
echo "Enter the user:group of the OpenDRS installation"
echo -n "directory [$APACHE_USER:$APACHE_GROUP] :"
read httpd_user_group
echo ""
if [ "$doc_root_in" = "" ]
then
doc_root_in=$DOC_ROOT
@@ -59,10 +50,6 @@ if [ "$install_loc_in" = "" ]
then
install_loc_in=$INSTALL_LOC
fi
if [ "$httpd_user_group" = "" ]
then
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
fi
install_path="$doc_root_in/$install_loc_in"
if [ -d "$install_path" ]
then
@@ -90,22 +77,36 @@ then
curr_dbname=`grep dbname $install_path/db.php | head -1 | cut -d "\"" -f2`
curr_username=`grep username $install_path/db.php | head -1 | cut -d "\"" -f2`
curr_dbpass=`grep dbpass $install_path/db.php | head -1 | cut -d "\"" -f2`
mysqldump -u"$curr_username" -p"$curr_dbpass" $curr_dbname > $curr_dbname-`date +%Y-%m-%d_%H:%M:%S`-backup.sql
export MYSQL_PWD="$curr_dbpass"
mysqldump -u"$curr_username" $curr_dbname > $curr_dbname-`date +%Y-%m-%d_%H:%M:%S`-backup.sql
# back up existing installation
echo "Backing up current installation to the package directory."
cp -R $install_path $install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup
# delete all existing installation files except db.php
find $install_path/ -mindepth 1 -not -name 'db.php' -delete
# apply database updates
mysql -u"$curr_username" -p"$curr_dbpass" $curr_dbname < opendrs-update.sql
mysql -u"$curr_username" $curr_dbname < opendrs-update.sql >/dev/null 2>&1
# apply updates to existing db.php
./opendrs-update.sh $install_path
# copy distribution to install location
echo "Installing distribution . . ."
cp -R distfiles/* $install_path
# set ownership
echo "In order to set the ownership correctly, we need to know the user and"
echo "group that the webserver expects its files to be owned by. This is"
echo "usually not the root account. Refer to the ownership of other files in"
echo "your webserver's document tree to see what this should be."
echo "Enter the user and group separated by a colon (username:groupname)."
echo "Enter the user:group of the OpenDRS installation"
echo -n "directory [$APACHE_USER:$APACHE_GROUP] :"
read httpd_user_group
if [ "$httpd_user_group" = "" ]
then
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
fi
echo ""
echo "Setting file ownership . . ."
chown -R $httpd_user_group $install_path
chown -R $httpd_user_group $install_path
else
echo "Cancelling installation"
exit
@@ -138,7 +139,8 @@ else
echo ""
echo -n "MySQL admin password: "
read -s mysql_adm_pass
mysql -u"$mysql_adm_user" -p"$mysql_adm_pass" -e "create database $admintestdb;drop database $admintestdb" 2>/dev/null
export MYSQL_PWD="$mysql_adm_pass"
mysql -u"$mysql_adm_user" -e "create database $admintestdb;drop database $admintestdb"
if [ $? -eq 0 ]
then
bad_mysql_adm=0
@@ -171,8 +173,13 @@ else
echo "distinctive name."
echo -n "database name [opendrs]: "
read new_db_name
if [ "$new_db_name" = "" ]
then
new_db_name=opendrs
fi
echo ""
mysql -u"$mysql_adm_user" -p"$mysql_adm_pass" -e "create database $new_db_name" 2>/dev/null
export MYSQL_PWD="$mysql_adm_pass"
mysql -u"$mysql_adm_user" -e "create database $new_db_name"
if [ $? -eq 0 ]
then
db_create_fail=0
@@ -191,15 +198,17 @@ else
# Create user and give rights to database
drs_user="$new_db_name`date +%Y%m%d%H%M%S`"
drs_pass=`uuidgen`
mysql -u"$mysql_adm_user" -p"$mysql_adm_pass" -e "create user if not exists '$drs_user'@'localhost' identified by '$drs_pass'" 2>/dev/null
mysql -u"$mysql_adm_user" -p"$mysql_adm_pass" -e "grant all on $new_db_name.* to '$drs_user'@'localhost'"
mysql -u"$mysql_adm_user" -p"$mysql_adm_pass" -e "flush privileges"
export MYSQL_PWD="$mysql_adm_pass"
mysql -u"$mysql_adm_user" -e "create user if not exists '$drs_user'@'localhost' identified by '$drs_pass'"
mysql -u"$mysql_adm_user" -e "grant all on $new_db_name.* to '$drs_user'@'localhost'"
mysql -u"$mysql_adm_user" -e "flush privileges"
# Populate initial database
mysql -u"$mysql_adm_user" -p"$mysql_adm_pass" $new_db_name < opendrs-initial.sql 2>/dev/null
mysql -u"$mysql_adm_user" $new_db_name < opendrs-initial.sql
# Set the installation name
mysql -u"$drs_user" -p"$drs_pass" $new_db_name -e "update config set value=\"$new_inst_name\",defaultvalue=\"$new_inst_name\" where name=\"app_name\""
export MYSQL_PWD="$drs_pass"
mysql -u"$drs_user" $new_db_name -e "update config set value=\"$new_inst_name\",defaultvalue=\"$new_inst_name\" where name=\"app_name\""
# Create install path
echo "Creating installation directory . . ."
@@ -219,8 +228,21 @@ else
cp -Rv distfiles/* $install_path
# set ownership
echo "In order to set the ownership correctly, we need to know the user and"
echo "group that the webserver expects its files to be owned by. This is"
echo "usually not the root account. Refer to the ownership of other files in"
echo "your webserver's document tree to see what this should be."
echo "Enter the user and group separated by a colon (username:groupname)."
echo "Enter the user:group of the OpenDRS installation"
echo -n "directory [$APACHE_USER:$APACHE_GROUP] :"
read httpd_user_group
if [ "$httpd_user_group" = "" ]
then
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
fi
echo ""
echo "Setting file ownership . . ."
chown -R $httpd_user_group $install_path
chown -R $httpd_user_group $install_path
fi
echo ""