From de16a6facdbefc25740cf40f05c44631f552b74b Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sun, 29 Sep 2024 16:57:21 -0600 Subject: [PATCH] Update piwigo-install.sh - minor edits --- piwigo/piwigo-install.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/piwigo/piwigo-install.sh b/piwigo/piwigo-install.sh index fbec676..f66d270 100644 --- a/piwigo/piwigo-install.sh +++ b/piwigo/piwigo-install.sh @@ -1,12 +1,6 @@ #!/bin/sh # Install Piwigo Gallery -# Check for Root Privileges -if ! [ $(id -u) = 0 ]; then - echo "This script must be run with root privileges" - exit 1 -fi - APP_NAME="Piwigo" DB_TYPE="MariaDB" DB_NAME="piwigo" @@ -16,6 +10,12 @@ DB_PASSWORD=$(openssl rand -base64 15) PHP_VERSION="83" MARIADB_VERSION="106" +# Check for Root Privileges +if ! [ $(id -u) = 0 ]; then + echo "This script must be run with root privileges" + exit 1 +fi + # Check for Reinstall if [ "$(ls -A /var/db/mysql/"${DB_NAME}" 2>/dev/null)" ]; then echo "Existing ${APP_NAME} database detected." @@ -40,7 +40,6 @@ if [ "${REINSTALL}" == "true" ]; then echo "You did a reinstall, but the ${DB_TYPE} root password AND ${APP_NAME} database password will be changed." echo "New passwords will be saved in the root directory." mysql -u root -e "SET PASSWORD FOR '${DB_USER}'@localhost = PASSWORD('${DB_PASSWORD}');" - sed -i '' -e "s|.*db_password.*|\$conf['db_password'] = '${DB_PASSWORD}';|g" /usr/local/www/piwigo/local/config/database.inc.php fetch -o /root/.my.cnf https://raw.githubusercontent.com/tschettervictor/bsd-apps/main/piwigo/includes/my.cnf sed -i '' "s|mypassword|${DB_ROOT_PASSWORD}|" /root/.my.cnf else @@ -65,6 +64,9 @@ mv "/tmp/dlcounter.php?code=latest" /tmp/piwigo.zip unzip -n -d /usr/local/www /tmp/piwigo.zip sh -c 'find /usr/local/www/ -type d -print0 | xargs -0 chmod 775' sh -c 'find /usr/local/www/ -type f -print0 | xargs -0 chmod 644' +if [ "${REINSTALL}" == "true" ]; then + sed -i '' -e "s|.*db_password.*|\$conf['db_password'] = '${DB_PASSWORD}';|g" /usr/local/www/piwigo/local/config/database.inc.php +fi chown -R www:www /usr/local/www # Enable and Start Services