This repository has been archived on 2024-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
joomla/bin/joomla_cleanup.sh
2023-07-09 23:34:46 -07:00

89 lines
2.6 KiB
Bash

#!/bin/bash
# Are you root?
if [ "$EUID" -ne 0 ]; then
echo -e "\033[0;31mThis script must be run as root.\033[0m"
exit 1
fi
##################################################################
# ENV file
##################################################################
# Verify the .env file exists
if [ ! -f ".env" ]; then
echo "Error: The .env file does not exist."
exit 1
fi
# Load environment variables from .env file
set -o allexport
source .env
set +o allexport
##################################################################
# Variables
##################################################################
PROJECTNAME=$(basename "$(pwd)")
# Joomla Configuration Defaults
if [ -z "$JCONFIG_REPORTING" ]; then
JCONFIG_REPORTING='none'
fi
if [ -z "$JCONFIG_TIMEZONE" ]; then
JCONFIG_TIMEZONE='America/Vancouver'
fi
if [ -z "$JCONFIG_SEF" ]; then
JCONFIG_SEF=true
fi
# SMTP ENV CHECK
if [ -z "$SMTP_MAILER" ]; then
SMTP_MAILER='/usr/sbin/sendmail'
fi
if [ -z "$SMTP_USER" ]; then
SMTP_USER=null
fi
if [ -z "$SMTP_PASS" ]; then
SMTP_PASS=null
fi
if [ -n "$SMTP_PASS" ]; then
SMTP_AUTH=true
else
SMTP_AUTH=false
fi
if [ -z "$SMTP_HOST" ]; then
SMTP_HOST='mailhog'
fi
if [ -z "$SMTP_SECURITY" ]; then
SMTP_SECURITY='None'
fi
if [ -z "$SMTP_PORT" ]; then
SMTP_PORT=1025
fi
# Set configuration.php
docker-compose exec -u www-data joomla php cli/joomla.php config:set error_reporting="${JCONFIG_REPORTING}"
docker-compose exec -u www-data joomla php cli/joomla.php config:set offset="${JCONFIG_TIMEZONE}"
docker-compose exec -u www-data joomla php cli/joomla.php config:set sef_rewrite="${JCONFIG_SEF}"
#SMTP
docker-compose exec -u www-data joomla php cli/joomla.php config:set mailer=smtp
docker-compose exec -u www-data joomla php cli/joomla.php config:set sendmail="${SMTP_MAILER}"
docker-compose exec -u www-data joomla php cli/joomla.php config:set smtpuser="${SMTP_USER}"
docker-compose exec -u www-data joomla php cli/joomla.php config:set smtppass="${SMTP_PASS}"
docker-compose exec -u www-data joomla php cli/joomla.php config:set smtpauth="${SMTP_AUTH}"
docker-compose exec -u www-data joomla php cli/joomla.php config:set smtphost="${SMTP_HOST}"
docker-compose exec -u www-data joomla php cli/joomla.php config:set smtpsecure="${SMTP_SECURITY}"
docker-compose exec -u www-data joomla php cli/joomla.php config:set smtpport="${SMTP_PORT}"
# Remove uneeded Joomla files
rm -f html/web.config.txt
rm -f html/htaccess.txt
rm -f html/LICENSE.txt
rm -f html/README.txt
# Remove Install helper scripts
rm -rf bin/inc_new_project
rm -rf bin/joomla_new_project.sh
rm -rf bin/joomla_install.sh
echo "Now check the results and commit them to Git"