From 05f289eae076f672708698c7864c889f4f264fb8 Mon Sep 17 00:00:00 2001 From: Nick Yeoman Date: Wed, 7 Jun 2023 14:16:31 -0700 Subject: [PATCH] updated documenation, fixed install script --- README.md | 78 +------------------ ..._component.sh => component_scaffolding.sh} | 0 bin/{build_component.sh => component_zip.sh} | 1 - bin/finalize.sh | 76 ++++++++++++++++-- bin/gitea_secrets.sh | 38 +++++++++ bin/setup_joomla_installer.sh | 2 +- development/README.md | 9 +++ docker-compose.yml | 17 +++- docs/CLI.md | 75 ------------------ docs/FAQs.md | 10 --- docs/README.md | 3 + env.sample | 11 ++- 12 files changed, 146 insertions(+), 174 deletions(-) rename bin/{create_component.sh => component_scaffolding.sh} (100%) rename bin/{build_component.sh => component_zip.sh} (99%) create mode 100644 bin/gitea_secrets.sh create mode 100644 development/README.md delete mode 100644 docs/CLI.md delete mode 100644 docs/FAQs.md create mode 100644 docs/README.md diff --git a/README.md b/README.md index 67c6cf5..1b5dd05 100644 --- a/README.md +++ b/README.md @@ -1,78 +1,8 @@ # Joomla -Joomla CMS. +This repository hold all the information Nick has documented about Joomla. +There are also helper files and scripts here. -Make sure the projectName is set correctly, it's very important, because it's used for git, docker, mysql and joomla. +* [Gitea Repo](https://git.nickyeoman.com/nick/joomla/) +* [Wiki](https://git.nickyeoman.com/nick/joomla/wiki) -## Quick Installation - -```bash -# STEP 1 -# Clone the repo (change projectName to the name of your project) -git clone git@git.nickyeoman.com:nick/joomla.git projectName - -# STEP 2 -# Move into the dir -cd projectName - -# STEP 3 -# Setup your env file -mv env.sample .env -vi .env - -# STEP 4 -# Prepare your project for git -bash bin/new_project.sh - -# STEP 5 -# Run the containers to initialize -sudo bash bin/docker_up.sh - -# STEP 6 -# Joomla cli installer -sudo bash bin/setup_joomla_installer.sh - -# STEP 7 -# Manually set Site Meta Description in [Administrator](http://localhost:8000/administrator/index.php?option=com_config) - -# Step 8 -# Clean up and Config -sudo bash bin/finalize.sh - -``` - -## Development Environment - -Let's update our bash_profile with some alias: -```bash -alias joomla='docker-compose exec -u www-data joomla php cli/joomla.php' -``` -Allowing you to just run commands like this: -```bash -joomla core:check-updates -joomla site:down -joomla extension:list -joomla update:extensions:check -joomla cache:clean - -``` - -## Create A Component - -1. Move to the directory where you would like to keep the component. ```cd ~/joomla-components/``` -1. Run component creator from your Joomla install. ```bash ~/projects/joomla/projectName/bin/create_component.sh``` -1. Optionally save to git repo. -1. build the zip file by running bin/build_component.sh - -## References - -* [Joomla Twig](https://phproberto.github.io/joomla-twig/) - -### Component - -* https://github.com/ceford/j4xdemos-com-mywalks/tree/master -* https://www.abdulwaheed.pk/en/blog/41-information-technology/44-joomla/302-how-to-create-joomla-4-component.html -* Can't get this one working either: https://www.techfry.com/resources/how-to-create-joomla-component -* https://docs.joomla.org/J4.x:Developing_an_MVC_Component/Introduction - * Can't get this one working [Develop a component](https://docs.joomla.org/J4.x:Developing_an_MVC_Component/Developing_a_Basic_Component) -* [Minimal component](https://joomla.stackexchange.com/questions/22176/minimal-basic-structure-for-a-frontend-joomla-component-without-using-joomla-mvc) \ No newline at end of file diff --git a/bin/create_component.sh b/bin/component_scaffolding.sh similarity index 100% rename from bin/create_component.sh rename to bin/component_scaffolding.sh diff --git a/bin/build_component.sh b/bin/component_zip.sh similarity index 99% rename from bin/build_component.sh rename to bin/component_zip.sh index 68490c8..56de801 100644 --- a/bin/build_component.sh +++ b/bin/component_zip.sh @@ -1,6 +1,5 @@ #!/bin/bash ################################################################################################### -# # INSTRUCTIONS # Move to the directory of the component # Run this script with component name (com_name) diff --git a/bin/finalize.sh b/bin/finalize.sh index b37699f..d662244 100644 --- a/bin/finalize.sh +++ b/bin/finalize.sh @@ -6,22 +6,82 @@ if [ "$EUID" -ne 0 ]; then 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)") -# Remove crap files +# 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 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 -# 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 +# Remove Install helper scripts rm -rf bin/inc_new_project rm -rf bin/new_project.sh rm -rf bin/setup_joomla_installer.sh -echo "Now check the results and commit them to Git" \ No newline at end of file +echo "Now check the results and commit them to Git" diff --git a/bin/gitea_secrets.sh b/bin/gitea_secrets.sh new file mode 100644 index 0000000..b072313 --- /dev/null +++ b/bin/gitea_secrets.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Load environment variables from .env file +if [ -f ".env" ]; then + set -o allexport + source .env + set +o allexport +else + echo "Error: The .env file does not exist." + exit 1 +fi + +USERNAME="" +PASSWORD="" + +read -p "Enter your Gitea username: " USERNAME +read -s -p "Enter your Gitea password: " PASSWORD +echo + +secrets_response=$(curl -s -u "$USERNAME:$PASSWORD" "$GITEA_API/repos/$REPO_OWNER/$REPO_NAME/actions/secrets") +status_code=$(tail -c 3 <<< "$secrets_response") + +if [[ $status_code -eq 401 ]]; then + echo "Authentication failed. Please check your username and password." + exit 1 +fi + +# Get the secret keys +secret_keys=$(echo "$secrets_response" | jq -r '.[].name') + +# Loop through secret keys +for secret_key in $secret_keys; do + secret_response=$(curl -s -u "$USERNAME:$PASSWORD" "$GITEA_API/repos/$REPO_OWNER/$REPO_NAME/actions/secrets/$secret_key") + secret_value=$(echo "$secret_response" | jq -r '.secret') + + # Update .env file + sed -i "s/$secret_key=.*/$secret_key=$secret_value/" .env +done diff --git a/bin/setup_joomla_installer.sh b/bin/setup_joomla_installer.sh index c55645b..8afc1d2 100644 --- a/bin/setup_joomla_installer.sh +++ b/bin/setup_joomla_installer.sh @@ -33,7 +33,7 @@ DB_PREFIX=$(LC_CTYPE=C tr -dc '[:alpha:]' < /dev/urandom | head -c 3)_ docker-compose exec -u www-data joomla php installation/joomla.php install \ --site-name=$PROJECTNAME \ --admin-email=$EMAIL \ - --admin-user=$JOOMLA_USER \ + --admin-user="$JOOMLA_USER" \ --admin-username=$JOOMLA_USERNAME \ --admin-password=$JOOMLA_PASSWORD \ --db-type=mysqli \ diff --git a/development/README.md b/development/README.md new file mode 100644 index 0000000..832b610 --- /dev/null +++ b/development/README.md @@ -0,0 +1,9 @@ +# Development directory + +This directory is accessable from the Joomla installation app. + +it mounts as /development +should be removed from your production +includes git sub modules to other repositories + + diff --git a/docker-compose.yml b/docker-compose.yml index 4005235..eb4a298 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,8 @@ services: MYSQL_DATABASE: ${MYSQL_DATABASE} volumes: - joomla-db:/var/lib/mysql + - "/etc/timezone:/etc/timezone:ro" + - "/etc/localtime:/etc/localtime:ro" joomla: image: joomla:4.3.2 # https://hub.docker.com/_/joomla @@ -31,7 +33,10 @@ services: JOOMLA_DB_NAME: ${MYSQL_DATABASE} volumes: - ./html:/var/www/html + - ./development:/development - ./php/php.ini:/usr/local/etc/php/php.ini + - "/etc/timezone:/etc/timezone:ro" + - "/etc/localtime:/etc/localtime:ro" ports: - "8000:80" @@ -44,9 +49,15 @@ services: UPLOAD_LIMIT: '200M' ports: - "8001:80" - + volumes: + - "/etc/timezone:/etc/timezone:ro" + - "/etc/localtime:/etc/localtime:ro" + mailhog: image: 'mailhog/mailhog:latest' # https://hub.docker.com/r/mailhog/mailhog ports: - - "1025:1025" - - "8002:8025" \ No newline at end of file + - "${SMTP_PORT}:1025" + - "8002:8025" + volumes: + - "/etc/timezone:/etc/timezone:ro" + - "/etc/localtime:/etc/localtime:ro" diff --git a/docs/CLI.md b/docs/CLI.md deleted file mode 100644 index a3a9a44..0000000 --- a/docs/CLI.md +++ /dev/null @@ -1,75 +0,0 @@ -# CLI Cheatsheet - -## Cache -``` -cache:clean Clean expired cache entries -``` - -## Config -``` -config:get Display the current value of a configuration option -config:set Set a value for a configuration option -``` - -## Core -``` -core:check-updates Check for Joomla updates -core:update Update Joomla -``` - -## Database -``` -database:export database:export -database:import Import the database -``` - -## Extension -``` -extension:discover Discover extensions -extension:discover:install Install discovered extensions -extension:discover:list List discovered extensions -extension:install Install an extension from a URL or from a path -extension:list List installed extensions -extension:remove Remove an extension -``` - -## Finder -``` -finder:index Purges and rebuild the index -Scheduler -scheduler:list List all scheduled tasks -scheduler:run Run one or more scheduled tasks -scheduler:state Enable, disable or trash a scheduled task -``` - -## Session -``` -session:gc Perform session garbage collection -session:metadata:gc Perform session metadata garbage collection -``` - -## Site -``` -site:down Put the site into offline mode -site:up Put the site into online mode -``` - -## Update -``` -update:extensions:check Check for pending extension updates -update:joomla:remove-old-files Remove old system files -``` - -## User -``` -user:add Add a user -user:addtogroup Add a user to a group -user:delete Delete a user -user:list List all users -user:removefromgroup Remove a user from a group -user:reset-password Change a user's password -``` - -## References - -* [Joomla Magazine - Powerful cli](https://magazine.joomla.org/all-issues/june-2022/joomla-4-a-powerful-cli-application) \ No newline at end of file diff --git a/docs/FAQs.md b/docs/FAQs.md deleted file mode 100644 index 49f89ff..0000000 --- a/docs/FAQs.md +++ /dev/null @@ -1,10 +0,0 @@ -# Frequently Asked Questions - -## How do I add user to Docker - -Read more on [Docker's Official Post Instalation Docs](https://docs.docker.com/engine/install/linux-postinstall/) - -```bash -sudo usermod -aG docker $USER -newgrp docker -``` diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..9451adf --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# Joomla Repository Documenation + +Nick's Joomla Repository Documenation is located in the Repo's wiki: https://git.nickyeoman.com/nick/joomla/wiki \ No newline at end of file diff --git a/env.sample b/env.sample index 6fcc4d9..5b42125 100644 --- a/env.sample +++ b/env.sample @@ -15,5 +15,12 @@ ACCESS_TOKEN=REPLACEME EMAIL=noreply@example.com JOOMLA_USER="John Doe" JOOMLA_USERNAME=admin -# Passwords must be 12 characters long -JOOMLA_PASSWORD=REPLACEME123 \ No newline at end of file +# Passwords must be 12 characters long (admin-password) +JOOMLA_PASSWORD=REPLACEME123 + +# SMTP +SMTP_USER=null +SMTP_PASS=null +SMTP_HOST='mailhog' +SMTP_SECURITY='None' +SMTP_PORT=1025 \ No newline at end of file