4 Commits

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# The most recent program version. # The most recent program version.
_VERSION="2.0.0" _VERSION="2.0.2"
_V="2.0" _V="2.0"
# The program full name # The program full name
@ -72,7 +72,7 @@ function traefik__TRuST__setup() {
while [ ${#VDM_DOMAIN} -le 1 ]; do while [ ${#VDM_DOMAIN} -le 1 ]; do
# get the value # 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_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 # keep asking if empty or does exist
[ ${#VDM_DOMAIN} -ge 1 ] || { [ ${#VDM_DOMAIN} -ge 1 ] || {
showError "You must enter a domain name!" showError "You must enter a domain name!"
@ -128,19 +128,19 @@ services:
container_name: traefik container_name: traefik
image: "traefik:latest" image: "traefik:latest"
command: command:
- --entrypoints.web.address=:80 ${VDM_REMOVE_SECURE} - --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443 ${VDM_REMOVE_SECURE} - --entrypoints.websecure.address=:443
# - --api.dashboard=true # - --api.dashboard=true
# - --api.insecure=true # - --api.insecure=true
- --providers.docker - --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.httpchallenge=true
${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.keytype=RSA4096 ${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.email=${VDM_SECURE_EMAIL:-user@demo.com}
${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.storage=/acme.json ${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.storage=/acme.json
${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallenge.entrypoint=web ${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallenge.entrypoint=web
# - --providers.file.directory=/conf ${VDM_REMOVE_SECURE} - --providers.file.directory=/conf
# - --providers.file.watch=true ${VDM_REMOVE_SECURE} - --providers.file.watch=true
restart: unless-stopped restart: unless-stopped
ports: ports:
- "80:80" - "80:80"
@ -148,15 +148,15 @@ ${VDM_REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallen
# - "8080:8080" # - "8080:8080"
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock - /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_REMOVE_SECURE} - "\${VDM_PROJECT_PATH}/traefik/acme.json:/acme.json"
- "\${VDM_PROJECT_PATH}/traefik/errors:/errors" ${VDM_REMOVE_SECURE} - "\${VDM_PROJECT_PATH}/traefik/errors:/errors"
labels: ${VDM_REMOVE_SECURE} labels:
# settings for all containers # settings for all containers
- "traefik.http.routers.http-catchall.rule=hostregexp(\`{host:.+}\`)" ${VDM_REMOVE_SECURE} - "traefik.http.routers.http-catchall.rule=hostregexp(\`{host:.+}\`)"
- "traefik.http.routers.http-catchall.entrypoints=web" ${VDM_REMOVE_SECURE} - "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-me" ${VDM_REMOVE_SECURE} - "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.middlewares.redirect-to-me.redirectscheme.scheme=${VDM_HTTP_SCHEME}"
networks: networks:
- traefik - traefik
@ -195,7 +195,7 @@ function portainer__TRuST__setup() {
while [ ${#VDM_DOMAIN} -le 1 ]; do while [ ${#VDM_DOMAIN} -le 1 ]; do
# get the value # 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_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 # keep asking if empty or does exist
[ ${#VDM_DOMAIN} -ge 1 ] || { [ ${#VDM_DOMAIN} -ge 1 ] || {
showError "You must enter a domain name!" showError "You must enter a domain name!"
@ -260,7 +260,7 @@ services:
# Frontend # Frontend
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.portainer.rule=Host(\`port.${VDM_DOMAIN}\`)" - "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" ${VDM_REMOVE_SECURE} - "traefik.http.routers.portainer.tls.certresolver=vdmresolver"
- "traefik.http.routers.portainer.service=portainer" - "traefik.http.routers.portainer.service=portainer"
- "traefik.http.services.portainer.loadbalancer.server.port=9000" - "traefik.http.services.portainer.loadbalancer.server.port=9000"
@ -325,7 +325,7 @@ function joomla__TRuST__setup() {
while [ ${#VDM_DOMAIN} -le 1 ]; do while [ ${#VDM_DOMAIN} -le 1 ]; do
# get the value # 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_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 # keep asking if empty or does exist
[ ${#VDM_DOMAIN} -ge 1 ] || { [ ${#VDM_DOMAIN} -ge 1 ] || {
showError "You must enter a domain name!" showError "You must enter a domain name!"
@ -444,6 +444,8 @@ function joomla__TRuST__setup() {
export vdm_database_rootpass export vdm_database_rootpass
# set host file if needed # set host file if needed
updateHostFile updateHostFile
# also set the database domain
updateHostFile "${VDM_SUBDOMAIN}db"
# create the directory if it does not yet already exist # create the directory if it does not yet already exist
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m 700 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_SUBDOMAIN}.${VDM_DOMAIN}" mkdir -p -m 700 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_SUBDOMAIN}.${VDM_DOMAIN}"
@ -516,7 +518,7 @@ services:
# joomla # joomla
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.joomla_${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}.${VDM_DOMAIN}\`)" - "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}.tls.certresolver=vdmresolver"
${VDM_REMOVE_SECURE} - "traefik.http.routers.joomla_${VDM_KEY}.service=joomla_${VDM_KEY}" ${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" ${VDM_REMOVE_SECURE} - "traefik.http.services.joomla_${VDM_KEY}.loadbalancer.server.port=80"
@ -536,10 +538,10 @@ ${VDM_REMOVE_SECURE} - "traefik.http.services.joomla_${VDM_KEY}.loadbalance
# phpmyadmin # phpmyadmin
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.phpmyadmin_${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}db.${VDM_DOMAIN}\`)" - "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" ${VDM_REMOVE_SECURE} - "traefik.http.routers.phpmyadmin_${VDM_KEY}.tls.certresolver=vdmresolver"
- "traefik.http.routers.phpmyadmin_${VDM_KEY}.service=phpmyadmin_${VDM_KEY}" ${VDM_REMOVE_SECURE} - "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.services.phpmyadmin_${VDM_KEY}.loadbalancer.server.port=80"
networks: networks:
traefik: traefik:
@ -567,7 +569,7 @@ function openssh__TRuST__setup() {
while [ ${#VDM_DOMAIN} -le 1 ]; do while [ ${#VDM_DOMAIN} -le 1 ]; do
# get the value # 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_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 # keep asking if empty or does exist
[ ${#VDM_DOMAIN} -ge 1 ] || { [ ${#VDM_DOMAIN} -ge 1 ] || {
showError "You must enter a domain name!" showError "You must enter a domain name!"
@ -641,35 +643,40 @@ function openssh__TRuST__setup() {
VDM_PUBLIC_KEY_U_DIR=$(getSelectedDirectory "Select the containers ssh public keys folder." \ VDM_PUBLIC_KEY_U_DIR=$(getSelectedDirectory "Select the containers ssh public keys folder." \
"${VDM_PUBLIC_KEY_GLOBAL_DIR}" "${VDM_KEY,,}" 'Select Folder') "${VDM_PUBLIC_KEY_GLOBAL_DIR}" "${VDM_KEY,,}" 'Select Folder')
# keep asking if empty or does exist # 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
(whiptail --yesno "Can we create this (${VDM_PUBLIC_KEY_U_DIR}) containers ssh public keys folder" --title "Create the Path" 8 112); then # add the parent dir back
# shellcheck disable=SC2174 VDM_PUBLIC_KEY_U_DIR="${VDM_PUBLIC_KEY_GLOBAL_DIR}/${VDM_PUBLIC_KEY_U_DIR}"
mkdir -p -m 700 "${VDM_PUBLIC_KEY_U_DIR}" # check if this directory exist
# TODO add option to add keys? if [ ! -d "${VDM_PUBLIC_KEY_U_DIR}" ] &&
elif [ ${#VDM_PUBLIC_KEY_U_DIR} -le 1 ]; then (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?
fi
else
showError "You must set a containers ssh public keys folder." showError "You must set a containers ssh public keys folder."
fi fi
fi fi
done done
# we must get the project path # we must get the project path
VDM_ENV_PROJECT_PATH="VDM_${VDM_ENV_KEY^^}_PROJECT_PATH" VDM_ENV_PROJECT_DIR="VDM_${VDM_ENV_KEY^^}_PROJECT_DIR"
VDM_PROJECT_U_PATH=${!VDM_ENV_PROJECT_PATH} VDM_PROJECT_U_DIR=${!VDM_ENV_PROJECT_DIR}
# get the directory of the ssh public keys if not set # 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 # creat the path if it exist
if [ ${#VDM_PROJECT_U_PATH} -ge 1 ] && if [ ${#VDM_PROJECT_U_DIR} -ge 1 ] &&
(whiptail --yesno "Can we create the ${VDM_PROJECT_U_PATH} parent mounting directory" --title "Create the Path" 8 112); then (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_PATH}" mkdir -p "${VDM_PROJECT_U_DIR}"
else else
# get the value # 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') "${VDM_PROJECT_PATH}" 'Enter Path')
# keep asking if empty or does exist # keep asking if empty or does exist
if [ ${#VDM_PROJECT_U_PATH} -ge 1 ] && [ ! -d "${VDM_PROJECT_U_PATH}" ] && if [ ${#VDM_PROJECT_U_DIR} -ge 1 ] && [ ! -d "${VDM_PROJECT_U_DIR}" ] &&
(whiptail --yesno "Can we create the ${VDM_PROJECT_U_PATH} parent mounting directory" --title "Create the Path" 8 112); then (whiptail --yesno "Can we create the ${VDM_PROJECT_U_DIR} parent mounting directory" --title "Create the Path" 8 112); then
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m 700 "${VDM_PROJECT_U_PATH}" mkdir -p -m 700 "${VDM_PROJECT_U_DIR}"
elif [ ${#VDM_PROJECT_U_PATH} -le 1 ]; then 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." showError "You must set a parent mounting directory path where we can select the folders to mount to this container."
fi fi
fi fi
@ -678,7 +685,7 @@ function openssh__TRuST__setup() {
while [ ${#VDM_MOUNT_DIRS} -le 1 ]; do while [ ${#VDM_MOUNT_DIRS} -le 1 ]; do
# get the value # get the value
VDM_MOUNT_DIRS=$(getSelectedDirectories "Select the directories to mount to this container." \ 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 # keep asking if empty or does exist
if [ ${#VDM_MOUNT_DIRS} -le 1 ]; then if [ ${#VDM_MOUNT_DIRS} -le 1 ]; then
showError "You must set the directories to mount to this container." showError "You must set the directories to mount to this container."
@ -693,7 +700,7 @@ function openssh__TRuST__setup() {
# set the full path # set the full path
mDir="${mDir//\"/}" mDir="${mDir//\"/}"
# when we mount a joomla volume we may not want to mount the database # 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 # 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 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}") VDM_MOUNT_PROJECTS+=$(getYMLDashLine "\${VDM_${VDM_ENV_KEY^^}_PROJECT_DIR}/${mDir}/joomla:/app/${mDir}")
@ -704,7 +711,7 @@ function openssh__TRuST__setup() {
# add this value if not set variable # add this value if not set variable
setEnvVariable "VDM_DOMAIN=\"${VDM_DOMAIN}\"" setEnvVariable "VDM_DOMAIN=\"${VDM_DOMAIN}\""
# add this value if not set variable # 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 # add this value if not set variable
setContainerEnvVariable "VDM_PUBLIC_KEY_GLOBAL_DIR=\"${VDM_PUBLIC_KEY_GLOBAL_DIR}\"" setContainerEnvVariable "VDM_PUBLIC_KEY_GLOBAL_DIR=\"${VDM_PUBLIC_KEY_GLOBAL_DIR}\""
# add this value if not set variable # add this value if not set variable
@ -723,7 +730,7 @@ function openssh__TRuST__setup() {
export VDM_ENV_KEY export VDM_ENV_KEY
export VDM_PUBLIC_KEY_GLOBAL_DIR export VDM_PUBLIC_KEY_GLOBAL_DIR
export VDM_PUBLIC_KEY_U_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 # create the directory if it does not yet already exist
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m 700 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_USER_NAME}.${VDM_DOMAIN}" mkdir -p -m 700 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_USER_NAME}.${VDM_DOMAIN}"
@ -749,7 +756,7 @@ function openssh__TRuST__setup() {
unset VDM_ENV_KEY unset VDM_ENV_KEY
unset VDM_PUBLIC_KEY_GLOBAL_DIR unset VDM_PUBLIC_KEY_GLOBAL_DIR
unset VDM_PUBLIC_KEY_U_DIR unset VDM_PUBLIC_KEY_U_DIR
unset VDM_PROJECT_U_PATH unset VDM_PROJECT_U_DIR
# return a success # return a success
return 0 return 0
} }
@ -993,10 +1000,10 @@ function joomla__TRuST__disable() {
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}/enabled/${VDM_CONTAINER}" ]; then if [ -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}" ]; then
# make sure the docker image is stopped # make sure the docker image is stopped
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/docker-compose.yml" down docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/docker-compose.yml" down
# then remove soft link # then remove soft link
rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}" rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}"
else else
showError "The (${VDM_CONTAINER}) container is not enabled." showError "The (${VDM_CONTAINER}) container is not enabled."
fi fi
@ -1039,10 +1046,10 @@ function openssh__TRuST__disable() {
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}/enabled/${VDM_CONTAINER}" ]; then if [ -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}" ]; then
# make sure the docker image is stopped # make sure the docker image is stopped
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/docker-compose.yml" down docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/docker-compose.yml" down
# then remove soft link # then remove soft link
rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}" rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}"
else else
showError "The (${VDM_CONTAINER}) container is not enabled." showError "The (${VDM_CONTAINER}) container is not enabled."
fi fi
@ -1469,8 +1476,12 @@ function runUpdate() {
# 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/docker-deploy /usr/local/bin/docker-deploy.bak
fi 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 # 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 # give success message
echo "SUCCESS: Update was successful." echo "SUCCESS: Update was successful."
# do we have a backup # do we have a backup
@ -1646,7 +1657,7 @@ function runUninstall() {
} }
# we show the octoleo info quietly # we show the octoleo info quietly
octoleoQuietly(){ octoleoQuietly() {
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/docker-deploy
@ -1673,13 +1684,13 @@ octoleoQuietly(){
--quiet" --quiet"
whiptail --msgbox --scrolltext "${message}" 30 112 whiptail --msgbox "${message}" --fb --backtitle " Octoleo" 32 112
} }
# show the help menu # show the help menu
function showHelpMenu() { function showHelpMenu() {
help=$(showHelp) help=$(showHelp)
whiptail --msgbox --scrolltext "${help}" 30 112 whiptail --msgbox --scrolltext "${help}" --fb --backtitle " Octoleo" 30 90
} }
#####################################################################################################################VDM #####################################################################################################################VDM
@ -1688,7 +1699,9 @@ function showHelpMenu() {
# show Joomla menu # show Joomla menu
function showJoomla() { function showJoomla() {
CHOICE=$( CHOICE=$(
whiptail --title "Joomla | ${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 7 \ whiptail --menu "Make your selection" 20 112 8 \
--title "Joomla | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" \
"1)" "<-- Return to the main menu." \ "1)" "<-- Return to the main menu." \
"2)" "Setup new container" \ "2)" "Setup new container" \
"3)" "Enable existing container" \ "3)" "Enable existing container" \
@ -1727,7 +1740,9 @@ function showJoomla() {
# show Openssh menu # show Openssh menu
function showOpenssh() { function showOpenssh() {
CHOICE=$( CHOICE=$(
whiptail --title "Openssh | ${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 6 \ whiptail --menu "Make your selection" 20 112 7 \
--title "Openssh | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" \
"1)" "<-- Return to the main menu." \ "1)" "<-- Return to the main menu." \
"2)" "Setup new container" \ "2)" "Setup new container" \
"3)" "Enable existing container" \ "3)" "Enable existing container" \
@ -1762,7 +1777,9 @@ function showOpenssh() {
# show Traefik menu # show Traefik menu
function showTraefik() { function showTraefik() {
CHOICE=$( CHOICE=$(
whiptail --title "Traefik | ${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 4 \ whiptail --menu "Make your selection" 16 112 4 \
--title "Traefik | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" \
"1)" "<-- Return to the main menu." \ "1)" "<-- Return to the main menu." \
"2)" "Setup Traefik" \ "2)" "Setup Traefik" \
"3)" "Enable Traefik" \ "3)" "Enable Traefik" \
@ -1785,7 +1802,9 @@ function showTraefik() {
# show Portainer menu # show Portainer menu
function showPortainer() { function showPortainer() {
CHOICE=$( CHOICE=$(
whiptail --title "Portainer | ${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 4 \ whiptail --menu "Make your selection" 16 112 4 \
--title "Portainer | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" \
"1)" "<-- Return to the main menu." \ "1)" "<-- Return to the main menu." \
"2)" "Setup Portainer" \ "2)" "Setup Portainer" \
"3)" "Enable Portainer" \ "3)" "Enable Portainer" \
@ -1809,7 +1828,9 @@ function showPortainer() {
function mainMenu() { function mainMenu() {
while true; do while true; do
CHOICE=$( CHOICE=$(
whiptail --title "${PROGRAM_NAME} v${_V}" --menu "Make your selection" 16 112 10 \ whiptail --menu "Make your selection" 20 112 10 \
--title "${PROGRAM_NAME} v${_V}" --fb \
--backtitle " Octoleo" \
"1)" "Joomla containers" \ "1)" "Joomla containers" \
"2)" "Openssh containers" \ "2)" "Openssh containers" \
"3)" "Traefik container" \ "3)" "Traefik container" \
@ -1980,7 +2001,7 @@ function getPassword() {
} }
# get and set the access token # get and set the access token
function getAccessToken(){ function getAccessToken() {
# we try getting the token twice # we try getting the token twice
local t=0 local t=0
local new_token=false local new_token=false
@ -2011,6 +2032,18 @@ function getAccessToken(){
return 0 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 # set the networks in place
function setNetworks() { function setNetworks() {
# we create the networks # we create the networks
@ -2075,7 +2108,7 @@ function isFunc() {
} }
# update the host file # update the host file
function updateHostFile(){ function updateHostFile() {
# check if we have secure switch set # check if we have secure switch set
if [ "${VDM_UPDATE_HOST:-not}" = 'not' ]; then if [ "${VDM_UPDATE_HOST:-not}" = 'not' ]; then
# check the security switch # check the security switch
@ -2095,7 +2128,7 @@ function updateHostFile(){
showNotice "${USER^}, ${1:-$VDM_SUBDOMAIN}.${2:-$VDM_DOMAIN} is already in the /etc/hosts file." 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 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 # 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 # show notice
showNotice "${USER^}, ${1:-$VDM_SUBDOMAIN}.${2:-$VDM_DOMAIN} was added to the /etc/hosts file." showNotice "${USER^}, ${1:-$VDM_SUBDOMAIN}.${2:-$VDM_DOMAIN} was added to the /etc/hosts file."
fi fi