From 44413a17df937d3ae7e3d45d414dc3d2e85ca0c3 Mon Sep 17 00:00:00 2001 From: Nick Yeoman Date: Sat, 20 May 2023 16:06:24 -0700 Subject: [PATCH] works to a full install --- README.md | 3 ++ bin/docker_up.sh | 1 + bin/finalize.sh | 28 +++++++++++++++ bin/setup_joomla_installer.sh | 64 +++++++++++++++++++++++++---------- env.sample | 3 +- 5 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 bin/finalize.sh diff --git a/README.md b/README.md index d4fbb83..e813826 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,7 @@ Make sure the projectName is set correctly, it's very important. 1. Prepare your project for git ```bash bin/new_project.sh``` 1. Run the containers to initialize ```sudo bash bin/docker_up.sh``` 1. Prepare the installer ```bash bin/setup_joomla_installer.sh``` +1. Go to ```http://localhost:8000``` and follow the installation steps +1. Manually set Site Meta Description in [Administrator](http://localhost:8000/administrator) +1. Run ```sudo bash bin/finalize.sh``` diff --git a/bin/docker_up.sh b/bin/docker_up.sh index 6a4a9f2..d81cf83 100644 --- a/bin/docker_up.sh +++ b/bin/docker_up.sh @@ -1,5 +1,6 @@ #!/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 diff --git a/bin/finalize.sh b/bin/finalize.sh new file mode 100644 index 0000000..fc0db54 --- /dev/null +++ b/bin/finalize.sh @@ -0,0 +1,28 @@ +#!/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 + +PROJECTNAME=$(basename "$(pwd)") + +# Remove crap files +rm -f html/web.config.txt +rm -f html/htaccess.txt +rm -f html/LICENSE.txt + +# Set configuration.php +docker-compose exec -u www-data joomla php cli/joomla.php config:set error_reporting=none +docker-compose exec -u www-data joomla php cli/joomla.php config:set offset=America/Vancouver +docker-compose exec -u www-data joomla php cli/joomla.php config:set sef_rewrite=true + +# remove unused files from install +rm -rf bin/inc_new_project +rm -rf bin/new_project.sh +rm -rf bin/setup_joomla_installer.sh + +# Git +git add . +git commit -m"ran finalize" diff --git a/bin/setup_joomla_installer.sh b/bin/setup_joomla_installer.sh index 9c4dc37..dd73ec7 100644 --- a/bin/setup_joomla_installer.sh +++ b/bin/setup_joomla_installer.sh @@ -26,26 +26,54 @@ set +o allexport # create json file ################################################################## -DB_PREFIX=$(echo $RANDOM | md5sum | awk '{print substr($1, 1, 3)}')_ +#DB_PREFIX=$(echo $RANDOM | md5sum | awk '{print substr($1, 1, 3)}')_ -docker-compose exec -u www-data joomla sh -c "echo '{ - \"language\":\"en-GB\", - \"site_name\":\"$PROJECTNAME\", - \"admin_email\":\"$EMAIL\", - \"admin_user\":\"$JOOMLA_USER\", - \"admin_password\":\"$JOOMLA_PASSWORD\", - \"db_type\":\"mysql\", - \"db_host\":\"mariadb\", - \"db_user\":\"$MYSQL_USER\", - \"db_pass\":\"$MYSQL_PASSWORD\", - \"db_name\":\"$MYSQL_DATABASE\", - \"db_prefix\":\"$DB_PREFIX\", - \"db_old\":\"remove\", - \"helpurl\":\"https://joomla.org\" -}' > config.json" +# docker-compose exec -u www-data joomla sh -c "echo '{ +# \"language\":\"en-GB\", +# \"site_name\":\"$PROJECTNAME\", +# \"admin_email\":\"$EMAIL\", +# \"admin_user\":\"$JOOMLA_USER\", +# \"admin_password\":\"$JOOMLA_PASSWORD\", +# \"db_type\":\"mysql\", +# \"db_host\":\"mariadb\", +# \"db_user\":\"$MYSQL_USER\", +# \"db_pass\":\"$MYSQL_PASSWORD\", +# \"db_name\":\"$MYSQL_DATABASE\", +# \"db_prefix\":\"$DB_PREFIX\", +# \"db_old\":\"remove\", +# \"helpurl\":\"https://joomla.org\" +# }' > config.json" + +# docker-compose exec -u www-data joomla php cli/joomla.php core:install --file=config.json ################################################################## -# run the installer +# EASY GUI SETUP ################################################################## -docker-compose exec -u www-data joomla php cli/joomla.php core:install --file=config.json \ No newline at end of file +# Site Name +xmlstarlet ed -L -s '//field[@name="site_name"]' -t attr -n default -v "$PROJECTNAME" html/installation/forms/setup.xml + +# Super User Full Name +xmlstarlet ed -L -s '//field[@name="admin_user"]' -t attr -n default -v "$JOOMLA_USER" html/installation/forms/setup.xml + +# Super User username +xmlstarlet ed -L -s '//field[@name="admin_username"]' -t attr -n default -v "$JOOMLA_USER" html/installation/forms/setup.xml + +# Super User Password +xmlstarlet ed -L -s '//field[@name="admin_password"]' -t attr -n default -v "$JOOMLA_PASSWORD" html/installation/forms/setup.xml + +# Super User email +xmlstarlet ed -L -s '//field[@name="admin_email"]' -t attr -n default -v "$EMAIL" html/installation/forms/setup.xml + +# Database host +xmlstarlet ed -L -u '//field[@name="db_host"]/@default' -v 'mariadb' html/installation/forms/setup.xml + +# Database user +xmlstarlet ed -L -s '//field[@name="db_user"]' -t attr -n default -v "$MYSQL_USER" html/installation/forms/setup.xml + +# Database password +xmlstarlet ed -L -s '//field[@name="db_pass"]' -t attr -n default -v "$MYSQL_PASSWORD" html/installation/forms/setup.xml + +# Database name +xmlstarlet ed -L -u '//field[@name="db_name"]/@default' -v "$MYSQL_DATABASE" html/installation/forms/setup.xml + diff --git a/env.sample b/env.sample index f7f24f8..9ad4d64 100644 --- a/env.sample +++ b/env.sample @@ -17,4 +17,5 @@ ACCESS_TOKEN=REPLACEME # Joomla EMAIL=noreply@example.com JOOMLA_USER=admin -JOOMLA_PASSWORD=REPLACEME \ No newline at end of file +# Passwords must be 12 characters long +JOOMLA_PASSWORD=REPLACEME123 \ No newline at end of file