4 Commits

2 changed files with 196 additions and 150 deletions

View File

@ -1,4 +1,4 @@
# Easy Docker Deployment (UBUNTU ONLY) # Octojoom - Easy Docker Deployment
With this script we can easily deploy docker containers of Joomla and Openssh. This combination of these tools give rise to a powerful and very secure shared development environment. With this script we can easily deploy docker containers of Joomla and Openssh. This combination of these tools give rise to a powerful and very secure shared development environment.
This program has **command input** options as seen in the menus below, but these command are _not the only way_ to set these values. This program has **command input** options as seen in the menus below, but these command are _not the only way_ to set these values.
@ -8,40 +8,34 @@ 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
$ sudo curl -L "https://git.vdm.dev/api/v1/repos/octoleo/docker-deploy/raw/src/docker-deploy?access_token=xxxx" -o /usr/local/bin/docker-deploy $ sudo curl -L "https://git.vdm.dev/api/v1/repos/octoleo/octojoom/raw/src/octojoom" -o /usr/local/bin/octojoom
$ sudo chmod +x /usr/local/bin/docker-deploy $ sudo chmod +x /usr/local/bin/octojoom
``` ```
### How to get the Access Token
Sign in to [https://git.vdm.dev/](https://git.vdm.dev/user/login) with your **GitHub** or **Gitlab** account.
Then open your [applications settings](https://git.vdm.dev/user/settings/applications) and create a new access token.
![image](https://user-images.githubusercontent.com/5607939/143513412-946843be-acd8-4973-be44-00902226f6ba.png)
The first time you use the program, it will ask for the access token again, so it can do updates in the future.
--- ---
# Usage # Usage
> To see the usage help menu > To see the usage help menu
```shell ```shell
$ docker-deploy -h $ octojoom -h
``` ```
### Help Menu (docker-deploy) ### Help Menu (octojoom)
```txt ```txt
Usage: docker-deploy [OPTION...] Usage: octojoom [OPTION...]
Options Options
====================================================== ======================================================
--type <type> --type <type>
set type you would like to work with set type you would like to work with
example: docker-deploy --type joomla example: octojoom --type joomla
====================================================== ======================================================
--task <task> --task <task>
set type of task you would like to perform set type of task you would like to perform
example: docker-deploy --task setup example: octojoom --task setup
====================================================== ======================================================
--container <container.domain.name> --container <container.domain.name>
Directly enabling or disabling a container with Directly enabling or disabling a container with
@ -49,74 +43,74 @@ Usage: docker-deploy [OPTION...]
The container must exist, which means it was The container must exist, which means it was
setup previously setup previously
Used without type and task Joomla-Enable is (default) Used without type and task Joomla-Enable is (default)
example: docker-deploy --container "io.vdm.dev" example: octojoom --container "io.vdm.dev"
====================================================== ======================================================
--update --update
to update your install to update your install
example: docker-deploy --update example: octojoom --update
====================================================== ======================================================
--access-token <token> --access-token <token>
to update the program you will need an access token to update the program you will need an access token
from https://git.vdm.dev/user/settings/applications from https://git.vdm.dev/user/settings/applications
example: docker-deploy --access-token xxxxxxxxxxx example: octojoom --access-token xxxxxxxxxxx
====================================================== ======================================================
--uninstall --uninstall
to uninstall this script to uninstall this script
example: docker-deploy --uninstall example: octojoom --uninstall
====================================================== ======================================================
AVAILABLE FOR TO ANY CONTAINER AVAILABLE FOR TO ANY CONTAINER
====================================================== ======================================================
-k|--key <key> -k|--key <key>
set key for the docker compose container naming set key for the docker compose container naming
!! no spaces allowed in the key !! !! no spaces allowed in the key !!
example: docker-deploy -k="vdm" example: octojoom -k="vdm"
example: docker-deploy --key="vdm" example: octojoom --key="vdm"
====================================================== ======================================================
-e|--env-key <key> -e|--env-key <key>
set key for the environment variable naming set key for the environment variable naming
!! no spaces allowed in the key & must be UPPERCASE !! !! no spaces allowed in the key & must be UPPERCASE !!
example: docker-deploy -e="VDM" example: octojoom -e="VDM"
example: docker-deploy --env-key="VDM" example: octojoom --env-key="VDM"
====================================================== ======================================================
-d|--domain <domain.com> -d|--domain <domain.com>
set key website domain set key website domain
!! must be domain.tld !! !! must be domain.tld !!
example: docker-deploy -d="joomla.org" example: octojoom -d="joomla.org"
example: docker-deploy --domain="joomla.org" example: octojoom --domain="joomla.org"
====================================================== ======================================================
-s|--sub-domain <domain.com> -s|--sub-domain <domain.com>
set key website sub domain set key website sub domain
!! no spaces allowed in the sub domain !! !! no spaces allowed in the sub domain !!
example: docker-deploy -s="jcb" example: octojoom -s="jcb"
example: docker-deploy --sub-domain="jcb" example: octojoom --sub-domain="jcb"
====================================================== ======================================================
AVAILABLE FOR JOOMLA CONTAINER AVAILABLE FOR JOOMLA CONTAINER
====================================================== ======================================================
-j|--joomla-version <version-tag> -j|--joomla-version <version-tag>
see available tags here https://hub.docker.com/_/joomla see available tags here https://hub.docker.com/_/joomla
example: docker-deploy -j=3.10 example: octojoom -j=3.10
example: docker-deploy --joomla-version=3.10 example: octojoom --joomla-version=3.10
====================================================== ======================================================
AVAILABLE FOR OPENSSH CONTAINER AVAILABLE FOR OPENSSH CONTAINER
====================================================== ======================================================
-u|--username <username> -u|--username <username>
set username of the container set username of the container
example: docker-deploy -u="ubuntu" example: octojoom -u="ubuntu"
example: docker-deploy --username="ubuntu" example: octojoom --username="ubuntu"
====================================================== ======================================================
--uid <id> --uid <id>
set container user id set container user id
example: docker-deploy --uid=1000 example: octojoom --uid=1000
====================================================== ======================================================
--gid <id> --gid <id>
set container user group id set container user group id
example: docker-deploy --gid=1000 example: octojoom --gid=1000
====================================================== ======================================================
-p|--port <port> -p|--port <port>
set ssh port to use set ssh port to use
!! do not use 22 !! !! do not use 22 !!
example: docker-deploy -p=2239 example: octojoom -p=2239
example: docker-deploy --port=2239 example: octojoom --port=2239
====================================================== ======================================================
--ssh-dir <dir> --ssh-dir <dir>
set ssh directory name found in the .ssh dir set ssh directory name found in the .ssh dir
@ -124,34 +118,34 @@ Usage: docker-deploy [OPTION...]
This directory has separate files for This directory has separate files for
each public key allowed to access each public key allowed to access
the container the container
example: docker-deploy --ssh-dir="teamname" example: octojoom --ssh-dir="teamname"
====================================================== ======================================================
--sudo --sudo
switch to add the container user to the switch to add the container user to the
sudo group of the container sudo group of the container
example: docker-deploy --sudo example: octojoom --sudo
====================================================== ======================================================
-t|--time-zone <time/zone> -t|--time-zone <time/zone>
set time zone of the container set time zone of the container
!! must valid time zone !! !! must valid time zone !!
example: docker-deploy -t="Africa/Windhoek" example: octojoom -t="Africa/Windhoek"
example: docker-deploy --time-zone="Africa/Windhoek" example: octojoom --time-zone="Africa/Windhoek"
====================================================== ======================================================
HELP ʕ•ᴥ•ʔ HELP ʕ•ᴥ•ʔ
====================================================== ======================================================
-h|--help -h|--help
display this help menu display this help menu
example: docker-deploy -h example: octojoom -h
example: docker-deploy --help example: octojoom --help
====================================================== ======================================================
Docker Deployment v2.1.0 Octojoom
====================================================== ======================================================
``` ```
--- ---
# Uninstall # Uninstall
```shell ```shell
$ docker-deploy --uninstall $ octojoom --uninstall
``` ```
--- ---
# Free Software License # Free Software License

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
# The most recent program version. # The most recent program version.
_VERSION="2.1.1" _VERSION="3.0.1"
_V="2.1" _V="3.0"
# The program full name # The program full name
PROGRAM_NAME="Docker Deployment" PROGRAM_NAME="Octojoom"
# make sure whiptail is installed # make sure whiptail is installed
command -v whiptail >/dev/null 2>&1 || { command -v whiptail >/dev/null 2>&1 || {
@ -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}
@ -828,7 +861,7 @@ function joomla__TRuST__enable() {
elif [ ! -d "${VDM_PROJECT_PATH}" ]; then elif [ ! -d "${VDM_PROJECT_PATH}" ]; then
# this should never happen, but in case # this should never happen, but in case
showError "The path ${VDM_PROJECT_PATH} does not exist, so we can't mount the persistent volumes. This error should never show, \ showError "The path ${VDM_PROJECT_PATH} does not exist, so we can't mount the persistent volumes. This error should never show, \
please open an issue and report docker-deploy-error-1234 with the steps of how you got here?" please open an issue and report octojoom-error-1234 with the steps of how you got here?"
elif [ ${#VDM_CONTAINER} -ge 1 ]; then elif [ ${#VDM_CONTAINER} -ge 1 ]; then
# this means we have a single already selected container to enable if it exists # this means we have a single already selected container to enable if it exists
if [ -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_CONTAINER}" ]; then if [ -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_CONTAINER}" ]; then
@ -1516,39 +1549,37 @@ function deletePersistentVolumes() {
function runUpdate() { function runUpdate() {
# we need sudo permissions # we need sudo permissions
if (whiptail --yesno "${USER^}, to update ${PROGRAM_NAME} we need sudo privileges." --title "Give sudo Privileges" 8 112); then if (whiptail --yesno "${USER^}, to update ${PROGRAM_NAME} we need sudo privileges." --title "Give sudo Privileges" 8 112); then
# check that we have an access token
getAccessToken || return 1
# remove the current version # remove the current version
if [ -f /usr/local/bin/docker-deploy ]; then if [ -f /usr/local/bin/octojoom ]; then
# just backup in case of failure # just backup in case of failure
sudo mv /usr/local/bin/docker-deploy /usr/local/bin/docker-deploy.bak sudo mv /usr/local/bin/octojoom /usr/local/bin/octojoom.bak
fi fi
# some local values # some local values
local branch local branch
# get the target branch to use in our update # get the target branch to use in our update
branch=$(getTargetBranch) branch=$(getTargetBranch)
# pull the latest version. Master is always the latest # pull the latest version. Master is always the latest
if sudo curl --fail -L "https://git.vdm.dev/api/v1/repos/octoleo/docker-deploy/raw/src/docker-deploy?ref=${branch:-master}&access_token=${VDM_ACCESS_TOKEN}" -o /usr/local/bin/docker-deploy 2>/dev/null; then if sudo curl --fail -L "https://git.vdm.dev/api/v1/repos/octoleo/octojoom/raw/src/octojoom?ref=${branch:-master}" -o /usr/local/bin/octojoom 2>/dev/null; then
# give success message # give success message
echo "SUCCESS: Update was successful." echo "SUCCESS: Update was successful."
# do we have a backup # do we have a backup
if [ -f /usr/local/bin/docker-deploy.bak ]; then if [ -f /usr/local/bin/octojoom.bak ]; then
# lets remove it now # lets remove it now
sudo rm -f /usr/local/bin/docker-deploy.bak sudo rm -f /usr/local/bin/octojoom.bak
fi fi
else else
# show the error # show the error
echo >&2 "ERROR: Update failed! Please try again later." echo >&2 "ERROR: Update failed! Please try again later."
# do we have a backup # do we have a backup
if [ -f /usr/local/bin/docker-deploy.bak ]; then if [ -f /usr/local/bin/octojoom.bak ]; then
# move backup back # move backup back
sudo mv /usr/local/bin/docker-deploy.bak /usr/local/bin/docker-deploy sudo mv /usr/local/bin/octojoom.bak /usr/local/bin/octojoom
fi fi
fi fi
# always set the permission again if we have a file # always set the permission again if we have a file
if [ -f /usr/local/bin/docker-deploy ]; then if [ -f /usr/local/bin/octojoom ]; then
# the we make sure its executable # the we make sure its executable
sudo chmod +x /usr/local/bin/docker-deploy sudo chmod +x /usr/local/bin/octojoom
fi fi
# always exit so the new script can load # always exit so the new script can load
exit 0 exit 0
@ -1601,9 +1632,9 @@ function runUninstall() {
sudo rm -fr "${VDM_REPO_PATH}" sudo rm -fr "${VDM_REPO_PATH}"
fi fi
elif (whiptail --yesno "Would you like to only remove the actual ${PROGRAM_NAME} v${_V} script but keep all the Docker stuff?" --title "Keep Docker Stuff" 8 112); then elif (whiptail --yesno "Would you like to only remove the actual ${PROGRAM_NAME} v${_V} script but keep all the Docker stuff?" --title "Keep Docker Stuff" 8 112); then
# now remove the docker-deploy script # now remove the octojoom script
if [ -f /usr/local/bin/docker-deploy ]; then if [ -f /usr/local/bin/octojoom ]; then
sudo rm -f /usr/local/bin/docker-deploy sudo rm -f /usr/local/bin/octojoom
fi fi
# give the final message # give the final message
whiptail --title "${PROGRAM_NAME} v${_VERSION} is UNINSTALLED" --msgbox "\n\ whiptail --title "${PROGRAM_NAME} v${_VERSION} is UNINSTALLED" --msgbox "\n\
@ -1687,9 +1718,9 @@ function runUninstall() {
sudo rm -fr "${VDM_SRC_PATH}" sudo rm -fr "${VDM_SRC_PATH}"
fi fi
fi fi
# now remove the docker-deploy script # now remove the octojoom script
if [ -f /usr/local/bin/docker-deploy ]; then if [ -f /usr/local/bin/octojoom ]; then
sudo rm -f /usr/local/bin/docker-deploy sudo rm -f /usr/local/bin/octojoom
fi fi
# last and final question as this is most dangerous and serious issue. # last and final question as this is most dangerous and serious issue.
if [ -d "${VDM_PROJECT_PATH}" ] && if [ -d "${VDM_PROJECT_PATH}" ] &&
@ -1705,10 +1736,10 @@ function runUninstall() {
} }
# we show the octoleo info quietly # we show the octoleo info quietly
octoleoQuietly() { octojoomQuietly() {
local message local message
# now set the message # now set the message
message=" https://git.vdm.dev/octoleo/docker-deploy message=" https://git.vdm.dev/octoleo/octojoom
Welcome to an Octoleo Program (${PROGRAM_NAME} v$_VERSION) Welcome to an Octoleo Program (${PROGRAM_NAME} v$_VERSION)
@ -1897,7 +1928,7 @@ function showTraefik() {
menu_options+=("delete" "Delete Traefik") && i=$((i + 1)) menu_options+=("delete" "Delete Traefik") && i=$((i + 1))
# get the selection # get the selection
CHOICE=$( CHOICE=$(
whiptail --menu "Make your selection" 16 112 $i \ whiptail --menu "Make your selection" 20 112 $i \
--title "Traefik | ${PROGRAM_NAME} v${_V}" --fb \ --title "Traefik | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" --nocancel --notags \ --backtitle " Octoleo" --nocancel --notags \
"${menu_options[@]}" 3>&2 2>&1 1>&3 "${menu_options[@]}" 3>&2 2>&1 1>&3
@ -1946,7 +1977,7 @@ function showPortainer() {
menu_options+=("delete" "Delete Portainer") && i=$((i + 1)) menu_options+=("delete" "Delete Portainer") && i=$((i + 1))
# get the selection # get the selection
CHOICE=$( CHOICE=$(
whiptail --menu "Make your selection" 16 112 $i \ whiptail --menu "Make your selection" 20 112 $i \
--title "Portainer | ${PROGRAM_NAME} v${_V}" --fb \ --title "Portainer | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" --nocancel --notags \ --backtitle " Octoleo" --nocancel --notags \
"${menu_options[@]}" 3>&2 2>&1 1>&3 "${menu_options[@]}" 3>&2 2>&1 1>&3
@ -1993,10 +2024,10 @@ function showHelpMenu() {
# Uninstall the whole script # Uninstall the whole script
menu_options+=("uninstall" "Uninstall ${PROGRAM_NAME,,}") menu_options+=("uninstall" "Uninstall ${PROGRAM_NAME,,}")
# Octoleo details # Octoleo details
menu_options+=("octoleo" "Octoleo") menu_options+=("octojoom" "Octojoom")
# get the selection # get the selection
CHOICE=$( CHOICE=$(
whiptail --menu "Make your selection" 16 112 $i \ whiptail --menu "Make your selection" 20 112 $i \
--title "Help Menu | ${PROGRAM_NAME} v${_V}" --fb \ --title "Help Menu | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" --nocancel --notags \ --backtitle " Octoleo" --nocancel --notags \
"${menu_options[@]}" 3>&2 2>&1 1>&3 "${menu_options[@]}" 3>&2 2>&1 1>&3
@ -2013,7 +2044,7 @@ function showHelpMenu() {
editConfigFile editConfigFile
;; ;;
"report-issue") "report-issue")
showLink "https://git.vdm.dev/octoleo/docker-deploy/issues" "To report an issue go to:" "Report an Issue" showLink "https://git.vdm.dev/octoleo/octojoom/issues" "To report an issue go to:" "Report an Issue"
;; ;;
"update") "update")
runUpdate runUpdate
@ -2021,8 +2052,8 @@ function showHelpMenu() {
"uninstall") "uninstall")
runUninstall runUninstall
;; ;;
"octoleo") "octojoom")
octoleoQuietly octojoomQuietly
;; ;;
esac esac
} }
@ -2046,7 +2077,7 @@ function domainsMenu() {
menu_options+=("edit" "Edit Host File") && i=$((i + 1)) menu_options+=("edit" "Edit Host File") && i=$((i + 1))
# get the selection # get the selection
CHOICE=$( CHOICE=$(
whiptail --menu "Make your selection" 16 112 $i \ whiptail --menu "Make your selection" 20 112 $i \
--title "Domains Menu | ${PROGRAM_NAME} v${_V}" --fb \ --title "Domains Menu | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" --nocancel --notags \ --backtitle " Octoleo" --nocancel --notags \
"${menu_options[@]}" 3>&2 2>&1 1>&3 "${menu_options[@]}" 3>&2 2>&1 1>&3
@ -2164,7 +2195,7 @@ function showImportantPaths() {
CONFIG: ${VDM_SRC_PATH} CONFIG: ${VDM_SRC_PATH}
Then we have some key environment variable files that hold very useful and important information. Then we have some key environment variable files that hold very useful and important information.
Since we do not store any passwords or other important details in the docker-deploy.yml files Since we do not store any passwords or other important details in the octojoom.yml files
they are stored in these environment variable files and its permissions are (600) for security. they are stored in these environment variable files and its permissions are (600) for security.
JOOMLA: ${VDM_REPO_PATH}/joomla/.env JOOMLA: ${VDM_REPO_PATH}/joomla/.env
@ -2322,38 +2353,6 @@ function getPassword() {
echo "${PASSWORD}" echo "${PASSWORD}"
} }
# get and set the access token
function getAccessToken() {
# we try getting the token twice
local t=0
local new_token=false
# check that we have an access token, els ask for it
while [ ${#VDM_ACCESS_TOKEN} -le 30 ]; do
# this is a new token
new_token=true
# get the value
VDM_ACCESS_TOKEN=$(getInput "Enter access token for updates.\n[You can get an access token from https://git.vdm.dev/user/settings/applications]" \
'' 'Access Token')
# keep asking if empty
if [ ${#VDM_ACCESS_TOKEN} -le 30 ]; then
showError "Updates can only be done if you have an access token."
# increment our try
t=$((t + 1))
# when the user for the second time does not supply the correct value we return
if [ $t -eq 2 ]; then
return 12
fi
fi
done
# make the token available
export VDM_ACCESS_TOKEN
# store the token for next time
$new_token && setEnvVariable "VDM_ACCESS_TOKEN=\"${VDM_ACCESS_TOKEN}\"" &&
showNotice "The token has been stored in the environment variable file (${VDM_SRC_PATH}/.env)."
# we have success
return 0
}
# get the target branch to use in update # get the target branch to use in update
function getTargetBranch() { function getTargetBranch() {
# now make the selection # now make the selection
@ -2366,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
@ -2474,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
@ -2738,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
@ -2856,16 +2910,16 @@ function editConfigFile() {
# help message # help message
function showHelp() { function showHelp() {
cat <<EOF cat <<EOF
Usage: ${0##*/:-} [OPTION...] Usage: octojoom [OPTION...]
Options Options
====================================================== ======================================================
--type <type> --type <type>
set type you would like to work with set type you would like to work with
example: ${0##*/:-} --type joomla example: octojoom --type joomla
====================================================== ======================================================
--task <task> --task <task>
set type of task you would like to perform set type of task you would like to perform
example: ${0##*/:-} --task setup example: octojoom --task setup
====================================================== ======================================================
--container <container.domain.name> --container <container.domain.name>
Directly enabling or disabling a container with Directly enabling or disabling a container with
@ -2873,74 +2927,74 @@ Usage: ${0##*/:-} [OPTION...]
The container must exist, which means it was The container must exist, which means it was
setup previously setup previously
Used without type and task Joomla-Enable is (default) Used without type and task Joomla-Enable is (default)
example: ${0##*/:-} --container "io.vdm.dev" example: octojoom --container "io.vdm.dev"
====================================================== ======================================================
--update --update
to update your install to update your install
example: ${0##*/:-} --update example: octojoom --update
====================================================== ======================================================
--access-token <token> --access-token <token>
to update the program you will need an access token to update the program you will need an access token
from https://git.vdm.dev/user/settings/applications from https://git.vdm.dev/user/settings/applications
example: docker-deploy --access-token xxxxxxxxxxx example: octojoom --access-token xxxxxxxxxxx
====================================================== ======================================================
--uninstall --uninstall
to uninstall this script to uninstall this script
example: ${0##*/:-} --uninstall example: octojoom --uninstall
====================================================== ======================================================
AVAILABLE FOR TO ANY CONTAINER AVAILABLE FOR TO ANY CONTAINER
====================================================== ======================================================
-k|--key <key> -k|--key <key>
set key for the docker compose container naming set key for the docker compose container naming
!! no spaces allowed in the key !! !! no spaces allowed in the key !!
example: ${0##*/:-} -k="vdm" example: octojoom -k="vdm"
example: ${0##*/:-} --key="vdm" example: octojoom --key="vdm"
====================================================== ======================================================
-e|--env-key <key> -e|--env-key <key>
set key for the environment variable naming set key for the environment variable naming
!! no spaces allowed in the key & must be UPPERCASE !! !! no spaces allowed in the key & must be UPPERCASE !!
example: ${0##*/:-} -e="VDM" example: octojoom -e="VDM"
example: ${0##*/:-} --env-key="VDM" example: octojoom --env-key="VDM"
====================================================== ======================================================
-d|--domain <domain.com> -d|--domain <domain.com>
set key website domain set key website domain
!! must be domain.tld !! !! must be domain.tld !!
example: ${0##*/:-} -d="joomla.org" example: octojoom -d="joomla.org"
example: ${0##*/:-} --domain="joomla.org" example: octojoom --domain="joomla.org"
====================================================== ======================================================
-s|--sub-domain <domain.com> -s|--sub-domain <domain.com>
set key website sub domain set key website sub domain
!! no spaces allowed in the sub domain !! !! no spaces allowed in the sub domain !!
example: ${0##*/:-} -s="jcb" example: octojoom -s="jcb"
example: ${0##*/:-} --sub-domain="jcb" example: octojoom --sub-domain="jcb"
====================================================== ======================================================
AVAILABLE FOR JOOMLA CONTAINER AVAILABLE FOR JOOMLA CONTAINER
====================================================== ======================================================
-j|--joomla-version <version-tag> -j|--joomla-version <version-tag>
see available tags here https://hub.docker.com/_/joomla see available tags here https://hub.docker.com/_/joomla
example: ${0##*/:-} -j=3.10 example: octojoom -j=3.10
example: ${0##*/:-} --joomla-version=3.10 example: octojoom --joomla-version=3.10
====================================================== ======================================================
AVAILABLE FOR OPENSSH CONTAINER AVAILABLE FOR OPENSSH CONTAINER
====================================================== ======================================================
-u|--username <username> -u|--username <username>
set username of the container set username of the container
example: ${0##*/:-} -u="ubuntu" example: octojoom -u="ubuntu"
example: ${0##*/:-} --username="ubuntu" example: octojoom --username="ubuntu"
====================================================== ======================================================
--uid <id> --uid <id>
set container user id set container user id
example: ${0##*/:-} --uid=1000 example: octojoom --uid=1000
====================================================== ======================================================
--gid <id> --gid <id>
set container user group id set container user group id
example: ${0##*/:-} --gid=1000 example: octojoom --gid=1000
====================================================== ======================================================
-p|--port <port> -p|--port <port>
set ssh port to use set ssh port to use
!! do not use 22 !! !! do not use 22 !!
example: ${0##*/:-} -p=2239 example: octojoom -p=2239
example: ${0##*/:-} --port=2239 example: octojoom --port=2239
====================================================== ======================================================
--ssh-dir <dir> --ssh-dir <dir>
set ssh directory name found in the .ssh dir set ssh directory name found in the .ssh dir
@ -2948,25 +3002,25 @@ Usage: ${0##*/:-} [OPTION...]
This directory has separate files for This directory has separate files for
each public key allowed to access each public key allowed to access
the container the container
example: ${0##*/:-} --ssh-dir="teamname" example: octojoom --ssh-dir="teamname"
====================================================== ======================================================
--sudo --sudo
switch to add the container user to the switch to add the container user to the
sudo group of the container sudo group of the container
example: ${0##*/:-} --sudo example: octojoom --sudo
====================================================== ======================================================
-t|--time-zone <time/zone> -t|--time-zone <time/zone>
set time zone of the container set time zone of the container
!! must valid time zone !! !! must valid time zone !!
example: ${0##*/:-} -t="Africa/Windhoek" example: octojoom -t="Africa/Windhoek"
example: ${0##*/:-} --time-zone="Africa/Windhoek" example: octojoom --time-zone="Africa/Windhoek"
====================================================== ======================================================
HELP ʕ•ᴥ•ʔ HELP ʕ•ᴥ•ʔ
====================================================== ======================================================
-h|--help -h|--help
display this help menu display this help menu
example: ${0##*/:-} -h example: octojoom -h
example: ${0##*/:-} --help example: octojoom --help
====================================================== ======================================================
${PROGRAM_NAME} v${_VERSION} ${PROGRAM_NAME} v${_VERSION}
====================================================== ======================================================
@ -3287,7 +3341,7 @@ fi
#####################################################################################################################VDM #####################################################################################################################VDM
######################################## SETUP KEY PATHS ######################################## SETUP KEY PATHS
# the src folder path is where we store the script global env # the src folder path is where we store the script global env
VDM_SRC_PATH="/home/${USER}/.config/docker-deploy" VDM_SRC_PATH="/home/${USER}/.config/octojoom"
# create the folder if not set # create the folder if not set
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m '700' "${VDM_SRC_PATH}" mkdir -p -m '700' "${VDM_SRC_PATH}"
@ -3296,8 +3350,6 @@ mkdir -p -m '700' "${VDM_SRC_PATH}"
[ -f "${VDM_SRC_PATH}/.env" ] && source "${VDM_SRC_PATH}/.env" [ -f "${VDM_SRC_PATH}/.env" ] && source "${VDM_SRC_PATH}/.env"
# get repo path where store the container deploy scripts # get repo path where store the container deploy scripts
while [ ${#VDM_REPO_PATH} -le 1 ] || [ ! -d "${VDM_REPO_PATH}" ]; do while [ ${#VDM_REPO_PATH} -le 1 ] || [ ! -d "${VDM_REPO_PATH}" ]; do
# we catch the token now.. so we don't need asking for it later
getAccessToken
# creat the path if it exist # creat the path if it exist
if [ ${#VDM_REPO_PATH} -ge 1 ] && (whiptail --yesno "Can we create the ${VDM_REPO_PATH} repository folder" --title "Create the Path" 8 112); then if [ ${#VDM_REPO_PATH} -ge 1 ] && (whiptail --yesno "Can we create the ${VDM_REPO_PATH} repository folder" --title "Create the Path" 8 112); then
mkdir -p "${VDM_REPO_PATH}" mkdir -p "${VDM_REPO_PATH}"