85 lines
2.7 KiB
Bash
85 lines
2.7 KiB
Bash
#!/bin/bash
|
|
|
|
# server-setup.sh
|
|
# OpenDRS Online Discrepancy Reporting System
|
|
# Copyright (C) 2018 Rod Wright
|
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
echo ""
|
|
echo ""
|
|
echo ""
|
|
echo ""
|
|
echo "This script will configure a Raspberry Pi to be an OpenDRS server."
|
|
echo ""
|
|
echo ""
|
|
echo "You should have already run the terminal-setup.sh script in this directory."
|
|
echo ""
|
|
if [ ! -e "/etc/drs.conf" ]
|
|
then
|
|
echo "It looks like the terminal-setup.sh script has not been run yet."
|
|
echo "This is required before running the server-setup.sh script."
|
|
echo "Aborting."
|
|
exit 1
|
|
fi
|
|
echo "It looks like you have. Continuing."
|
|
echo ""
|
|
echo ""
|
|
echo "Updating Raspbian..."
|
|
sleep 10
|
|
apt update && apt dist-upgrade -y
|
|
echo "...done."
|
|
echo ""
|
|
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"
|
|
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
|
|
cp etc/apache2/mods-available/alias.conf /etc/apache2/mods-available
|
|
service apache2 restart
|
|
echo "...done."
|
|
echo ""
|
|
echo ""
|
|
echo "Configuring the mysql installation. Accept the defaults at the following prompts."
|
|
echo "Remember the password you set here. You'll need it during the OpenDRS install."
|
|
echo -n "Press enter to proceed."
|
|
read continueok
|
|
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"
|
|
echo "Creating installation directory . . ."
|
|
mkdir $install_path
|
|
echo "Installing distribution . . ."
|
|
cp -Rv ../distfiles/* $install_path
|
|
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."
|
|
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 ""
|
|
echo -n "Press enter to reboot now."
|
|
read rebootok
|
|
reboot
|