Incorporate changes made for old version 5.2.4.3
This commit is contained in:
23
CHANGELOG
23
CHANGELOG
@@ -193,7 +193,7 @@
|
||||
fixed. Made the corrections to the edit code as well as the
|
||||
new entry.
|
||||
- In logentry.php, the default times for notes entered using dates
|
||||
other than today's date contained a trailing coln that mysql
|
||||
other than today's date contained a trailing colon that mysql
|
||||
didn't like. Removed trailing colons.
|
||||
- Cleaned up the REQUEST importation in multiple files to default to
|
||||
NULL values for parameters not supplied to prevent warning
|
||||
@@ -211,3 +211,24 @@
|
||||
5.2.4.2 - 2025-12-11
|
||||
- Fixed other bugs caused by passing a non-array as the second
|
||||
argument of the php in_array() function in various files.
|
||||
|
||||
5.2.4.3 - 2025-12-16
|
||||
- Various problems were noted resulting from php's use of UTC as the
|
||||
default timezone. Now, on installation or upgrade, the installer
|
||||
gets the correct timezone from the system and sets it as a php
|
||||
option in a .htaccess file in the install location. This solves
|
||||
multiple problems and allows today's date and the current time
|
||||
to be determined from the php date() function as part of the
|
||||
settings.php once per page load instead of having to query the
|
||||
database multiple times per page load. Also added the option to
|
||||
allow apache to read the .htaccess file to the <Directory>
|
||||
section of the application's conf file in
|
||||
/etc/apache2/conf-available
|
||||
- Renamed the installer's db.php_update.sh script to files-update.sh
|
||||
to reflect that it now can do more than just modify the db.php
|
||||
file. For this version, it's used to modify the apache conf file
|
||||
mentioned earlier.
|
||||
- Completely removed the optional package prompting/installation
|
||||
code from install.sh. This is best done using separate
|
||||
installers.
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ CREATE TABLE `configs` (
|
||||
LOCK TABLES `configs` WRITE;
|
||||
/*!40000 ALTER TABLE `configs` DISABLE KEYS */;
|
||||
INSERT INTO `configs` VALUES
|
||||
(1,'ol_version','5.2.4.2'),
|
||||
(1,'ol_version','5.2.4.3'),
|
||||
(2,'log_name','OpenLog'),
|
||||
(3,'banner','1'),
|
||||
(4,'background_color','#003333'),
|
||||
|
||||
31
database-update.sh
Executable file
31
database-update.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# database-update.sh
|
||||
# OpenLog Online Logbook
|
||||
# Copyright (C) 2025 Rod Wright
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
if [[ $1 == "" ]]
|
||||
then
|
||||
echo "This script requires a mysql options file, but none was specified. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mysql_opt_file=$1
|
||||
if [[ ! -f $mysql_opt_file ]]
|
||||
then
|
||||
echo "The mysql options file specified does not exist. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
margs="--defaults-extra-file=$mysql_opt_file"
|
||||
|
||||
# ---------- version x.x.x ----------
|
||||
# Nothing to be done for versions prior to 5.2.4.3
|
||||
# -----------------------------------
|
||||
|
||||
# ---------- version 5.2.4.3 ----------
|
||||
# Nothing to do
|
||||
# -------------------------------------
|
||||
@@ -31,12 +31,17 @@ UPDATE configs SET confvalue="5.2.3" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue="5.2.4" WHERE confname="ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.4.1 -------------
|
||||
-- ---------- version 5.2.4.1 -----------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.4.1" WHERE confname="ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.4.2 -------------
|
||||
-- ---------- version 5.2.4.2 -----------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.4.2" WHERE confname="ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.4.3 -----------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.4.3" WHERE confname="ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
@@ -211,3 +211,24 @@
|
||||
5.2.4.2 - 2025-12-11
|
||||
- Fixed other bugs caused by passing a non-array as the second
|
||||
argument of the php in_array() function in various files.
|
||||
|
||||
5.2.4.3 - 2025-12-16
|
||||
- Various problems were noted resulting from php's use of UTC as the
|
||||
default timezone. Now, on installation or upgrade, the installer
|
||||
gets the correct timezone from the system and sets it as a php
|
||||
option in a .htaccess file in the install location. This solves
|
||||
multiple problems and allows today's date and the current time
|
||||
to be determined from the php date() function as part of the
|
||||
settings.php once per page load instead of having to query the
|
||||
database multiple times per page load. Also added the option to
|
||||
allow apache to read the .htaccess file to the <Directory>
|
||||
section of the application's conf file in
|
||||
/etc/apache2/conf-available
|
||||
- Renamed the installer's db.php_update.sh script to files-update.sh
|
||||
to reflect that it now can do more than just modify the db.php
|
||||
file. For this version, it's used to modify the apache conf file
|
||||
mentioned earlier.
|
||||
- Completely removed the optional package prompting/installation
|
||||
code from install.sh. This is best done using separate
|
||||
installers.
|
||||
|
||||
|
||||
@@ -722,7 +722,6 @@ function showlinklist($print) {
|
||||
function nag($tech_id) {
|
||||
// nags the user if something is pending
|
||||
global $db;
|
||||
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
|
||||
// maintenance forms
|
||||
$mfpending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$tech_id\" and pending=1"));
|
||||
if ($mfpending) {
|
||||
@@ -821,7 +820,6 @@ function get_upcoming_events() {
|
||||
// takes no arguments
|
||||
// returns an array containing arrays of upcoming event data
|
||||
global $db;
|
||||
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
|
||||
$uceventsqry=mysqli_query($db,"select * from events where active_flag=\"1\" and (deferred_flag=\"0\" or (deferred_flag=\"1\" and deferred_date <= \"$today\"))");
|
||||
$ucevents=array();
|
||||
while ($uceventrow=mysqli_fetch_assoc($uceventsqry)) {
|
||||
|
||||
@@ -77,9 +77,6 @@ if ($edit || $delete) {
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
// determine today's date and make it the default
|
||||
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
|
||||
$now=mysqli_fetch_row(mysqli_query($db,"select current_time"))[0];
|
||||
if ($add) {
|
||||
if ($submit) {
|
||||
// add the entry if submit is pressed
|
||||
|
||||
@@ -29,7 +29,6 @@ if ($print) {
|
||||
}
|
||||
|
||||
// use default date values if not supplied
|
||||
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
|
||||
if ($tgt_date=="") $tgt_date=$today;
|
||||
|
||||
// define shifttable_classic function
|
||||
|
||||
@@ -104,9 +104,6 @@ if ($printfmt) {
|
||||
}
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
// determine today's date and make it the default
|
||||
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
|
||||
$now=mysqli_fetch_row(mysqli_query($db,"select current_time"))[0];
|
||||
|
||||
//var_dump($_REQUEST);
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ if ($print) {
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
}
|
||||
// **** BEGIN DATABASE OPERATIONS ****
|
||||
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
|
||||
$tomorrow=mysqli_fetch_row(mysqli_query($db,"select adddate((select current_date),1)"))[0];
|
||||
$errorstack=array();
|
||||
|
||||
|
||||
@@ -58,20 +58,19 @@ framework("begin","$logname Search","Search",$print);
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
// get the date range of lognotes
|
||||
$todaysdate = mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
|
||||
$logdateqry=mysqli_query($db,"select min(date), max(date) from lognotes");
|
||||
$logdateresults=mysqli_fetch_row($logdateqry);
|
||||
$logmindate=$logdateresults[0];
|
||||
if ($logmindate == "") $logmindate = $todaysdate;
|
||||
if ($logmindate == "") $logmindate = $today;
|
||||
$logmaxdate=$logdateresults[1];
|
||||
if ($logmaxdate == "") $logmaxdate = $todaysdate;
|
||||
if ($logmaxdate == "") $logmaxdate = $today;
|
||||
// get the date range of maintenance forms
|
||||
$mfdateqry=mysqli_query($db,"select min(mfdate), max(mfdate) from maintforms");
|
||||
$mfdateresults=mysqli_fetch_row($mfdateqry);
|
||||
$mfmindate=$mfdateresults[0];
|
||||
if ($mfmindate == "") $mfmindate = $todaysdate;
|
||||
if ($mfmindate == "") $mfmindate = $today;
|
||||
$mfmaxdate=$mfdateresults[1];
|
||||
if ($mfmaxdate == "") $mfmaxdate = $todaysdate;
|
||||
if ($mfmaxdate == "") $mfmaxdate = $today;
|
||||
// determine entire date range
|
||||
$mindate=min($logmindate, $mfmindate);
|
||||
$maxdate=max($logmaxdate, $mfmaxdate);
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
// determine today's date and time and assign them to variables
|
||||
$today = date("Y-m-d");
|
||||
$now = date("H:i:s");
|
||||
|
||||
$sttl=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"session_ttl_days\""))[0];
|
||||
$ostype=strtoupper(substr(php_uname('s'), 0, 3));
|
||||
if ($ostype == 'WIN') {
|
||||
|
||||
40
files-update.sh
Executable file
40
files-update.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
# files_update.sh
|
||||
|
||||
install_path=$1
|
||||
|
||||
|
||||
# ---------- version 5.2.1 -------------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.2.2 -------------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.2.3 -------------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.2.4 -------------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.2.4.1 -----------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.2.4.2 -----------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.2.4.3 -----------
|
||||
# Add AllowOverride Options to the apache conf-available file
|
||||
install_loc=$(basename $install_path)
|
||||
if ! grep -q "AllowOverride Options" /etc/apache2/conf-available/$install_loc.conf
|
||||
then
|
||||
sed -i '/^<Directory/a\ AllowOverride Options' /etc/apache2/conf-available/$install_loc.conf
|
||||
systemctl reload apache2
|
||||
fi
|
||||
# --------------------------------------
|
||||
|
||||
308
install.sh
308
install.sh
@@ -8,21 +8,26 @@
|
||||
|
||||
APP_NAME="OpenLog"
|
||||
DEFAULT_DB_NAME="openlog"
|
||||
APP_VERSION="5.2.4.2"
|
||||
APP_VERSION="5.2.4.3"
|
||||
DOC_ROOT="/var/www"
|
||||
INSTALL_LOC="openlog"
|
||||
APACHE_USER="www-data"
|
||||
APACHE_GROUP="www-data"
|
||||
APACHE_CONF_DIR="/etc/apache2/conf-available"
|
||||
BACKUP_DIR="openlog-previous-installation"
|
||||
INDEX_FILE="lognotes.php"
|
||||
LANDING_PAGE="lognotes.php"
|
||||
CONFIG_TABLE="configs"
|
||||
CONFIG_NAME_COLUMN="confname"
|
||||
CONFIG_VALUE_COLUMN="confvalue"
|
||||
CONFIG_DEFAULT_COLUMN=""
|
||||
OFFER_OPTIONAL_PKGS=false
|
||||
|
||||
|
||||
function privilege_check() {
|
||||
# test for superuser rights
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run with superuser privileges. Try sudo $0"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function get_new_password() {
|
||||
# Stores new password in the variable $newpassword
|
||||
pwgood=false
|
||||
@@ -105,11 +110,22 @@ function abort_exit() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
function spinner() {
|
||||
local pid="$1"
|
||||
local delay="0.1"
|
||||
local spinstr='|/-\\'
|
||||
local i=0
|
||||
|
||||
while ps -p "$pid" > /dev/null; do
|
||||
i=$(( (i+1) % 4 ))
|
||||
printf "\r[%c]" "${spinstr:$i:1}"
|
||||
sleep "$delay"
|
||||
done
|
||||
printf "\r \r" # Clear the spinner line
|
||||
}
|
||||
|
||||
# test for superuser rights
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run with superuser privileges. Try sudo ./install.sh"
|
||||
abort_exit
|
||||
fi
|
||||
privilege_check
|
||||
|
||||
|
||||
echo ""
|
||||
@@ -122,182 +138,28 @@ echo "Preparing for installation. Please wait..."
|
||||
|
||||
# Prevent unattended-upgrades from interfering
|
||||
restart_uu=false
|
||||
while systemctl status unattended-upgrades >/dev/null 2>&1
|
||||
while dpkg -l|grep unattended-upgrades >/dev/null 2>&1
|
||||
do
|
||||
systemctl stop unattended-upgrades
|
||||
sleep 5
|
||||
restart_uu=true
|
||||
done
|
||||
|
||||
apt-get update
|
||||
apt-get update -qq
|
||||
|
||||
# Check for prerequisites and prompt to install
|
||||
echo "Checking for required packages..."
|
||||
echo ""
|
||||
install_required_packages "apache2" "php" "mysql-server or mariadb-server" "uuid-runtime"
|
||||
install_required_packages "apache2" "php" "mysql-server or mariadb-server" "php-mysql" "uuid-runtime"
|
||||
echo ""
|
||||
echo "Finished required package installation."
|
||||
echo ""
|
||||
|
||||
if $OFFER_OPTIONAL_PKGS
|
||||
then
|
||||
# Check for optional packages and prompt to install
|
||||
echo "Checking for optional packages..."
|
||||
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 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 "Proceeding with phpmyadmin installation"
|
||||
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 "In order to log in to the database using phpmyadmin, there must be a"
|
||||
echo "database user with a password set who has administrator privileges."
|
||||
echo "After a fresh installation of the MySQL or MariaDB server, the root"
|
||||
echo "user doesn't have a password, and is unable to log in to the phpmyadmin"
|
||||
echo "web GUI. You should create a new user with administrative rights now."
|
||||
echo ""
|
||||
read -p "New MySQL/MariaDB administrator username: " -r newdbadminuser
|
||||
echo ""
|
||||
get_new_password
|
||||
newdbadminpass=$newpassword
|
||||
unset newpassword
|
||||
mysql -e "CREATE USER '$newdbadminuser'@'localhost'
|
||||
IDENTIFIED VIA mysql_native_password USING password('$newdbadminpass');
|
||||
GRANT ALL PRIVILEGES ON *.* TO '$newdbadminuser'@'localhost'
|
||||
REQUIRE NONE WITH GRANT OPTION
|
||||
MAX_QUERIES_PER_HOUR 0
|
||||
MAX_CONNECTIONS_PER_HOUR 0
|
||||
MAX_UPDATES_PER_HOUR 0
|
||||
MAX_USER_CONNECTIONS 0;
|
||||
flush privileges"
|
||||
echo ""
|
||||
echo ""
|
||||
echo "You can now access phpmyadmin using a web browser pointed to:"
|
||||
echo ""
|
||||
echo " http://$HOSTNAME/phpmyadmin"
|
||||
echo ""
|
||||
echo "*** WARNING!! this url is accessible via unencrypted (http) connections."
|
||||
echo "This is a huge security risk since the username and password you enter"
|
||||
echo "on the phpmyadmin login page can be sent in the clear for any potential"
|
||||
echo "attacker to sniff! You should enable redirection to https for phpmyadmin"
|
||||
echo "in your apache2 configuration if your site is reachable from the internet."
|
||||
echo ""
|
||||
echo -n "Press enter to continue."
|
||||
read continueok
|
||||
echo ""
|
||||
echo "Finished with phpmyadmin installation"
|
||||
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 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 "Proceeding with webmin installation"
|
||||
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 "Finished with webmin installation"
|
||||
echo ""
|
||||
sleep 3
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Finished optional package installation."
|
||||
fi
|
||||
echo ""
|
||||
# Determine the correct Apache2 user and group
|
||||
APACHE_USER=$(grep APACHE_RUN_USER /etc/apache2/envvars | cut -d= -f2)
|
||||
APACHE_GROUP=$(grep APACHE_RUN_GROUP /etc/apache2/envvars | cut -d= -f2)
|
||||
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
|
||||
|
||||
sleep 3
|
||||
# prompt for install location
|
||||
echo "Where would you like to install this version of $APP_NAME? This should"
|
||||
@@ -322,6 +184,7 @@ fi
|
||||
install_path="$doc_root_in/$install_loc_in"
|
||||
if [ -d "$install_path" ]
|
||||
then
|
||||
echo "The installation path you chose already exists."
|
||||
# Install path exists.
|
||||
if [ -e "$install_path/db.php" ]
|
||||
then
|
||||
@@ -329,7 +192,6 @@ then
|
||||
if grep -q -e "$APP_NAME" $install_path/db.php
|
||||
then
|
||||
# the db.php file is part of a previous installation
|
||||
echo "The installation path you chose already exists."
|
||||
echo "Would you like to upgrade an existing installation or cancel "
|
||||
echo "and restart the install using a new installation location."
|
||||
echo -n "[U]pgrade or [C]ancel? [C] :"
|
||||
@@ -337,23 +199,49 @@ then
|
||||
if [ "$upgrade_choice" = "U" -o "$upgrade_choice" = "u" ] # Upgrade chosen
|
||||
then
|
||||
# proceed with upgrade
|
||||
mkdir -p backups
|
||||
operation="upgraded"
|
||||
curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2)
|
||||
|
||||
# create mysql option file with data for this installation
|
||||
mysql_opt_file=$(mktemp --tmpdir=/run/shm/)
|
||||
echo "[client]" > $mysql_opt_file
|
||||
echo "user = $(grep username $install_path/db.php | head -1 | cut -d\" -f2)" >> $mysql_opt_file
|
||||
echo "password = $(grep dbpass $install_path/db.php | head -1 | cut -d\" -f2)" >> $mysql_opt_file
|
||||
echo "" >> $mysql_opt_file
|
||||
echo "[mysql]" > $mysql_opt_file
|
||||
echo "database = $curr_dbname" >> $mysql_opt_file
|
||||
echo "batch" >> $mysql_opt_file
|
||||
echo "disable-column-names" >> $mysql_opt_file
|
||||
|
||||
# back up existing database
|
||||
echo "Backing up the current database to the package directory."
|
||||
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`
|
||||
export MYSQL_PWD="$curr_dbpass"
|
||||
mysqldump --no-tablespaces -u"$curr_username" $curr_dbname > $curr_dbname-`date +%Y-%m-%d_%H:%M:%S`-backup.sql
|
||||
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > backups/$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
|
||||
cp -R $install_path backups/$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" -f -D $curr_dbname < database-update.sql >/dev/null 2>&1
|
||||
# apply updates to existing db.php
|
||||
bash ./db.php_update $install_path
|
||||
|
||||
echo "Performing database updates. This may take a while..."
|
||||
# apply database updates from sql file
|
||||
(mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) &
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
|
||||
# apply database updates via script
|
||||
(bash ./database-update.sh $mysql_opt_file) &
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
|
||||
echo "... finished with database updates."
|
||||
rm -f $mysql_opt_file
|
||||
|
||||
# apply updates to other files
|
||||
bash ./files-update.sh $install_path
|
||||
|
||||
# copy distribution to install location
|
||||
echo "Installing distribution . . ."
|
||||
cp -R distfiles/* $install_path
|
||||
@@ -365,21 +253,14 @@ then
|
||||
# set symlink for index.php
|
||||
if [ ! -L "$install_path/index.php" ]
|
||||
then
|
||||
ln -s $install_path/$INDEX_FILE $install_path/index.php
|
||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||
fi
|
||||
# add the local timezone to .htaccess
|
||||
local_tz=$(timedatectl show -p Timezone|cut -d= -f2)
|
||||
echo "Your local timezone is $local_tz"
|
||||
echo "php_value date.timezone \"$local_tz\"">$install_path/.htaccess
|
||||
|
||||
# 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 $APP_NAME 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
|
||||
@@ -396,8 +277,21 @@ then
|
||||
else
|
||||
# This was a mistake. Exit now to avoid clobbering another app.
|
||||
echo "The installation directory you chose exists, but no previous installation"
|
||||
echo "of $APP_NAME was found. Please investigate the situation. Aborting now."
|
||||
abort_exit
|
||||
echo "of $APP_NAME was found."
|
||||
echo ""
|
||||
echo " CAUTION: If there is anything else in this directory, it will be deleted!"
|
||||
echo ""
|
||||
echo "Would you like to use this location for a fresh installation or quit and"
|
||||
echo "investigate further? It's probably safest to quit and investigate."
|
||||
proceed=""
|
||||
while [[ $proceed != "P" && $proceed != "p" && $proceed != "Q" && $proceed != "q" ]]
|
||||
do
|
||||
read proceed -p "[P]roceed with new install or [Q]uit? : "
|
||||
done
|
||||
if [[ $proceed == "Q" || $proceed == "q" ]]
|
||||
then
|
||||
abort_exit
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# This is a fresh install
|
||||
@@ -486,21 +380,14 @@ else
|
||||
fi
|
||||
if [ ! -L "$install_path/index.php" ]
|
||||
then
|
||||
ln -s $install_path/lognotes.php $install_path/index.php
|
||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||
fi
|
||||
# add the local timezone to .htaccess
|
||||
local_tz=$(timedatectl show -p Timezone|cut -d= -f2)
|
||||
echo "Your local timezone is $local_tz"
|
||||
echo "php_value date.timezone \"$local_tz\"">$install_path/.htaccess
|
||||
|
||||
# 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 $APP_NAME 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
|
||||
@@ -521,6 +408,7 @@ then
|
||||
echo "Alias /$base_url $doc_root_in/$base_url" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "<Directory $doc_root_in/$base_url>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " AllowOverride Options" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
|
||||
Reference in New Issue
Block a user