updated documenation, fixed install script

This commit is contained in:
Nick Yeoman 2023-06-07 14:16:31 -07:00
parent 815a551a07
commit 05f289eae0
12 changed files with 146 additions and 174 deletions

View File

@ -1,78 +1,8 @@
# Joomla # 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)

View File

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
################################################################################################### ###################################################################################################
#
# INSTRUCTIONS # INSTRUCTIONS
# Move to the directory of the component # Move to the directory of the component
# Run this script with component name (com_name) # Run this script with component name (com_name)

View File

@ -6,20 +6,80 @@ if [ "$EUID" -ne 0 ]; then
exit 1 exit 1
fi 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)") 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/web.config.txt
rm -f html/htaccess.txt rm -f html/htaccess.txt
rm -f html/LICENSE.txt rm -f html/LICENSE.txt
rm -f html/README.txt rm -f html/README.txt
# Set configuration.php # Remove Install helper scripts
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/inc_new_project
rm -rf bin/new_project.sh rm -rf bin/new_project.sh
rm -rf bin/setup_joomla_installer.sh rm -rf bin/setup_joomla_installer.sh

38
bin/gitea_secrets.sh Normal file
View File

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

View File

@ -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 \ docker-compose exec -u www-data joomla php installation/joomla.php install \
--site-name=$PROJECTNAME \ --site-name=$PROJECTNAME \
--admin-email=$EMAIL \ --admin-email=$EMAIL \
--admin-user=$JOOMLA_USER \ --admin-user="$JOOMLA_USER" \
--admin-username=$JOOMLA_USERNAME \ --admin-username=$JOOMLA_USERNAME \
--admin-password=$JOOMLA_PASSWORD \ --admin-password=$JOOMLA_PASSWORD \
--db-type=mysqli \ --db-type=mysqli \

9
development/README.md Normal file
View File

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

View File

@ -20,6 +20,8 @@ services:
MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_DATABASE: ${MYSQL_DATABASE}
volumes: volumes:
- joomla-db:/var/lib/mysql - joomla-db:/var/lib/mysql
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
joomla: joomla:
image: joomla:4.3.2 # https://hub.docker.com/_/joomla image: joomla:4.3.2 # https://hub.docker.com/_/joomla
@ -31,7 +33,10 @@ services:
JOOMLA_DB_NAME: ${MYSQL_DATABASE} JOOMLA_DB_NAME: ${MYSQL_DATABASE}
volumes: volumes:
- ./html:/var/www/html - ./html:/var/www/html
- ./development:/development
- ./php/php.ini:/usr/local/etc/php/php.ini - ./php/php.ini:/usr/local/etc/php/php.ini
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
ports: ports:
- "8000:80" - "8000:80"
@ -44,9 +49,15 @@ services:
UPLOAD_LIMIT: '200M' UPLOAD_LIMIT: '200M'
ports: ports:
- "8001:80" - "8001:80"
volumes:
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
mailhog: mailhog:
image: 'mailhog/mailhog:latest' # https://hub.docker.com/r/mailhog/mailhog image: 'mailhog/mailhog:latest' # https://hub.docker.com/r/mailhog/mailhog
ports: ports:
- "1025:1025" - "${SMTP_PORT}:1025"
- "8002:8025" - "8002:8025"
volumes:
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"

View File

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

View File

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

3
docs/README.md Normal file
View File

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

View File

@ -15,5 +15,12 @@ ACCESS_TOKEN=REPLACEME
EMAIL=noreply@example.com EMAIL=noreply@example.com
JOOMLA_USER="John Doe" JOOMLA_USER="John Doe"
JOOMLA_USERNAME=admin JOOMLA_USERNAME=admin
# Passwords must be 12 characters long # Passwords must be 12 characters long (admin-password)
JOOMLA_PASSWORD=REPLACEME123 JOOMLA_PASSWORD=REPLACEME123
# SMTP
SMTP_USER=null
SMTP_PASS=null
SMTP_HOST='mailhog'
SMTP_SECURITY='None'
SMTP_PORT=1025