Update piwigo-install.sh - minor edits

This commit is contained in:
tschettervictor
2024-09-29 16:57:21 -06:00
committed by GitHub
parent 2dbc49dc99
commit de16a6facd

View File

@@ -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