Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
ead3ac2d3c
|
|||
13975467a1
|
|||
ef55a19c75
|
|||
b5693c9b91
|
|||
f50f87a454
|
|||
8ee988a534
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The most recent program version.
|
||||
_VERSION="2.0.0"
|
||||
_VERSION="2.0.4"
|
||||
_V="2.0"
|
||||
|
||||
# The program full name
|
||||
@ -72,7 +72,7 @@ function traefik__TRuST__setup() {
|
||||
while [ ${#VDM_DOMAIN} -le 1 ]; do
|
||||
# get the value
|
||||
VDM_DOMAIN=$(getInput "Enter main domain of all your containers.\n[only one main domain allowed for now, must have at least one dot]" \
|
||||
"vdm.dev" 'Enter Main Domain')
|
||||
"${USER}.vdm" 'Enter Main Domain')
|
||||
# keep asking if empty or does exist
|
||||
[ ${#VDM_DOMAIN} -ge 1 ] || {
|
||||
showError "You must enter a domain name!"
|
||||
@ -128,19 +128,19 @@ services:
|
||||
container_name: traefik
|
||||
image: "traefik:latest"
|
||||
command:
|
||||
- --entrypoints.web.address=:80
|
||||
- --entrypoints.websecure.address=:443
|
||||
${VDM_REMOVE_SECURE} - --entrypoints.web.address=:80
|
||||
${VDM_REMOVE_SECURE} - --entrypoints.websecure.address=:443
|
||||
# - --api.dashboard=true
|
||||
# - --api.insecure=true
|
||||
- --providers.docker
|
||||
- --log.level=INFO
|
||||
${VDM_REMOVE_SECURE} - --log.level=INFO
|
||||
${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallenge=true
|
||||
${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.keytype=RSA4096
|
||||
${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.email=${VDM_SECURE_EMAIL:-user@demo.com}
|
||||
${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.storage=/acme.json
|
||||
${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallenge.entrypoint=web
|
||||
# - --providers.file.directory=/conf
|
||||
# - --providers.file.watch=true
|
||||
${VDM_REMOVE_SECURE} - --providers.file.directory=/conf
|
||||
${VDM_REMOVE_SECURE} - --providers.file.watch=true
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
@ -148,15 +148,15 @@ ${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallen
|
||||
# - "8080:8080"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
# - "\${VDM_PROJECT_PATH}/traefik/conf:/conf"
|
||||
${VDM_REMOVE_SECURE} - "\${VDM_PROJECT_PATH}/traefik/conf:/conf"
|
||||
${VDM_REMOVE_SECURE} - "\${VDM_PROJECT_PATH}/traefik/acme.json:/acme.json"
|
||||
- "\${VDM_PROJECT_PATH}/traefik/errors:/errors"
|
||||
labels:
|
||||
${VDM_REMOVE_SECURE} - "\${VDM_PROJECT_PATH}/traefik/errors:/errors"
|
||||
${VDM_REMOVE_SECURE} labels:
|
||||
# settings for all containers
|
||||
- "traefik.http.routers.http-catchall.rule=hostregexp(\`{host:.+}\`)"
|
||||
- "traefik.http.routers.http-catchall.entrypoints=web"
|
||||
- "traefik.http.routers.http-catchall.middlewares=redirect-to-me"
|
||||
- "traefik.http.middlewares.redirect-to-me.redirectscheme.scheme=${VDM_HTTP_SCHEME}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.http-catchall.rule=hostregexp(\`{host:.+}\`)"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.http-catchall.entrypoints=web"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.http-catchall.middlewares=redirect-to-me"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.middlewares.redirect-to-me.redirectscheme.scheme=${VDM_HTTP_SCHEME}"
|
||||
networks:
|
||||
- traefik
|
||||
|
||||
@ -195,7 +195,7 @@ function portainer__TRuST__setup() {
|
||||
while [ ${#VDM_DOMAIN} -le 1 ]; do
|
||||
# get the value
|
||||
VDM_DOMAIN=$(getInput "Enter main domain of all your containers.\n[only one main domain allowed for now, must have at least one dot]" \
|
||||
"vdm.dev" 'Enter Main Domain')
|
||||
"${USER}.vdm" 'Enter Main Domain')
|
||||
# keep asking if empty or does exist
|
||||
[ ${#VDM_DOMAIN} -ge 1 ] || {
|
||||
showError "You must enter a domain name!"
|
||||
@ -260,7 +260,7 @@ services:
|
||||
# Frontend
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.portainer.rule=Host(\`port.${VDM_DOMAIN}\`)"
|
||||
- "traefik.http.routers.portainer.entrypoints=${VDM_ENTRY_POINT}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.portainer.entrypoints=${VDM_ENTRY_POINT}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.portainer.tls.certresolver=vdmresolver"
|
||||
- "traefik.http.routers.portainer.service=portainer"
|
||||
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
|
||||
@ -290,6 +290,15 @@ function joomla__TRuST__setup() {
|
||||
# load this container type globals
|
||||
# shellcheck disable=SC1090
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && source "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
|
||||
# we need to pull these values from the env if set
|
||||
local vdm_key_db
|
||||
local vdm_env_db
|
||||
local vdm_key_user
|
||||
local vdm_env_user
|
||||
local vdm_key_pass
|
||||
local vdm_env_pass
|
||||
local vdm_key_root
|
||||
local vdm_env_root
|
||||
# get the Joomla version if not set
|
||||
while [ ${#VDM_JV} -le 1 ]; do
|
||||
# get the value
|
||||
@ -325,7 +334,7 @@ function joomla__TRuST__setup() {
|
||||
while [ ${#VDM_DOMAIN} -le 1 ]; do
|
||||
# get the value
|
||||
VDM_DOMAIN=$(getInput "Enter main domain of all your containers.\n[only one main domain allowed for now, must have at least one dot]" \
|
||||
"vdm.dev" 'Enter Main Domain')
|
||||
"${USER}.vdm" 'Enter Main Domain')
|
||||
# keep asking if empty or does exist
|
||||
[ ${#VDM_DOMAIN} -ge 1 ] || {
|
||||
showError "You must enter a domain name!"
|
||||
@ -357,10 +366,26 @@ function joomla__TRuST__setup() {
|
||||
if $VDM_SECURE; then
|
||||
VDM_REMOVE_SECURE=''
|
||||
VDM_ENTRY_POINT="websecure"
|
||||
VDM_HTTP_SCHEME="https://"
|
||||
else
|
||||
VDM_REMOVE_SECURE="#"
|
||||
VDM_ENTRY_POINT="web"
|
||||
VDM_HTTP_SCHEME="http://"
|
||||
fi
|
||||
# set the details
|
||||
vdm_key_db="VDM_${VDM_ENV_KEY^^}_DB"
|
||||
vdm_env_db="${!vdm_key_db}"
|
||||
vdm_key_user="VDM_${VDM_ENV_KEY^^}_DB_USER"
|
||||
vdm_env_user="${!vdm_key_user}"
|
||||
vdm_key_pass="VDM_${VDM_ENV_KEY^^}_DB_PASS"
|
||||
vdm_env_pass="${!vdm_key_pass}"
|
||||
vdm_key_root="VDM_${VDM_ENV_KEY^^}_DB_ROOT"
|
||||
vdm_env_root="${!vdm_key_root}"
|
||||
# now we check if its has been set
|
||||
vdm_database_name="${vdm_database_name:-$vdm_env_db}"
|
||||
vdm_database_user="${vdm_database_user:-$vdm_env_user}"
|
||||
vdm_database_pass="${vdm_database_pass:-$vdm_env_pass}"
|
||||
vdm_database_rootpass="${vdm_database_rootpass:-$vdm_env_root}"
|
||||
# check if env is already set
|
||||
# shellcheck disable=SC2015
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && grep -q "VDM_${VDM_ENV_KEY}_DB=" "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" || {
|
||||
@ -412,13 +437,13 @@ function joomla__TRuST__setup() {
|
||||
# add this value if not set variable
|
||||
setEnvVariable "VDM_SECURE=${VDM_SECURE}"
|
||||
# add this value if not set variable
|
||||
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
|
||||
setContainerEnvVariable "VDM_${VDM_ENV_KEY}_DB_USER=\"${vdm_database_user}\""
|
||||
[ ${#vdm_database_user} -ge 1 ] && setContainerEnvVariable "VDM_${VDM_ENV_KEY}_DB_USER=\"${vdm_database_user}\""
|
||||
# add this value if not set variable
|
||||
setContainerEnvVariable "VDM_${VDM_ENV_KEY}_DB_PASS=\"${vdm_database_pass}\""
|
||||
[ ${#vdm_database_pass} -ge 1 ] && setContainerEnvVariable "VDM_${VDM_ENV_KEY}_DB_PASS=\"${vdm_database_pass}\""
|
||||
# add this value if not set variable
|
||||
setContainerEnvVariable "VDM_${VDM_ENV_KEY}_DB_ROOT=\"${vdm_database_rootpass}\""
|
||||
[ ${#vdm_database_rootpass} -ge 1 ] && setContainerEnvVariable "VDM_${VDM_ENV_KEY}_DB_ROOT=\"${vdm_database_rootpass}\""
|
||||
# add the projects path
|
||||
setContainerEnvVariable "VDM_PROJECT_PATH=\"${VDM_PROJECT_PATH}\""
|
||||
##########################
|
||||
@ -437,6 +462,7 @@ function joomla__TRuST__setup() {
|
||||
export VDM_ENV_KEY
|
||||
export VDM_REMOVE_SECURE
|
||||
export VDM_ENTRY_POINT
|
||||
export VDM_HTTP_SCHEME
|
||||
# container lower
|
||||
export vdm_database_name
|
||||
export vdm_database_user
|
||||
@ -444,6 +470,8 @@ function joomla__TRuST__setup() {
|
||||
export vdm_database_rootpass
|
||||
# set host file if needed
|
||||
updateHostFile
|
||||
# also set the database domain
|
||||
updateHostFile "${VDM_SUBDOMAIN}db"
|
||||
# create the directory if it does not yet already exist
|
||||
# shellcheck disable=SC2174
|
||||
mkdir -p -m 700 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_SUBDOMAIN}.${VDM_DOMAIN}"
|
||||
@ -460,6 +488,8 @@ function joomla__TRuST__setup() {
|
||||
# then we enable it
|
||||
enableContainer "${VDM_CONTAINER_TYPE}"
|
||||
fi
|
||||
# display the configurations
|
||||
showJoomlaConfigDetails
|
||||
##########################
|
||||
### unset all no longer needed
|
||||
# container
|
||||
@ -469,6 +499,7 @@ function joomla__TRuST__setup() {
|
||||
unset VDM_ENV_KEY
|
||||
unset VDM_REMOVE_SECURE
|
||||
unset VDM_ENTRY_POINT
|
||||
unset VDM_HTTP_SCHEME
|
||||
# container lower
|
||||
unset vdm_database_name
|
||||
unset vdm_database_user
|
||||
@ -516,7 +547,7 @@ services:
|
||||
# joomla
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.joomla_${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}.${VDM_DOMAIN}\`)"
|
||||
- "traefik.http.routers.joomla_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.joomla_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.joomla_${VDM_KEY}.tls.certresolver=vdmresolver"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.joomla_${VDM_KEY}.service=joomla_${VDM_KEY}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.services.joomla_${VDM_KEY}.loadbalancer.server.port=80"
|
||||
@ -536,10 +567,10 @@ ${VDM_REMOVE_SECURE} - "traefik.http.services.joomla_${VDM_KEY}.loadbalance
|
||||
# phpmyadmin
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.phpmyadmin_${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}db.${VDM_DOMAIN}\`)"
|
||||
- "traefik.http.routers.phpmyadmin_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.phpmyadmin_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.phpmyadmin_${VDM_KEY}.tls.certresolver=vdmresolver"
|
||||
- "traefik.http.routers.phpmyadmin_${VDM_KEY}.service=phpmyadmin_${VDM_KEY}"
|
||||
- "traefik.http.services.phpmyadmin_${VDM_KEY}.loadbalancer.server.port=80"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.routers.phpmyadmin_${VDM_KEY}.service=phpmyadmin_${VDM_KEY}"
|
||||
${VDM_REMOVE_SECURE} - "traefik.http.services.phpmyadmin_${VDM_KEY}.loadbalancer.server.port=80"
|
||||
|
||||
networks:
|
||||
traefik:
|
||||
@ -567,7 +598,7 @@ function openssh__TRuST__setup() {
|
||||
while [ ${#VDM_DOMAIN} -le 1 ]; do
|
||||
# get the value
|
||||
VDM_DOMAIN=$(getInput "Enter main domain of all your containers.\n[only one main domain allowed for now, must have at least one dot]" \
|
||||
"vdm.dev" 'Enter Main Domain')
|
||||
"${USER}.vdm" 'Enter Main Domain')
|
||||
# keep asking if empty or does exist
|
||||
[ ${#VDM_DOMAIN} -ge 1 ] || {
|
||||
showError "You must enter a domain name!"
|
||||
@ -641,35 +672,40 @@ function openssh__TRuST__setup() {
|
||||
VDM_PUBLIC_KEY_U_DIR=$(getSelectedDirectory "Select the containers ssh public keys folder." \
|
||||
"${VDM_PUBLIC_KEY_GLOBAL_DIR}" "${VDM_KEY,,}" 'Select Folder')
|
||||
# keep asking if empty or does exist
|
||||
if [ ${#VDM_PUBLIC_KEY_U_DIR} -ge 1 ] && [ ! -d "${VDM_PUBLIC_KEY_U_DIR}" ] &&
|
||||
if [ ${#VDM_PUBLIC_KEY_U_DIR} -ge 1 ]; then
|
||||
# add the parent dir back
|
||||
VDM_PUBLIC_KEY_U_DIR="${VDM_PUBLIC_KEY_GLOBAL_DIR}/${VDM_PUBLIC_KEY_U_DIR}"
|
||||
# check if this directory exist
|
||||
if [ ! -d "${VDM_PUBLIC_KEY_U_DIR}" ] &&
|
||||
(whiptail --yesno "Can we create this (${VDM_PUBLIC_KEY_U_DIR}) containers ssh public keys folder" --title "Create the Path" 8 112); then
|
||||
# shellcheck disable=SC2174
|
||||
mkdir -p -m 700 "${VDM_PUBLIC_KEY_U_DIR}"
|
||||
# TODO add option to add keys?
|
||||
elif [ ${#VDM_PUBLIC_KEY_U_DIR} -le 1 ]; then
|
||||
fi
|
||||
else
|
||||
showError "You must set a containers ssh public keys folder."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
# we must get the project path
|
||||
VDM_ENV_PROJECT_PATH="VDM_${VDM_ENV_KEY^^}_PROJECT_PATH"
|
||||
VDM_PROJECT_U_PATH=${!VDM_ENV_PROJECT_PATH}
|
||||
VDM_ENV_PROJECT_DIR="VDM_${VDM_ENV_KEY^^}_PROJECT_DIR"
|
||||
VDM_PROJECT_U_DIR=${!VDM_ENV_PROJECT_DIR}
|
||||
# get the directory of the ssh public keys if not set
|
||||
while [ ${#VDM_PROJECT_U_PATH} -le 1 ] || [ ! -d "${VDM_PROJECT_U_PATH}" ]; do
|
||||
while [ ${#VDM_PROJECT_U_DIR} -le 1 ] || [ ! -d "${VDM_PROJECT_U_DIR}" ]; do
|
||||
# creat the path if it exist
|
||||
if [ ${#VDM_PROJECT_U_PATH} -ge 1 ] &&
|
||||
(whiptail --yesno "Can we create the ${VDM_PROJECT_U_PATH} parent mounting directory" --title "Create the Path" 8 112); then
|
||||
mkdir -p "${VDM_PROJECT_U_PATH}"
|
||||
if [ ${#VDM_PROJECT_U_DIR} -ge 1 ] &&
|
||||
(whiptail --yesno "Can we create the ${VDM_PROJECT_U_DIR} parent mounting directory" --title "Create the Path" 8 112); then
|
||||
mkdir -p "${VDM_PROJECT_U_DIR}"
|
||||
else
|
||||
# get the value
|
||||
VDM_PROJECT_U_PATH=$(getInput "Enter the parent path where we can select the folders to mount to this container." \
|
||||
VDM_PROJECT_U_DIR=$(getInput "Enter the parent path where we can select the folders to mount to this container." \
|
||||
"${VDM_PROJECT_PATH}" 'Enter Path')
|
||||
# keep asking if empty or does exist
|
||||
if [ ${#VDM_PROJECT_U_PATH} -ge 1 ] && [ ! -d "${VDM_PROJECT_U_PATH}" ] &&
|
||||
(whiptail --yesno "Can we create the ${VDM_PROJECT_U_PATH} parent mounting directory" --title "Create the Path" 8 112); then
|
||||
if [ ${#VDM_PROJECT_U_DIR} -ge 1 ] && [ ! -d "${VDM_PROJECT_U_DIR}" ] &&
|
||||
(whiptail --yesno "Can we create the ${VDM_PROJECT_U_DIR} parent mounting directory" --title "Create the Path" 8 112); then
|
||||
# shellcheck disable=SC2174
|
||||
mkdir -p -m 700 "${VDM_PROJECT_U_PATH}"
|
||||
elif [ ${#VDM_PROJECT_U_PATH} -le 1 ]; then
|
||||
mkdir -p -m 700 "${VDM_PROJECT_U_DIR}"
|
||||
elif [ ${#VDM_PROJECT_U_DIR} -le 1 ]; then
|
||||
showError "You must set a parent mounting directory path where we can select the folders to mount to this container."
|
||||
fi
|
||||
fi
|
||||
@ -678,7 +714,7 @@ function openssh__TRuST__setup() {
|
||||
while [ ${#VDM_MOUNT_DIRS} -le 1 ]; do
|
||||
# get the value
|
||||
VDM_MOUNT_DIRS=$(getSelectedDirectories "Select the directories to mount to this container." \
|
||||
"${VDM_PROJECT_U_PATH}" 'Select Folders')
|
||||
"${VDM_PROJECT_U_DIR}" 'Select Folders')
|
||||
# keep asking if empty or does exist
|
||||
if [ ${#VDM_MOUNT_DIRS} -le 1 ]; then
|
||||
showError "You must set the directories to mount to this container."
|
||||
@ -693,7 +729,7 @@ function openssh__TRuST__setup() {
|
||||
# set the full path
|
||||
mDir="${mDir//\"/}"
|
||||
# when we mount a joomla volume we may not want to mount the database
|
||||
mFull="${VDM_PROJECT_U_PATH}/${mDir}/joomla"
|
||||
mFull="${VDM_PROJECT_U_DIR}/${mDir}/joomla"
|
||||
# add to mount projects
|
||||
if [ -d "${mFull}" ] && (whiptail --yesno "Should we ONLY mount the (joomla website files) ${mDir}/joomla directory" --title "Mount Joomla" 8 112); then
|
||||
VDM_MOUNT_PROJECTS+=$(getYMLDashLine "\${VDM_${VDM_ENV_KEY^^}_PROJECT_DIR}/${mDir}/joomla:/app/${mDir}")
|
||||
@ -704,7 +740,7 @@ function openssh__TRuST__setup() {
|
||||
# add this value if not set variable
|
||||
setEnvVariable "VDM_DOMAIN=\"${VDM_DOMAIN}\""
|
||||
# add this value if not set variable
|
||||
setContainerEnvVariable "${VDM_ENV_PROJECT_PATH}=\"${VDM_PROJECT_U_PATH}\""
|
||||
setContainerEnvVariable "${VDM_ENV_PROJECT_DIR}=\"${VDM_PROJECT_U_DIR}\""
|
||||
# add this value if not set variable
|
||||
setContainerEnvVariable "VDM_PUBLIC_KEY_GLOBAL_DIR=\"${VDM_PUBLIC_KEY_GLOBAL_DIR}\""
|
||||
# add this value if not set variable
|
||||
@ -723,7 +759,7 @@ function openssh__TRuST__setup() {
|
||||
export VDM_ENV_KEY
|
||||
export VDM_PUBLIC_KEY_GLOBAL_DIR
|
||||
export VDM_PUBLIC_KEY_U_DIR
|
||||
export VDM_PROJECT_U_PATH
|
||||
export VDM_PROJECT_U_DIR
|
||||
# create the directory if it does not yet already exist
|
||||
# shellcheck disable=SC2174
|
||||
mkdir -p -m 700 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_USER_NAME}.${VDM_DOMAIN}"
|
||||
@ -749,7 +785,7 @@ function openssh__TRuST__setup() {
|
||||
unset VDM_ENV_KEY
|
||||
unset VDM_PUBLIC_KEY_GLOBAL_DIR
|
||||
unset VDM_PUBLIC_KEY_U_DIR
|
||||
unset VDM_PROJECT_U_PATH
|
||||
unset VDM_PROJECT_U_DIR
|
||||
# return a success
|
||||
return 0
|
||||
}
|
||||
@ -985,10 +1021,7 @@ function portainer__TRuST__enable() {
|
||||
######################################## DISABLE JOOMLA
|
||||
function joomla__TRuST__disable() {
|
||||
# check if this type has enabled containers
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" ] ||
|
||||
[ $(ls -A "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" | wc -l) = 0 ]; then
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} containers to disable."
|
||||
elif [ ${#VDM_CONTAINER} -ge 1 ]; then
|
||||
# this means we have a single already selected container to enable if it exists
|
||||
@ -1031,10 +1064,7 @@ function joomla__TRuST__disable() {
|
||||
######################################## DISABLE OPENSSH
|
||||
function openssh__TRuST__disable() {
|
||||
# check if this type has enabled containers
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" ] ||
|
||||
[ $(ls -A "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" | wc -l) = 0 ]; then
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} containers to disable."
|
||||
elif [ ${#VDM_CONTAINER} -ge 1 ]; then
|
||||
# this means we have a single already selected container to enable if it exists
|
||||
@ -1101,10 +1131,7 @@ function portainer__TRuST__disable() {
|
||||
########################################UP JOOMLA
|
||||
function joomla__TRuST__up() {
|
||||
# check if this type has enabled containers
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" ] ||
|
||||
[ $(ls -A "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" | wc -l) = 0 ]; then
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} containers enabled, first enable some containers.\n\
|
||||
(UP and DOWN targets only enabled containers)"
|
||||
else
|
||||
@ -1135,10 +1162,7 @@ function joomla__TRuST__up() {
|
||||
######################################## UP OPENSSH
|
||||
function openssh__TRuST__up() {
|
||||
# check if this type has enabled containers
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" ] ||
|
||||
[ $(ls -A "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" | wc -l) = 0 ]; then
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} containers enabled, first enable some containers.\n\
|
||||
(UP and DOWN targets only enabled containers)"
|
||||
else
|
||||
@ -1169,10 +1193,7 @@ function openssh__TRuST__up() {
|
||||
########################################DOWN JOOMLA
|
||||
function joomla__TRuST__down() {
|
||||
# check if this type has enabled containers
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" ] ||
|
||||
[ $(ls -A "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" | wc -l) = 0 ]; then
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} containers to take down.\n\
|
||||
(UP and DOWN targets only enabled containers)"
|
||||
else
|
||||
@ -1187,10 +1208,7 @@ function joomla__TRuST__down() {
|
||||
######################################## DOWN OPENSSH
|
||||
function openssh__TRuST__down() {
|
||||
# check if this type has enabled containers
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" ] ||
|
||||
[ $(ls -A "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" | wc -l) = 0 ]; then
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} containers to take down."
|
||||
else
|
||||
# get all zip files
|
||||
@ -1204,11 +1222,8 @@ function openssh__TRuST__down() {
|
||||
######################################## DELETE JOOMLA
|
||||
function joomla__TRuST__delete() {
|
||||
# check if this type has enabled containers
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/" ] ||
|
||||
[ $(ls -A "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/" | wc -l) = 0 ]; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} available containers."
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/available/"; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} containers available."
|
||||
else
|
||||
# set some local variables
|
||||
local vdm_delete_me
|
||||
@ -1241,7 +1256,7 @@ function joomla__TRuST__delete() {
|
||||
done
|
||||
fi
|
||||
# ask if there are volumes to delete
|
||||
if [ -d "${VDM_PROJECT_PATH}" ] && [ $(ls -A "${VDM_PROJECT_PATH}" | wc -l) -ne 0 ] &&
|
||||
if hasDirectories '' "${VDM_PROJECT_PATH}" &&
|
||||
(whiptail --yesno "Would you like to delete persistent volumes found in (${VDM_PROJECT_PATH})?" --title "Continue To Delete Persistent Volumes" 12 112); then
|
||||
# trigger the volumes removal script
|
||||
deletePersistentVolumes
|
||||
@ -1253,11 +1268,8 @@ function joomla__TRuST__delete() {
|
||||
######################################## DELETE OPENSSH
|
||||
function openssh__TRuST__delete() {
|
||||
# check if this type has enabled containers
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/" ] ||
|
||||
[ $(ls -A "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/" | wc -l) = 0 ]; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} available containers."
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/available/"; then
|
||||
showError "There are no ${VDM_CONTAINER_TYPE} containers available."
|
||||
else
|
||||
# set some local variables
|
||||
local vdm_delete_me
|
||||
@ -1354,11 +1366,9 @@ function deleteContainer() {
|
||||
# To fix the permissions of Joomla containers
|
||||
function fixContainerPermissions() {
|
||||
# check if we have persistent volumes
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ ! -d "${VDM_PROJECT_PATH}" ]; then
|
||||
showError "The ${VDM_PROJECT_PATH} does not exist."
|
||||
elif [ $(ls -A "${VDM_PROJECT_PATH}" | wc -l) = 0 ]; then
|
||||
elif ! hasDirectories '' "${VDM_PROJECT_PATH}"; then
|
||||
showError "There are no persistent volumes in ${VDM_PROJECT_PATH} available."
|
||||
else
|
||||
# set some local variables
|
||||
@ -1398,11 +1408,17 @@ function fixContainerPermissions() {
|
||||
# Change the image folder permissions
|
||||
# chmod 707 "${VDM_PROJECT_PATH}/${persistent}/joomla/images"
|
||||
# chmod 707 "${VDM_PROJECT_PATH}/${persistent}/joomla/images/stories"
|
||||
#
|
||||
# Check if the setfacl command is installed
|
||||
# shellcheck disable=SC2015
|
||||
if command -v setfacl >/dev/null 2>&1; then
|
||||
### Fix the folder permissions so the active user (1000) can access the files
|
||||
#
|
||||
echo "Fixing the folder permissions of ${persistent} joomla so user:$USER can access them"
|
||||
#
|
||||
sudo setfacl -R -m u:"$USER":rwx "${VDM_PROJECT_PATH}/${persistent}/joomla"
|
||||
else
|
||||
echo "[ERROR] Could not fix the permissions of the ${persistent} joomla so user:$USER can access them."
|
||||
echo "[ERROR] You will need to install: setfacl for this option to work, then run this fix again."
|
||||
fi
|
||||
### Fix the folder ownership of database folders
|
||||
#
|
||||
echo "Fixing the folder ownership of ${persistent} database folders"
|
||||
@ -1428,9 +1444,7 @@ function fixContainerPermissions() {
|
||||
# delete persistent volumes
|
||||
function deletePersistentVolumes() {
|
||||
# we first check if we have some volumes
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ -d "${VDM_PROJECT_PATH}" ] && [ $(ls -A "${VDM_PROJECT_PATH}" | wc -l) -ne 0 ]; then
|
||||
if hasDirectories '' "${VDM_PROJECT_PATH}"; then
|
||||
# set some local variables
|
||||
local vdm_delete_volumes
|
||||
local persistent
|
||||
@ -1469,8 +1483,12 @@ function runUpdate() {
|
||||
# just backup in case of failure
|
||||
sudo mv /usr/local/bin/docker-deploy /usr/local/bin/docker-deploy.bak
|
||||
fi
|
||||
# some local values
|
||||
local branch
|
||||
# get the target branch to use in our update
|
||||
branch=$(getTargetBranch)
|
||||
# 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=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/docker-deploy/raw/src/docker-deploy?ref=${branch:-master}&access_token=${VDM_ACCESS_TOKEN}" -o /usr/local/bin/docker-deploy 2>/dev/null; then
|
||||
# give success message
|
||||
echo "SUCCESS: Update was successful."
|
||||
# do we have a backup
|
||||
@ -1646,7 +1664,7 @@ function runUninstall() {
|
||||
}
|
||||
|
||||
# we show the octoleo info quietly
|
||||
octoleoQuietly(){
|
||||
octoleoQuietly() {
|
||||
local message
|
||||
# now set the message
|
||||
message=" https://git.vdm.dev/octoleo/docker-deploy
|
||||
@ -1673,13 +1691,13 @@ octoleoQuietly(){
|
||||
|
||||
--quiet"
|
||||
|
||||
whiptail --msgbox --scrolltext "${message}" 30 112
|
||||
whiptail --msgbox "${message}" --fb --backtitle " Octoleo" 32 112
|
||||
}
|
||||
|
||||
# show the help menu
|
||||
function showHelpMenu() {
|
||||
# show the commands help menu
|
||||
function showCommandsHelpMenu() {
|
||||
help=$(showHelp)
|
||||
whiptail --msgbox --scrolltext "${help}" 30 112
|
||||
whiptail --msgbox --scrolltext "${help}" --fb --backtitle " Octoleo" 30 90
|
||||
}
|
||||
|
||||
#####################################################################################################################VDM
|
||||
@ -1687,38 +1705,61 @@ function showHelpMenu() {
|
||||
|
||||
# show Joomla menu
|
||||
function showJoomla() {
|
||||
# menu for dynamic addition
|
||||
local menu_options=()
|
||||
# our counter
|
||||
local i=2
|
||||
# load the back menu
|
||||
menu_options+=("back" "<-- Return to the main menu.")
|
||||
# setup new container
|
||||
menu_options+=("setup" "Setup new container")
|
||||
# enable existing container
|
||||
hasDirectories 'joomla/available' &&
|
||||
menu_options+=("enable" "Enable existing container") && i=$((i + 1))
|
||||
# disable enabled container
|
||||
hasDirectories 'joomla/enabled' &&
|
||||
menu_options+=("disable" "Disable enabled container") && i=$((i + 1))
|
||||
# delete a container
|
||||
hasDirectories 'joomla/available' &&
|
||||
menu_options+=("delete" "Delete a container") && i=$((i + 1))
|
||||
# take all enabled containers down
|
||||
hasDirectories 'joomla/enabled' &&
|
||||
menu_options+=("down" "Take all enabled containers down") && i=$((i + 1))
|
||||
# pull up all enabled containers
|
||||
hasDirectories 'joomla/enabled' &&
|
||||
menu_options+=("up" "Pull up all enabled containers") && i=$((i + 1))
|
||||
# fix permissions
|
||||
hasDirectories '' "${VDM_PROJECT_PATH}" &&
|
||||
menu_options+=("fix" "Fix permissions of folders and files of a container") &&
|
||||
i=$((i + 1))
|
||||
# get the selection
|
||||
CHOICE=$(
|
||||
whiptail --title "Joomla | ${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 7 \
|
||||
"1)" "<-- Return to the main menu." \
|
||||
"2)" "Setup new container" \
|
||||
"3)" "Enable existing container" \
|
||||
"4)" "Disable enabled container" \
|
||||
"5)" "Delete a container" \
|
||||
"6)" "Take all enabled containers down" \
|
||||
"7)" "Pull up all enabled containers" \
|
||||
"8)" "Fix permissions of folders and files of a container" 3>&2 2>&1 1>&3
|
||||
whiptail --menu "Make your selection" 20 112 $i \
|
||||
--title "Joomla | ${PROGRAM_NAME} v${_V}" --fb \
|
||||
--backtitle " Octoleo" --nocancel --notags \
|
||||
"${menu_options[@]}" 3>&2 2>&1 1>&3
|
||||
)
|
||||
|
||||
case $CHOICE in
|
||||
"2)")
|
||||
"setup")
|
||||
setupContainer 'joomla'
|
||||
;;
|
||||
"3)")
|
||||
"enable")
|
||||
enableContainer 'joomla'
|
||||
;;
|
||||
"4)")
|
||||
"disable")
|
||||
disableContainer 'joomla'
|
||||
;;
|
||||
"5)")
|
||||
"delete")
|
||||
deleteContainer 'joomla'
|
||||
;;
|
||||
"6)")
|
||||
"down")
|
||||
downContainers 'joomla'
|
||||
;;
|
||||
"7)")
|
||||
"up")
|
||||
upContainers 'joomla'
|
||||
;;
|
||||
"8)")
|
||||
"fix")
|
||||
fixContainerPermissions
|
||||
;;
|
||||
esac
|
||||
@ -1726,34 +1767,54 @@ function showJoomla() {
|
||||
|
||||
# show Openssh menu
|
||||
function showOpenssh() {
|
||||
# menu for dynamic addition
|
||||
local menu_options=()
|
||||
# our counter
|
||||
local i=2
|
||||
# load the back menu
|
||||
menu_options+=("back" "<-- Return to the main menu.")
|
||||
# setup new container
|
||||
menu_options+=("setup" "Setup new container")
|
||||
# enable existing container
|
||||
hasDirectories 'openssh/available' &&
|
||||
menu_options+=("enable" "Enable existing container") && i=$((i + 1))
|
||||
# disable enabled container
|
||||
hasDirectories 'openssh/enabled' &&
|
||||
menu_options+=("disable" "Disable enabled container") && i=$((i + 1))
|
||||
# delete a container
|
||||
hasDirectories 'openssh/available' &&
|
||||
menu_options+=("delete" "Delete a container") && i=$((i + 1))
|
||||
# take all enabled containers down
|
||||
hasDirectories 'openssh/enabled' &&
|
||||
menu_options+=("down" "Take all enabled containers down") && i=$((i + 1))
|
||||
# pull up all enabled containers
|
||||
hasDirectories 'openssh/enabled' &&
|
||||
menu_options+=("up" "Pull up all enabled containers") && i=$((i + 1))
|
||||
# get the selection
|
||||
CHOICE=$(
|
||||
whiptail --title "Openssh | ${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 6 \
|
||||
"1)" "<-- Return to the main menu." \
|
||||
"2)" "Setup new container" \
|
||||
"3)" "Enable existing container" \
|
||||
"4)" "Disable enabled container" \
|
||||
"5)" "Delete a container" \
|
||||
"6)" "Take all enabled containers down" \
|
||||
"7)" "Pull up all enabled containers" 3>&2 2>&1 1>&3
|
||||
whiptail --menu "Make your selection" 20 112 $i \
|
||||
--title "Openssh | ${PROGRAM_NAME} v${_V}" --fb \
|
||||
--backtitle " Octoleo" --nocancel --notags \
|
||||
"${menu_options[@]}" 3>&2 2>&1 1>&3
|
||||
)
|
||||
|
||||
case $CHOICE in
|
||||
"2)")
|
||||
"setup")
|
||||
setupContainer 'openssh'
|
||||
;;
|
||||
"3)")
|
||||
"enable")
|
||||
enableContainer 'openssh'
|
||||
;;
|
||||
"4)")
|
||||
"disable")
|
||||
disableContainer 'openssh'
|
||||
;;
|
||||
"5)")
|
||||
"delete")
|
||||
deleteContainer 'openssh'
|
||||
;;
|
||||
"6)")
|
||||
"down")
|
||||
downContainers 'openssh'
|
||||
;;
|
||||
"7)")
|
||||
"up")
|
||||
upContainers 'openssh'
|
||||
;;
|
||||
esac
|
||||
@ -1761,22 +1822,36 @@ function showOpenssh() {
|
||||
|
||||
# show Traefik menu
|
||||
function showTraefik() {
|
||||
# menu for dynamic addition
|
||||
local menu_options=()
|
||||
# our counter
|
||||
local i=2
|
||||
# load the back menu
|
||||
menu_options+=("back" "<-- Return to the main menu.")
|
||||
# setup new container
|
||||
menu_options+=("setup" "Setup/Rebuild Traefik")
|
||||
# enable existing container
|
||||
[ -f "${VDM_REPO_PATH}/traefik/docker-compose.yml" ] &&
|
||||
menu_options+=("enable" "Enable Traefik") && i=$((i + 1))
|
||||
# disable enabled container
|
||||
[ -f "${VDM_REPO_PATH}/traefik/docker-compose.yml" ] &&
|
||||
menu_options+=("disable" "Disable Traefik") && i=$((i + 1))
|
||||
# get the selection
|
||||
CHOICE=$(
|
||||
whiptail --title "Traefik | ${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 4 \
|
||||
"1)" "<-- Return to the main menu." \
|
||||
"2)" "Setup Traefik" \
|
||||
"3)" "Enable Traefik" \
|
||||
"4)" "Disable Traefik" 3>&2 2>&1 1>&3
|
||||
whiptail --menu "Make your selection" 16 112 $i \
|
||||
--title "Traefik | ${PROGRAM_NAME} v${_V}" --fb \
|
||||
--backtitle " Octoleo" --nocancel --notags \
|
||||
"${menu_options[@]}" 3>&2 2>&1 1>&3
|
||||
)
|
||||
|
||||
case $CHOICE in
|
||||
"2)")
|
||||
"setup")
|
||||
setupContainer 'traefik'
|
||||
;;
|
||||
"3)")
|
||||
"enable")
|
||||
enableContainer 'traefik'
|
||||
;;
|
||||
"4)")
|
||||
"disable")
|
||||
disableContainer 'traefik'
|
||||
;;
|
||||
esac
|
||||
@ -1784,73 +1859,141 @@ function showTraefik() {
|
||||
|
||||
# show Portainer menu
|
||||
function showPortainer() {
|
||||
# menu for dynamic addition
|
||||
local menu_options=()
|
||||
# our counter
|
||||
local i=2
|
||||
# load the back menu
|
||||
menu_options+=("back" "<-- Return to the main menu.")
|
||||
# setup new container
|
||||
menu_options+=("setup" "Setup/Rebuild Portainer")
|
||||
# enable existing container
|
||||
[ -f "${VDM_REPO_PATH}/portainer/docker-compose.yml" ] &&
|
||||
menu_options+=("enable" "Enable Portainer") && i=$((i + 1))
|
||||
# disable enabled container
|
||||
[ -f "${VDM_REPO_PATH}/portainer/docker-compose.yml" ] &&
|
||||
menu_options+=("disable" "Disable Portainer") && i=$((i + 1))
|
||||
# get the selection
|
||||
CHOICE=$(
|
||||
whiptail --title "Portainer | ${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 4 \
|
||||
"1)" "<-- Return to the main menu." \
|
||||
"2)" "Setup Portainer" \
|
||||
"3)" "Enable Portainer" \
|
||||
"4)" "Disable Portainer" 3>&2 2>&1 1>&3
|
||||
whiptail --menu "Make your selection" 16 112 $i \
|
||||
--title "Portainer | ${PROGRAM_NAME} v${_V}" --fb \
|
||||
--backtitle " Octoleo" --nocancel --notags \
|
||||
"${menu_options[@]}" 3>&2 2>&1 1>&3
|
||||
)
|
||||
|
||||
case $CHOICE in
|
||||
"2)")
|
||||
"setup")
|
||||
setupContainer 'portainer'
|
||||
;;
|
||||
"3)")
|
||||
"enable")
|
||||
enableContainer 'portainer'
|
||||
;;
|
||||
"4)")
|
||||
"disable")
|
||||
disableContainer 'portainer'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# show systems help menu
|
||||
function showHelpMenu() {
|
||||
# menu for dynamic addition
|
||||
local menu_options=()
|
||||
# our counter
|
||||
local i=7
|
||||
# load the back menu
|
||||
menu_options+=("back" "<-- Return to the main menu.")
|
||||
# Show command help
|
||||
menu_options+=("command-help" "Help with commands")
|
||||
# Show folder paths
|
||||
menu_options+=("important-paths" "Important Paths")
|
||||
# Report an Issue
|
||||
menu_options+=("report-issue" "Report an Issue")
|
||||
# Update the whole script
|
||||
menu_options+=("update" "Update ${PROGRAM_NAME,,}")
|
||||
# Uninstall the whole script
|
||||
menu_options+=("uninstall" "Uninstall ${PROGRAM_NAME,,}")
|
||||
# Octoleo details
|
||||
menu_options+=("octoleo" "Octoleo")
|
||||
# get the selection
|
||||
CHOICE=$(
|
||||
whiptail --menu "Make your selection" 16 112 $i \
|
||||
--title "Portainer | ${PROGRAM_NAME} v${_V}" --fb \
|
||||
--backtitle " Octoleo" --nocancel --notags \
|
||||
"${menu_options[@]}" 3>&2 2>&1 1>&3
|
||||
)
|
||||
|
||||
case $CHOICE in
|
||||
"command-help")
|
||||
showCommandsHelpMenu
|
||||
;;
|
||||
"important-paths")
|
||||
showImportantPaths
|
||||
;;
|
||||
"report-issue")
|
||||
showLink "https://git.vdm.dev/octoleo/docker-deploy/issues" "To report an issue go to:" "Report an Issue"
|
||||
;;
|
||||
"update")
|
||||
runUpdate
|
||||
;;
|
||||
"uninstall")
|
||||
runUninstall
|
||||
;;
|
||||
"octoleo")
|
||||
octoleoQuietly
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# MAIN MENU
|
||||
function mainMenu() {
|
||||
# menu for dynamic addition
|
||||
local menu_options=()
|
||||
# our counter
|
||||
local i=9
|
||||
# Joomla containers
|
||||
menu_options+=("joomla" "Joomla Containers")
|
||||
# Openssh containers
|
||||
menu_options+=("openssh" "Openssh Containers")
|
||||
# Traefik container
|
||||
menu_options+=("traefik" "Traefik Container")
|
||||
# Portainer container
|
||||
menu_options+=("portainer" "Portainer Container")
|
||||
# Delete Persistent Volumes
|
||||
hasDirectories '' "${VDM_PROJECT_PATH}" &&
|
||||
menu_options+=("delete" "Delete Persistent Volumes") && i=$((i + 1))
|
||||
# Show help
|
||||
menu_options+=("help" "Main Help Menu")
|
||||
# Octoleo details
|
||||
menu_options+=("quit" "Quit Program")
|
||||
# get the selection
|
||||
while true; do
|
||||
CHOICE=$(
|
||||
whiptail --title "${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 10 \
|
||||
"1)" "Joomla containers" \
|
||||
"2)" "Openssh containers" \
|
||||
"3)" "Traefik container" \
|
||||
"4)" "Portainer container" \
|
||||
"5)" "Delete Persistent Volumes" \
|
||||
"6)" "Update ${PROGRAM_NAME,,}" \
|
||||
"7)" "Uninstall ${PROGRAM_NAME,,}" \
|
||||
"8)" "Show command help" \
|
||||
"9)" "Octoleo" \
|
||||
"10)" "Quit" 3>&2 2>&1 1>&3
|
||||
whiptail --menu "Make your selection" 20 112 $i \
|
||||
--title "${PROGRAM_NAME} v${_V}" --fb \
|
||||
--backtitle " Octoleo" --nocancel --notags \
|
||||
"${menu_options[@]}" 3>&2 2>&1 1>&3
|
||||
)
|
||||
|
||||
case $CHOICE in
|
||||
"1)")
|
||||
"joomla")
|
||||
showJoomla
|
||||
;;
|
||||
"2)")
|
||||
"openssh")
|
||||
showOpenssh
|
||||
;;
|
||||
"3)")
|
||||
"traefik")
|
||||
showTraefik
|
||||
;;
|
||||
"4)")
|
||||
"portainer")
|
||||
showPortainer
|
||||
;;
|
||||
"5)")
|
||||
"delete")
|
||||
deletePersistentVolumes
|
||||
;;
|
||||
"6)")
|
||||
runUpdate
|
||||
;;
|
||||
"7)")
|
||||
runUninstall
|
||||
;;
|
||||
"8)")
|
||||
"help")
|
||||
showHelpMenu
|
||||
;;
|
||||
"9)")
|
||||
octoleoQuietly
|
||||
;;
|
||||
"10)") exit ;;
|
||||
"quit") exit ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
@ -1873,6 +2016,70 @@ function showNotice() {
|
||||
whiptail --title "NOTICE | ${PROGRAM_NAME} v${_V}" --msgbox "${1}" 12 112
|
||||
}
|
||||
|
||||
# show link
|
||||
function showLink() {
|
||||
whiptail --title "${3:-Open Link} | ${PROGRAM_NAME} v${_V}" --msgbox "${2:-To open the link click here:} ${1}" 8 112
|
||||
}
|
||||
|
||||
# show important paths
|
||||
function showImportantPaths() {
|
||||
local message
|
||||
# now set the message
|
||||
message=" ${PROGRAM_NAME} v$_VERSION
|
||||
|
||||
We have a few important paths that you should know, and use to manually manage your setup.
|
||||
|
||||
DOCKER: ${VDM_REPO_PATH}
|
||||
SSH: ${VDM_REPO_PATH}/openssh/.ssh
|
||||
VOLUMES: ${VDM_PROJECT_PATH}
|
||||
CONFIG: ${VDM_SRC_PATH}
|
||||
|
||||
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.
|
||||
They are stored in these environment variable files and its permissions are (600) for security.
|
||||
|
||||
JOOMLA: ${VDM_REPO_PATH}/joomla/.env
|
||||
OPENSSH: ${VDM_REPO_PATH}/openssh/.env
|
||||
TRAEFIK: ${VDM_REPO_PATH}/traefik/.env
|
||||
PORTAINER: ${VDM_REPO_PATH}/portainer/.env
|
||||
|
||||
|
||||
Not all these files or folders may exist, they are created only when needed.
|
||||
"
|
||||
|
||||
whiptail --msgbox "${message}" --fb --backtitle " Octoleo" 32 112
|
||||
}
|
||||
|
||||
# show show the Joomla config details
|
||||
function showJoomlaConfigDetails() {
|
||||
# load the env back to show if set previously
|
||||
# shellcheck disable=SC1090
|
||||
# [ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && source "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
|
||||
# set some locals
|
||||
local message
|
||||
# now set the message
|
||||
message=" ${PROGRAM_NAME} v$_VERSION
|
||||
|
||||
Running the Joomla container for the first time you will need these details:
|
||||
--------------------------------------------------------------------
|
||||
URL: ${VDM_HTTP_SCHEME}${VDM_SUBDOMAIN}.${VDM_DOMAIN}
|
||||
DATABASE_HOST: mariadb_${VDM_KEY}:3306
|
||||
--------------------------------------------------------------------
|
||||
VDM_${VDM_ENV_KEY^^}_DB: ${vdm_database_name}
|
||||
VDM_${VDM_ENV_KEY^^}_DB_USER: ${vdm_database_user}
|
||||
VDM_${VDM_ENV_KEY^^}_DB_PASS: ${vdm_database_pass}
|
||||
VDM_${VDM_ENV_KEY^^}_DB_ROOT: ${vdm_database_rootpass}
|
||||
--------------------------------------------------------------------
|
||||
These details are securely stored in this environment variable file
|
||||
${VDM_REPO_PATH}/joomla/.env
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Do not remove these details from the file, as its used to deploy the container.
|
||||
"
|
||||
|
||||
whiptail --msgbox "${message}" --fb --backtitle " Octoleo" 30 112
|
||||
}
|
||||
|
||||
# we must get a random key
|
||||
function getRandomPass() {
|
||||
# simple basic random
|
||||
@ -1880,6 +2087,16 @@ function getRandomPass() {
|
||||
echo $(tr -dc 'A-HJ-NP-Za-km-z2-9' </dev/urandom | dd bs="${1:-128}" count=1 status=none)
|
||||
}
|
||||
|
||||
# check if a Directory exist and if it has sub-directories
|
||||
function hasDirectories() {
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ -d "${2:-$VDM_REPO_PATH}/${1:-}" ] && [ $(ls -A "${2:-$VDM_REPO_PATH}/${1:-}" | wc -l) -ne 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# get input from user
|
||||
function getInput() {
|
||||
# set local var
|
||||
@ -1903,9 +2120,7 @@ function getSelectedDirectory() {
|
||||
# our counter
|
||||
local i=0
|
||||
# now check if this dir has sub dirs
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ -d "${path}" ] && [ $(ls -A "$path" | wc -l) -ne 0 ]; then
|
||||
if hasDirectories '' "$path"; then
|
||||
# loop over the directory
|
||||
for dir_ in "${path%/}/"*; do
|
||||
# remove the full path
|
||||
@ -1935,9 +2150,7 @@ function getSelectedDirectories() {
|
||||
# our counter
|
||||
local i=0
|
||||
# now check if this dir has sub dirs
|
||||
# shellcheck disable=SC2046
|
||||
# shellcheck disable=SC2012
|
||||
if [ -d "${path}" ] && [ $(ls -A "$path" | wc -l) -ne 0 ]; then
|
||||
if hasDirectories '' "$path"; then
|
||||
# loop over the directory
|
||||
for dir_ in "${path%/}/"*; do
|
||||
# remove the full path
|
||||
@ -1980,7 +2193,7 @@ function getPassword() {
|
||||
}
|
||||
|
||||
# get and set the access token
|
||||
function getAccessToken(){
|
||||
function getAccessToken() {
|
||||
# we try getting the token twice
|
||||
local t=0
|
||||
local new_token=false
|
||||
@ -2011,6 +2224,18 @@ function getAccessToken(){
|
||||
return 0
|
||||
}
|
||||
|
||||
# get the target branch to use in update
|
||||
function getTargetBranch() {
|
||||
# now make the selection
|
||||
answer=$(whiptail --title "Select Update Channel" --radiolist --nocancel --notags \
|
||||
"You can select the update channel you would like to use." 10 80 2 \
|
||||
"master" "Stable Version" "ON" \
|
||||
"staging" "Developer Version" "OFF" \
|
||||
3>&1 1>&2 2>&3)
|
||||
# return the answer (default master)
|
||||
echo "${answer:-master}"
|
||||
}
|
||||
|
||||
# set the networks in place
|
||||
function setNetworks() {
|
||||
# we create the networks
|
||||
@ -2075,7 +2300,7 @@ function isFunc() {
|
||||
}
|
||||
|
||||
# update the host file
|
||||
function updateHostFile(){
|
||||
function updateHostFile() {
|
||||
# check if we have secure switch set
|
||||
if [ "${VDM_UPDATE_HOST:-not}" = 'not' ]; then
|
||||
# check the security switch
|
||||
@ -2095,7 +2320,7 @@ function updateHostFile(){
|
||||
showNotice "${USER^}, ${1:-$VDM_SUBDOMAIN}.${2:-$VDM_DOMAIN} is already in the /etc/hosts file."
|
||||
elif (whiptail --yesno "${USER^}, to add the ${1:-$VDM_SUBDOMAIN}.${2:-$VDM_DOMAIN} entry to your host file we need sudo privileges." --title "Give sudo Privileges" 8 112); then
|
||||
# add the domain to the host file
|
||||
echo "127.0.0.1 ${VDM_SUBDOMAIN}.${VDM_DOMAIN}" | sudo tee -a /etc/hosts > /dev/null
|
||||
echo "127.0.0.1 ${1:-$VDM_SUBDOMAIN}.${2:-$VDM_DOMAIN}" | sudo tee -a /etc/hosts >/dev/null
|
||||
# show notice
|
||||
showNotice "${USER^}, ${1:-$VDM_SUBDOMAIN}.${2:-$VDM_DOMAIN} was added to the /etc/hosts file."
|
||||
fi
|
||||
|
Reference in New Issue
Block a user