3 Commits

2 changed files with 101 additions and 11 deletions

View File

@ -8,6 +8,8 @@ There are more than one .env file and the script will set those up for you whene
the script will check if those values exist, and if they don't it will ask for them, and store them automatically for future use. the script will check if those values exist, and if they don't it will ask for them, and store them automatically for future use.
That same time the output message to the terminal will show you where the specific .env file can be found. That same time the output message to the terminal will show you where the specific .env file can be found.
> program only for ubuntu/debian systems at this time (should you like to use it on other OS's please open and issue...)
--- ---
# Install # Install
```shell ```shell

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# The most recent program version. # The most recent program version.
_VERSION="3.0.0" _VERSION="3.0.1"
_V="3.0" _V="3.0"
# The program full name # The program full name
@ -259,13 +259,21 @@ function joomla__TRuST__setup() {
local vdm_env_pass local vdm_env_pass
local vdm_key_root local vdm_key_root
local vdm_env_root local vdm_env_root
# get the Joomla image source
VDM_J_REPO=$(getImageSource)
# build the URL
if [ "${VDM_J_REPO}" = 'joomla' ]; then
vdm_image_repo_url="https://hub.docker.com/_/${VDM_J_REPO}?tab=tags"
else
vdm_image_repo_url="https://hub.docker.com/r/${VDM_J_REPO}/tags"
fi
# get the Joomla version if not set # get the Joomla version if not set
while [ ${#VDM_JV} -le 1 ]; do while [ ${#VDM_JV} -le 1 ]; do
# get the value # get the value
VDM_JV=$(getInput 'Enter Joomla version tag for this container.\n[See available tags here https://hub.docker.com/_/joomla]' '3.10' 'Enter Version Tag') VDM_JV=$(getInput "Enter Joomla version tag for this container.\n[See available tags here ${vdm_image_repo_url}]" '3.10' 'Enter Version Tag')
# keep asking # keep asking
[ ${#VDM_JV} -ge 1 ] || { [ ${#VDM_JV} -ge 1 ] || {
showError "You must enter a version tag. See available tags here https://hub.docker.com/_/joomla" showError "You must enter a version tag. See available tags here ${vdm_image_repo_url}"
} }
done done
# get the key if not set # get the key if not set
@ -350,6 +358,16 @@ function joomla__TRuST__setup() {
} }
# add the projects path # add the projects path
setContainerEnvVariable "VDM_PROJECT_PATH=\"${VDM_PROJECT_PATH}\"" setContainerEnvVariable "VDM_PROJECT_PATH=\"${VDM_PROJECT_PATH}\""
# set the container user detail id needed
if [ "${VDM_J_REPO}" = 'llewellyn/joomla' ]; then
# if this is our octoleo images we can also set the user ID and user-group ID
setContainerUser
# check that we got the details
if [ -n "${VDM_PUID}" ] && [ -n "${VDM_PGID}" ]; then
setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_PUID=\"#${VDM_PUID}\""
setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_PGID=\"#${VDM_PGID}\""
fi
fi
# add this value if not set variable # add this value if not set variable
[ ${#vdm_database_name} -ge 1 ] && setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_DB=\"${vdm_database_name}\"" [ ${#vdm_database_name} -ge 1 ] && setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_DB=\"${vdm_database_name}\""
# add this value if not set variable # add this value if not set variable
@ -365,6 +383,7 @@ function joomla__TRuST__setup() {
export VDM_REPO_PATH export VDM_REPO_PATH
export VDM_PROJECT_PATH export VDM_PROJECT_PATH
# container # container
export VDM_J_REPO
export VDM_JV export VDM_JV
export VDM_REMOVE_SECURE export VDM_REMOVE_SECURE
export VDM_ENTRY_POINT export VDM_ENTRY_POINT
@ -400,12 +419,15 @@ function joomla__TRuST__setup() {
### unset all no longer needed ### unset all no longer needed
# container # container
unset VDM_SUBDOMAIN unset VDM_SUBDOMAIN
unset VDM_J_REPO
unset VDM_JV unset VDM_JV
unset VDM_KEY unset VDM_KEY
unset VDM_ENV_KEY unset VDM_ENV_KEY
unset VDM_REMOVE_SECURE unset VDM_REMOVE_SECURE
unset VDM_ENTRY_POINT unset VDM_ENTRY_POINT
unset VDM_HTTP_SCHEME unset VDM_HTTP_SCHEME
unset VDM_PUID
unset VDM_PGID
# container lower # container lower
unset vdm_database_name unset vdm_database_name
unset vdm_database_user unset vdm_database_user
@ -417,6 +439,13 @@ function joomla__TRuST__setup() {
# return the Joomla Container setup yml # return the Joomla Container setup yml
function joomlaContainer() { function joomlaContainer() {
# set the USER if set
vdm_container_user=''
if [ -n "${VDM_PUID}" ] && [ -n "${VDM_PGID}" ]; then
vdm_container_user="
- APACHE_RUN_USER=\${VDM_${VDM_ENV_KEY^^}_PUID}
- APACHE_RUN_GROUP=\${VDM_${VDM_ENV_KEY^^}_PGID}"
fi
# we build the yml file # we build the yml file
cat <<EOF cat <<EOF
version: '2' version: '2'
@ -435,10 +464,10 @@ services:
networks: networks:
- traefik - traefik
joomla_${VDM_KEY}: joomla_${VDM_KEY}:
image: joomla:${VDM_JV} image: ${VDM_J_REPO}:${VDM_JV}
container_name: joomla_${VDM_KEY} container_name: joomla_${VDM_KEY}
restart: unless-stopped restart: unless-stopped
environment: environment:${vdm_container_user}
- JOOMLA_DB_HOST=mariadb_${VDM_KEY}:3306 - JOOMLA_DB_HOST=mariadb_${VDM_KEY}:3306
- JOOMLA_DB_NAME=\${VDM_${VDM_ENV_KEY^^}_DB} - JOOMLA_DB_NAME=\${VDM_${VDM_ENV_KEY^^}_DB}
- JOOMLA_DB_USER=\${VDM_${VDM_ENV_KEY^^}_DB_USER} - JOOMLA_DB_USER=\${VDM_${VDM_ENV_KEY^^}_DB_USER}
@ -513,6 +542,8 @@ function openssh__TRuST__setup() {
showError "You must enter a username for the container" showError "You must enter a username for the container"
fi fi
done done
# be sure to set the container USER ID
setContainerUser 33
# get the key if not set # get the key if not set
setUniqueKey "Enter key used for container naming." setUniqueKey "Enter key used for container naming."
# get the env key if not set # get the env key if not set
@ -658,6 +689,8 @@ function openssh__TRuST__setup() {
# container # container
unset VDM_PORT unset VDM_PORT
unset VDM_USER_NAME unset VDM_USER_NAME
unset VDM_PUID
unset VDM_PGID
unset VDM_KEY unset VDM_KEY
unset VDM_ENV_KEY unset VDM_ENV_KEY
unset VDM_PUBLIC_KEY_GLOBAL_DIR unset VDM_PUBLIC_KEY_GLOBAL_DIR
@ -682,8 +715,8 @@ services:
restart: unless-stopped restart: unless-stopped
hostname: ${VDM_DOMAIN:-vdm.dev} hostname: ${VDM_DOMAIN:-vdm.dev}
environment: environment:
- PUID=${VDM_PUID:-33} - PUID=${VDM_PUID}
- PGID=${VDM_PGID:-33} - PGID=${VDM_PGID}
- TZ=${VDM_TZ:-Africa/Windhoek} - TZ=${VDM_TZ:-Africa/Windhoek}
- PUBLIC_KEY_DIR=/config/ssh_public_keys - PUBLIC_KEY_DIR=/config/ssh_public_keys
- SUDO_ACCESS=${VDM_SUDO_ACCESS:-false} - SUDO_ACCESS=${VDM_SUDO_ACCESS:-false}
@ -2332,6 +2365,48 @@ function getTargetBranch() {
echo "${answer:-master}" echo "${answer:-master}"
} }
# get the target repository to use in update
function getImageSource() {
# we set some local stuff
local image
local image_source
local images_source
# menu for dynamic addition
local menu_options=()
# our counter
local i=2
# set the base images source
menu_options+=("joomla" "Joomla official image" "OFF")
menu_options+=("llewellyn/joomla" "Octoleo Joomla image" "OFF")
# get existing source
if [ -f "${VDM_SRC_PATH}/.images-source" ] && readarray -t images_source <"${VDM_SRC_PATH}/.images-source"; then
# build the menus
if [ "${#images_source[@]}" -gt 0 ]; then
# loop source images
for image in "${images_source[@]}"; do
# the image name (get before first comma)
image_name="${image%%,*}"
# the image description (get after last comma)
image_desc="${image##*,}"
# make sure we have a value, and it is not the defaults already set
if [ "${#image_name}" -ge 1 ] && [ "${#image_desc}" -ge 1 ] &&
[ "${image_name}" != 'joomla' ] && [ "${image_name}" != 'llewellyn/joomla' ]; then
# load the source name and description
menu_options+=("${image_name}" "${image_desc}" "OFF")
# increment our counter
i=$((i + 1))
fi
done
fi
fi
# now make the selection
image_source=$(whiptail --title "Select image source repository" --radiolist --nocancel --notags \
"You can select the source of your Joomla! image." 10 80 $i \
"${menu_options[@]}" 3>&1 1>&2 2>&3)
# return the answer (default joomla)
echo "${image_source:-joomla}"
}
# get a list of domains locally set # get a list of domains locally set
function getListDomains() { function getListDomains() {
# get the separator # get the separator
@ -2440,6 +2515,19 @@ function getMainDomain() {
fi fi
} }
# set the container user
function setContainerUser() {
# we first get the container user ID
VDM_PUID=$(getInput "Enter user ID for the ${VDM_CONTAINER_TYPE^} container.\n[add only a number]" \
"${1:-1000}" 'Enter Container User ID')
# we get the container user-group ID
VDM_PGID=$(getInput "Enter user-group ID for the ${VDM_CONTAINER_TYPE^} container.\n[add only a number]" \
"${1:-1000}" 'Enter Container User Group ID')
# make available
export VDM_PUID
export VDM_PGID
}
# set the domain # set the domain
function setDomain() { function setDomain() {
# allow multi domain setup # allow multi domain setup
@ -2704,8 +2792,8 @@ function saveMultiDomain() {
local domain_name local domain_name
local src_path_domain local src_path_domain
# set the domain and remove any whitespace # set the domain and remove any whitespace
domain_name="$(echo -e "${1}" | tr -d '[:space:]')"; domain_name="$(echo -e "${1}" | tr -d '[:space:]')"
src_path_domain="${VDM_SRC_PATH}/.domains"; src_path_domain="${VDM_SRC_PATH}/.domains"
# check that we have a domain string # check that we have a domain string
if [ ${#domain_name} -ge 1 ]; then if [ ${#domain_name} -ge 1 ]; then
# check if the file exist # check if the file exist