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,10 +2,15 @@
# server-setup.sh
# OpenDRS Online Discrepancy Reporting System
# Copyright (C) 2018 Rod Wright
# Copyright (C) 2020 Rod Wright
# SPDX-License-Identifier: GPL-2.0
inst_name="OpenDRS"
docroot_path="/var/www"
apache_user="www-data"
apache_group="www-data"
echo ""
echo ""
echo ""
@@ -30,6 +35,8 @@ sleep 10
apt update && apt dist-upgrade -y
echo "...done."
echo ""
echo "IMPORTANT!: Be sure to make note of usernames and passwords you provide below."
echo "You will need them later."
echo ""
echo "Installing required server packages. Select apache2 as the web server to configure"
echo "automatically. Choose Yes when prompted to install phpmyadmin database and allow it to"
@@ -37,7 +44,7 @@ echo "generate a random password(leave the field blank)."
echo -n "Press enter to continue."
read continueok
sleep 10
apt install -y apache2 php php-mcrypt mysql-server phpmyadmin
apt install -y apache2 php php-mcrypt mariadb-server phpmyadmin uuid-runtime
cp etc/apache2/mods-available/alias.conf /etc/apache2/mods-available
service apache2 restart
echo "...done."
@@ -51,34 +58,168 @@ mysql_secure_installation
mysql mysql -e "update user set plugin='';flush privileges;"
echo ""
echo ""
echo "Installing OpenDRS."
DRS_VERSION="1.1.0"
install_path="/var/www/opendrs-$DRS_VERSION"
httpd_user_group="www-data:www-data"
new_link_name="/var/www/opendrs"
# This is a fresh install
operation="installed"
# prompt for mysql information
bad_mysql_adm=1
while [ $bad_mysql_adm -eq 1 ]
do
admintestdb="drsadm`date +%Y%m%d`"
echo "We need to know the username and password of a MySQL administrator"
echo "to be able to create the database and user for OpenDRS. Note that this"
echo "is not necessarily the same as the login and password for the computer."
echo -n "MySQL admin username: "
read mysql_adm_user
echo ""
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 ]
then
bad_mysql_adm=0
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]: "
read admtry
if [ "$admtry" != "Y" -o "$admtry" != "y" ]
then
exit
fi
fi
done
echo ""
echo "What would you like to call this installation of OpenDRS? If you accept"
echo "the default, it will be called $inst_name. If you will be running multiple"
echo "instances of OpenDRS on this server, you should choose a distinctive name."
echo -n "Installation name [$inst_name]: "
read inst_name
echo ""
# Create initial database
db_create_fail=1
while [ $db_create_fail -eq 1 ]
do
name_valid=0
while [ $name_valid -eq 0 ]
do
echo "What would you like to call the database for this installation of OpenDRS?"
echo "If you accept the default or make it blank, it will be $inst_name."
echo "Spaces or special characters are not allowed in the name."
echo -n "database name [$inst_name]: "
read new_db_name
if [ "$new_db_name" = "" ]
then
new_db_name=$inst_name
fi
echo $new_db_name|egrep -q "\W"
if [ $? -eq 0 ]
then
echo "The name you entered seems to contain whitespace or special"
echo "characters. Try again or just accept the default."
else
name_valid=1
fi
done
echo ""
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
else
echo "An error was encountered when trying to create the database."
echo "This probably means the database already exists."
echo -n "Try again with a different database name? [Y/N]: "
read dbcreatetry
if [ "$dbcreatetry" != "Y" -o "$dbcreatetry" != "y" ]
then
exit
fi
fi
done
# Create user and give rights to database
drs_user="$new_db_name-user"
drs_pass=`uuidgen`
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" $new_db_name < ../opendrs-initial.sql
# Set the installation name
export MYSQL_PWD="$drs_pass"
mysql -u"$drs_user" $new_db_name -e "update config set value=\"$inst_name\",defaultvalue=\"$inst_name\" where name=\"app_name\""
# Create install path
echo "Creating installation directory . . ."
install_path=$docroot_path/$inst_name
mkdir $install_path
# Create db.php if it doesn't exist
if [ ! -f "$install_path/db.php" ]
then
cp ../db.php.template $install_path/db.php
sed -i "s/DBNAME/$new_db_name/g" $install_path/db.php
sed -i "s/DBUSER/$drs_user/g" $install_path/db.php
sed -i "s/DBPASS/$drs_pass/g" $install_path/db.php
fi
# copy distribution to install location
echo "Installing distribution . . ."
cp -Rv ../distfiles/* $install_path
ln -s $install_path/writeups.php $install_path/index.php
# 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
echo ""
echo "Setting file ownership . . ."
chown -R $httpd_user_group $install_path
ln -s $install_path $new_link_name
cp etc/apache2/conf-available/opendrs.conf /etc/apache2/conf-available
cp etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available
a2enconf opendrs
echo "DRS_SERVER=\"http://localhost\"" > /etc/drs.conf
service apache2 restart
echo ""
echo "Server configuration is now complete. "
echo "Once the reboot is complete you will need to do the final installation of OpenDRS through"
echo "the browser. You will need the password you set during the mysql installation above."
# tell user to launch web browser to continue
echo ""
echo ""
echo "It is highly recommended that after rebooting, you press ctrl-alt-F2,"
echo "log in as pi, then create new users for yourself and any other"
echo "administrators using the cloneuser command (cloneuser pi newlogin)."
echo ""
echo "OpenDRS has been installed."
echo "# OpenDRS default Apache configuration" > /etc/apache2/conf-available/$inst_name.conf
echo "" >> /etc/apache2/conf-available/$inst_name.conf
echo "Alias /$inst_name $install_path" >> /etc/apache2/conf-available/$inst_name.conf
echo "" >> /etc/apache2/conf-available/$inst_name.conf
echo "<Directory $install_path>" >> /etc/apache2/conf-available/$inst_name.conf
echo " Options FollowSymLinks" >> /etc/apache2/conf-available/$inst_name.conf
echo " DirectoryIndex index.php" >> /etc/apache2/conf-available/$inst_name.conf
echo "</Directory>" >> /etc/apache2/conf-available/$inst_name.conf
a2enconf $inst_name
service apache2 reload
echo "OpenDRS server setup is complete."
echo ""
echo "Once the reboot is complete you will need to do the final installation of $inst_name through"
echo "the browser. You will need the mysql username and password you set during the mysql installation above."
echo ""
echo ""
echo -n "Press enter to reboot now."
read rebootok
reboot
echo "Once the final install is done, you will need to log in to $inst_name to configure it."
echo "IMPORTANT: The default login credentials for the initial admin user are:"
echo ""
echo "login: drsadmin"
echo "password: OpenDRS-1"
echo ""
echo "REMEMBER THESE CREDENTIALS. Otherwise, you will not be able to log in and"
echo "configure your new installation."
echo "It is highly recommended that you change the initial password to something"
echo "secure after logging in for the first time."
echo "DRS_SERVER=\"http://localhost/$inst_name\"" > /etc/drs.conf

View File

@@ -2,7 +2,7 @@
# terminal-setup.sh
# OpenDRS Online Maintenance Tracking System
# Copyright (C) 2018 Rod Wright
# Copyright (C) 2020 Rod Wright
# SPDX-License-Identifier: GPL-2.0
@@ -46,8 +46,6 @@ chmod +x usr/local/bin/*
cp usr/local/bin/* /usr/local/bin
cp etc/apt/sources.list.d/* /etc/apt/sources.list.d
cp lib/systemd/system/getty@tty1.service /lib/systemd/system
rm /lib/systemd/system/ctrl-alt-del.target
ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target
echo "...done."
echo ""
echo ""
@@ -80,7 +78,7 @@ read continueok
echo ""
echo ""
echo "Creating customer user..."
cloneuser pi customer
cloneuser `who am i | awk '{print $1}'` customer
mkdir -p /home/customer/.config/openbox
cp home/customer/.profile /home/customer
cp home/customer/.config/openbox/rc.xml /home/customer/.config/openbox
@@ -89,32 +87,27 @@ echo "...done."
echo ""
echo ""
echo "This terminal will need to communicate with an OpenDRS server. If"
echo "you intend to host the server directly on this terminal, accept the"
echo "default URL shown. Otherwise, enter the server URL."
echo -n "[http://localhost] :"
echo "you intend to host the server directly on this terminal, leave this"
echo -n "blank. Otherwise, enter the server URL :"
read server_url
if [[ $server_url == "" ]]
then
server_url="http://localhost"
fi
echo "DRS_SERVER=\"$server_url\"" > /etc/drs.conf
echo ""
echo ""
echo "Terminal configuration is now complete. "
echo ""
echo ""
echo "If this Raspberry Pi will also be used as the OpenDRS server, you will need"
echo "to run the server-setup.sh script in this same directory."
echo "Would you like to do that now? enter Y if so, or press enter to leave this"
echo -n "as a terminal only and reboot :"
read serverchoice
if [[ $serverchoice == "Y" || $serverchoice == "y" ]]
then
conftype="Server/Terminal"
touch /etc/drs.conf
./server-setup.sh
else
conftype="Terminal"
echo "DRS_SERVER=\"$server_url\"" > /etc/drs.conf
fi
echo "It is highly recommended that after rebooting, you press ctrl-alt-F2,"
echo "log in as pi, then create new users for yourself and any other"
echo "administrators using the cloneuser command (cloneuser pi newlogin)."
echo ""
echo ""
echo "$conftype configuration is now complete. "
echo ""
echo ""
echo "It is highly recommended that after rebooting, you run ssh pi@$HOSTNAME"
echo "from another computer on the network, then create new users for"
echo "yourself and any other administrators using the cloneuser command"
echo "(cloneuser pi <new username>)."
echo ""
echo ""
echo "Setup complete."

View File

@@ -2,17 +2,27 @@
SRC=$1
DEST=$2
if [ $# -ne 2 ]; then
echo "Usage: cloneuser source_user destination_user"
exit 1
fi
if ! grep -q $SRC /etc/passwd ;then echo "Source user doesn't exist!"; exit 1; fi
if grep -q $DEST /etc/passwd ;then echo "Destination user already exists!"; exit 1; fi
SRC_GROUPS=`id -Gn ${SRC}`
SRC_SHELL=$(awk -F : -v name=${SRC} '(name == $1) { print $7 }' /etc/passwd)
RAND_PW=`date +%s | sha256sum | base64 | head -c 32 ; echo`
echo "Creating user $DEST"
useradd --shell ${SRC_SHELL} --create-home ${DEST}
echo "Creating user $DEST with a random password"
useradd --shell ${SRC_SHELL} --password ${RAND_PW} --create-home ${DEST}
for grp in ${SRC_GROUPS};do
if [ "$grp" != "$SRC" ]; then
echo "Adding user $DEST to group $grp."
usermod -a -G $grp ${DEST}
fi
done
passwd ${DEST}
echo "Finished. Please set an actual password for $DEST if you want them to be able to log in."

View File

@@ -7,18 +7,16 @@ openbox-session &
xset s off
xset +dpms
xset dpms 0 600 1800
#xset dpms force off
while true
do
killall chromium-browser
rm -rf ~/.{config,cache}/chromium/
# start browser in your web site: here, just plain old localhost
# -test-type will ignore any warnings and
# start browser to DRS Server
# --test-type will ignore any warnings and
# --ignore-certificate-errors will allow you to kiosk any https-page without displaying certificate errors
chromium-browser -test-type --ignore-certificate-errors --kiosk --no-first-run --incognito $DRS_SERVER &
chromium-browser --test-type --ignore-certificate-errors --kiosk --no-first-run --check-for-update-interval=1 --simulate-upgrade --incognito $DRS_SERVER &
sleep 10
@@ -27,8 +25,8 @@ do
pgrep chromium-browse
if [ "$?" -eq "1" ]
then
# here you could execute something that is supposed to happen after the browser was accidentally quit
chromium-browser -test-type --ignore-certificate-errors --kiosk --no-first-run --incognito $DRS_SERVER &
# relaunch browser if it terminates
chromium-browser --test-type --ignore-certificate-errors --kiosk --no-first-run --check-for-update-interval=1 --simulate-upgrade --incognito $DRS_SERVER &
fi
sleep 1
done