Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
593ae84c89
|
|||
962b1628c2
|
|||
b666db9f33
|
|||
ed147ece9e
|
|||
8cf856b35e
|
|||
1a83002c9d
|
|||
e627e7f4cd
|
|||
eaa5b217c8
|
|||
b7973a0011
|
306
src/octojoom
306
src/octojoom
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The most recent program version.
|
||||
_VERSION="3.6.1"
|
||||
_VERSION="3.6.4"
|
||||
_V="3.6"
|
||||
|
||||
# Bash version required
|
||||
@ -18,6 +18,12 @@ BACK_TITLE=" Octoleo | ${USER}@${SERVER_HOSTNAME}"
|
||||
|
||||
#####################################################################################################################VDM
|
||||
######################################## The environment preparation
|
||||
# make sure curl is installed
|
||||
command -v curl >/dev/null 2>&1 || {
|
||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require curl."
|
||||
echo >&2 "NOTICE: Please install curl first and then re-run this script again."
|
||||
exit 1
|
||||
}
|
||||
# Set OS number
|
||||
OS_NUMBER=0 # Unknown
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
@ -27,8 +33,8 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
|
||||
OS_NUMBER=3
|
||||
fi
|
||||
# Function to check Bash version
|
||||
check_bash_version() {
|
||||
# Check Bash version
|
||||
function check_bash_version() {
|
||||
local bash_version="$1"
|
||||
local version_string="$BASH_VERSION"
|
||||
local major_version="${version_string%%.*}"
|
||||
@ -42,19 +48,60 @@ check_bash_version() {
|
||||
}
|
||||
# Check for the appropriate version of Bash
|
||||
check_bash_version "$_bash_v"
|
||||
# make sure whiptail is installed
|
||||
command -v whiptail >/dev/null 2>&1 || {
|
||||
# Install whiptail on Ubuntu
|
||||
function install_whiptail_linux() {
|
||||
sudo apt-get update
|
||||
sudo apt-get install whiptail -y
|
||||
}
|
||||
# Install whiptail on macOS
|
||||
function install_whiptail_macos() {
|
||||
if ! command -v brew >/dev/null 2>&1; then
|
||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require Homebrew to install whiptail on macOS."
|
||||
echo >&2 "NOTICE: Please install Homebrew first and then re-run this script."
|
||||
exit 1
|
||||
fi
|
||||
brew install newt
|
||||
}
|
||||
# Install whiptail on Windows using Chocolatey
|
||||
function install_whiptail_windows() {
|
||||
if ! command -v choco >/dev/null 2>&1; then
|
||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require Chocolatey to install whiptail on Windows."
|
||||
echo >&2 "NOTICE: Please install Chocolatey first and then re-run this script."
|
||||
exit 1
|
||||
fi
|
||||
choco install newt
|
||||
}
|
||||
# Main script
|
||||
if ! command -v whiptail >/dev/null 2>&1; then
|
||||
echo "Whiptail is not installed. Do you want to install it now? (y/n)"
|
||||
read -r response
|
||||
if [[ "$response" =~ ^[Yy]$ ]]; then
|
||||
# If the user chooses Yes, install Docker based on the OS
|
||||
case "$OS_NUMBER" in
|
||||
1)
|
||||
install_whiptail_linux
|
||||
;;
|
||||
2)
|
||||
install_whiptail_macos
|
||||
;;
|
||||
3)
|
||||
install_whiptail_windows
|
||||
;;
|
||||
*)
|
||||
echo >&2 "ERROR: Unsupported operating system."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require whiptail."
|
||||
echo >&2 "NOTICE: Please install whiptail first and then re-run this script again."
|
||||
exit 1
|
||||
}
|
||||
# make sure curl is installed
|
||||
command -v curl >/dev/null 2>&1 || {
|
||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require curl."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
# make sure awk is installed
|
||||
command -v awk >/dev/null 2>&1 || {
|
||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require awk."
|
||||
echo >&2 "NOTICE: Please install awk first and then re-run this script again."
|
||||
exit 1
|
||||
}
|
||||
# make sure rsync is installed (hmmm not always)
|
||||
@ -62,8 +109,8 @@ command -v awk >/dev/null 2>&1 || {
|
||||
# echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require rsync."
|
||||
# exit 1
|
||||
#}
|
||||
# Function to check and install Docker on Linux
|
||||
install_docker_linux() {
|
||||
# Check and install Docker on Linux
|
||||
function install_docker_linux() {
|
||||
echo "Installing Docker on Linux..."
|
||||
# Add Docker GPG key and repository to sources.list.
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
||||
@ -79,15 +126,15 @@ install_docker_linux() {
|
||||
sudo systemctl start docker.service
|
||||
echo "Docker is installed."
|
||||
}
|
||||
# Function to check and install Docker on macOS
|
||||
install_docker_macos() {
|
||||
# Check and install Docker on macOS
|
||||
function install_docker_macos() {
|
||||
echo "Installing Docker on macOS..."
|
||||
brew install --cask docker
|
||||
open /Applications/Docker.app
|
||||
echo "Docker is installed. Please follow the prompts to complete the installation."
|
||||
}
|
||||
# Function to check and install Docker on Windows (MSYS/Cygwin)
|
||||
install_docker_windows() {
|
||||
# Check and install Docker on Windows (MSYS/Cygwin)
|
||||
function install_docker_windows() {
|
||||
echo "Please download and install Docker Desktop from https://www.docker.com/products/docker-desktop"
|
||||
echo "Docker Desktop is required for Windows environments."
|
||||
exit 0
|
||||
@ -116,11 +163,12 @@ if ! command -v docker &>/dev/null; then
|
||||
else
|
||||
# If the user chooses No, exit the script with an error message
|
||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script requires Docker."
|
||||
echo >&2 "NOTICE: Please install Docker first and then re-run this script again."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# Function to install Docker Compose on Linux
|
||||
install_docker_compose_linux() {
|
||||
# Install Docker Compose on Linux
|
||||
function install_docker_compose_linux() {
|
||||
echo "Installing Docker Compose on Linux..."
|
||||
# Download the latest Docker Compose binary.
|
||||
COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
@ -130,8 +178,8 @@ install_docker_compose_linux() {
|
||||
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
|
||||
echo "Docker Compose is installed."
|
||||
}
|
||||
# Function to install Docker Compose on macOS
|
||||
install_docker_compose_macos() {
|
||||
# Install Docker Compose on macOS
|
||||
function install_docker_compose_macos() {
|
||||
echo "Installing Docker Compose on macOS..."
|
||||
# Download the latest Docker Compose binary.
|
||||
COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
@ -141,8 +189,8 @@ install_docker_compose_macos() {
|
||||
sudo ln -s /usr/local/bin/docker-compose /usr/local/bin/docker-compose
|
||||
echo "Docker Compose is installed."
|
||||
}
|
||||
# Function to install Docker Compose on Windows (MSYS/Cygwin)
|
||||
install_docker_compose_windows() {
|
||||
# Install Docker Compose on Windows (MSYS/Cygwin)
|
||||
function install_docker_compose_windows() {
|
||||
echo "Please download Docker Compose from https://github.com/docker/compose/releases"
|
||||
echo "and place it in a directory included in your PATH."
|
||||
exit 0
|
||||
@ -171,9 +219,13 @@ if ! command -v docker-compose &>/dev/null; then
|
||||
else
|
||||
# If the user chooses No, exit the script with an error message
|
||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script requires docker-compose."
|
||||
echo >&2 "NOTICE: Please install docker-compose first and then re-run this script again."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# Setting the LC_ALL with respect to language, regional settings, to use POSIX locale,
|
||||
# so ASCII character set and standardizes behavior is used for consistent across different environments
|
||||
export LC_ALL=C
|
||||
# just clear the screen
|
||||
clear
|
||||
|
||||
@ -262,15 +314,13 @@ function traefik__TRuST__setup() {
|
||||
function traefikContainer() {
|
||||
# we build the yml file
|
||||
cat <<EOF
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
traefik:
|
||||
container_name: traefik
|
||||
image: "traefik:latest"
|
||||
command:
|
||||
${VDM_REMOVE_SECURE} - --entrypoints.web.address=:80
|
||||
${VDM_REMOVE_SECURE} - --entrypoints.websecure.address=:443
|
||||
- --entrypoints.web.address=:80
|
||||
- --entrypoints.websecure.address=:443
|
||||
# - --api.dashboard=true
|
||||
# - --api.insecure=true
|
||||
- --providers.docker
|
||||
@ -303,6 +353,7 @@ ${VDM_REMOVE_SECURE} - "traefik.http.middlewares.redirect-to-me.redirectsch
|
||||
|
||||
networks:
|
||||
traefik:
|
||||
external: true
|
||||
name: ${VDM_TRAEFIK_GATEWAY:-traefik_webgateway}
|
||||
EOF
|
||||
}
|
||||
@ -376,8 +427,6 @@ function portainer__TRuST__setup() {
|
||||
function portainerContainer() {
|
||||
# we build the yml file
|
||||
cat <<EOF
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
portainer:
|
||||
image: portainer/portainer-ce:latest
|
||||
@ -579,7 +628,7 @@ function joomla__TRuST__setup() {
|
||||
fi
|
||||
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.service=mailcatcher${VDM_KEY}\"")
|
||||
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.services.mailcatcher${VDM_KEY}.loadbalancer.server.port=1080\"")
|
||||
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}:1080")
|
||||
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}:1025")
|
||||
fi
|
||||
# if this is our octoleo images we can also set the user ID and user-group ID
|
||||
setContainerUser "$(id -u)"
|
||||
@ -732,7 +781,6 @@ function joomlaContainer() {
|
||||
fi
|
||||
# we build the yml file
|
||||
cat <<EOF
|
||||
version: '2'
|
||||
services:
|
||||
mariadb${VDM_KEY}:
|
||||
image: mariadb:latest
|
||||
@ -1024,7 +1072,7 @@ function joomla__TRuST__bulk() {
|
||||
fi
|
||||
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.service=mailcatcher${VDM_KEY}\"")
|
||||
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.services.mailcatcher${VDM_KEY}.loadbalancer.server.port=1080\"")
|
||||
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}:1080")
|
||||
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}:1025")
|
||||
fi
|
||||
# setup letsencrypt stuff
|
||||
VDM_JOOMLA_SECURE_LABELS=''
|
||||
@ -1317,7 +1365,6 @@ function openssh__TRuST__setup() {
|
||||
function opensshContainer() {
|
||||
# we build the yml file
|
||||
cat <<EOF
|
||||
version: "2.1"
|
||||
services:
|
||||
openssh-server-${VDM_KEY}:
|
||||
image: lscr.io/linuxserver/openssh-server
|
||||
@ -1339,6 +1386,7 @@ services:
|
||||
|
||||
networks:
|
||||
openssh:
|
||||
external: true
|
||||
name: ${VDM_OPENSSH_GATEWAY:-openssh_gateway}
|
||||
EOF
|
||||
}
|
||||
@ -1486,6 +1534,8 @@ function joomla__TRuST__enable() {
|
||||
[ -e "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}" ] || {
|
||||
ln -s "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_CONTAINER}" "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}"
|
||||
}
|
||||
# set some local variables
|
||||
local evn_file
|
||||
# check if image has its own env file also
|
||||
evn_file=''
|
||||
# shellcheck disable=SC2015
|
||||
@ -1507,6 +1557,7 @@ function joomla__TRuST__enable() {
|
||||
# set some local variables
|
||||
local vdm_enable_me
|
||||
local container
|
||||
local evn_file
|
||||
# create the folder as needed
|
||||
mkdir -p "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/"
|
||||
# get containers to enable
|
||||
@ -1555,6 +1606,8 @@ function openssh__TRuST__enable() {
|
||||
[ -e "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}" ] || {
|
||||
ln -s "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_CONTAINER}" "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}"
|
||||
}
|
||||
# set some local variables
|
||||
local evn_file
|
||||
# check if image has its own env file also
|
||||
evn_file=''
|
||||
# shellcheck disable=SC2015
|
||||
@ -1665,10 +1718,21 @@ function joomla__TRuST__disable() {
|
||||
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
|
||||
# this means we have a single already selected container to disable if it exists
|
||||
if [ -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}" ]; then
|
||||
# set some local variables
|
||||
local evn_file
|
||||
# check if image has its own env file also
|
||||
evn_file=''
|
||||
# shellcheck disable=SC2015
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/.env" || {
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
|
||||
}
|
||||
# make sure the docker image is stopped
|
||||
# shellcheck disable=SC2015
|
||||
[ ${#evn_file} -ge 1 ] && docker-compose --env-file "${evn_file}" --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/docker-compose.yml" down --remove-orphans || {
|
||||
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/docker-compose.yml" down --remove-orphans
|
||||
}
|
||||
# then remove soft link
|
||||
rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}"
|
||||
else
|
||||
@ -1681,6 +1745,7 @@ function joomla__TRuST__disable() {
|
||||
# set some local variables
|
||||
local vdm_disable_me
|
||||
local container
|
||||
local evn_file
|
||||
# get containers to enable
|
||||
vdm_disable_me=$(getSelectedDirectories "Select container/s to disable." \
|
||||
"${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" "Disable ${VDM_CONTAINER_TYPE^} Containers")
|
||||
@ -1692,8 +1757,17 @@ function joomla__TRuST__disable() {
|
||||
for containered in "${vdm_disable_me_array[@]}"; do
|
||||
# remove the " from the string
|
||||
container="${containered//\"/}"
|
||||
# check if image has its own env file also
|
||||
evn_file=''
|
||||
# shellcheck disable=SC2015
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}/.env" || {
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
|
||||
}
|
||||
# make sure the docker image is stopped
|
||||
# shellcheck disable=SC2015
|
||||
[ ${#evn_file} -ge 1 ] && docker-compose --env-file "${evn_file}" --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}/docker-compose.yml" down --remove-orphans || {
|
||||
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}/docker-compose.yml" down --remove-orphans
|
||||
}
|
||||
# then remove soft link
|
||||
rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}"
|
||||
done
|
||||
@ -1708,10 +1782,21 @@ function openssh__TRuST__disable() {
|
||||
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
|
||||
# this means we have a single already selected container to disable if it exists
|
||||
if [ -d "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}" ]; then
|
||||
# set some local variables
|
||||
local evn_file
|
||||
# check if image has its own env file also
|
||||
evn_file=''
|
||||
# shellcheck disable=SC2015
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/.env" || {
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
|
||||
}
|
||||
# make sure the docker image is stopped
|
||||
# shellcheck disable=SC2015
|
||||
[ ${#evn_file} -ge 1 ] && docker-compose --env-file "${evn_file}" --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/docker-compose.yml" down --remove-orphans || {
|
||||
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}/docker-compose.yml" down --remove-orphans
|
||||
}
|
||||
# then remove soft link
|
||||
rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${VDM_CONTAINER}"
|
||||
else
|
||||
@ -1724,6 +1809,7 @@ function openssh__TRuST__disable() {
|
||||
# set some local variables
|
||||
local vdm_disable_me
|
||||
local container
|
||||
local evn_file
|
||||
# get containers to enable
|
||||
vdm_disable_me=$(getSelectedDirectories "Select container/s to disable." \
|
||||
"${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/" "Disable ${VDM_CONTAINER_TYPE^} Containers")
|
||||
@ -1735,8 +1821,17 @@ function openssh__TRuST__disable() {
|
||||
for containered in "${vdm_disable_me_array[@]}"; do
|
||||
# remove the " from the string
|
||||
container="${containered//\"/}"
|
||||
# check if image has its own env file also
|
||||
evn_file=''
|
||||
# shellcheck disable=SC2015
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}/.env" || {
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
|
||||
}
|
||||
# make sure the docker image is stopped
|
||||
# shellcheck disable=SC2015
|
||||
[ ${#evn_file} -ge 1 ] && docker-compose --env-file "${evn_file}" --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}/docker-compose.yml" down --remove-orphans || {
|
||||
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}/docker-compose.yml" down --remove-orphans
|
||||
}
|
||||
# then remove soft link
|
||||
rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}"
|
||||
done
|
||||
@ -1751,8 +1846,19 @@ function traefik__TRuST__disable() {
|
||||
if [ ! -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" ]; then
|
||||
showError "There is no ${VDM_CONTAINER_TYPE^} container to disable."
|
||||
else
|
||||
# set some local variables
|
||||
local evn_file
|
||||
# check if image has its own env file also
|
||||
evn_file=''
|
||||
# shellcheck disable=SC2015
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" || {
|
||||
[ -f "${VDM_SRC_PATH}/.env" ] && evn_file="${VDM_SRC_PATH}/.env"
|
||||
}
|
||||
# make sure the docker image is stopped
|
||||
# shellcheck disable=SC2015
|
||||
[ ${#evn_file} -ge 1 ] && docker-compose --env-file "${evn_file}" --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" down || {
|
||||
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" down
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
@ -1763,8 +1869,19 @@ function portainer__TRuST__disable() {
|
||||
if [ ! -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" ]; then
|
||||
showError "There is no ${VDM_CONTAINER_TYPE^} container to disable."
|
||||
else
|
||||
# set some local variables
|
||||
local evn_file
|
||||
# check if image has its own env file also
|
||||
evn_file=''
|
||||
# shellcheck disable=SC2015
|
||||
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" || {
|
||||
[ -f "${VDM_SRC_PATH}/.env" ] && evn_file="${VDM_SRC_PATH}/.env"
|
||||
}
|
||||
# make sure the docker image is stopped
|
||||
# shellcheck disable=SC2015
|
||||
[ ${#evn_file} -ge 1 ] && docker-compose --env-file "${evn_file}" --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" down || {
|
||||
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" down
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
@ -1861,6 +1978,42 @@ function openssh__TRuST__down() {
|
||||
fi
|
||||
}
|
||||
|
||||
#####################################################################################################################VDM
|
||||
######################################## CLONE JOOMLA
|
||||
function joomla__TRuST__clone() {
|
||||
# check if this type have available containers
|
||||
if ! hasDirectories "${VDM_CONTAINER_TYPE}/available/"; then
|
||||
showError "The path ${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/ does not exist or is empty, first run a ${VDM_CONTAINER_TYPE^} setup."
|
||||
else
|
||||
# ask if they want to clone a volume
|
||||
if (whiptail --yesno "Would you like to clone a persistent volume found in (${VDM_PROJECT_PATH})?" \
|
||||
--title "Continue To Clone Persistent Volume" --backtitle "${BACK_TITLE}" 12 112); then
|
||||
# trigger the volumes clone script
|
||||
clonePersistentVolume
|
||||
fi
|
||||
# ask if they want to clone a container
|
||||
if (whiptail --yesno "Would you like to clone a ${VDM_CONTAINER_TYPE^} container?" \
|
||||
--title "Continue To Clone Container (feature not ready)" --defaultno --backtitle "${BACK_TITLE}" 12 112); then
|
||||
# set some local variables
|
||||
local vdm_clone_me
|
||||
local container
|
||||
# list containers... and allow selection to edit
|
||||
container=$(getSelectedDirectory "Select a container you would like to clone." \
|
||||
"${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/" '' "Clone ${VDM_CONTAINER_TYPE^} Container (feature not ready)")
|
||||
# check that we have something, else return to main menu
|
||||
if [ ${#container} -ge 1 ]; then
|
||||
# add the parent dir back
|
||||
vdm_clone_me="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${container}/docker-compose.yml"
|
||||
# check if this docker-composer.yml exist
|
||||
if [ -f "${vdm_clone_me}" ]; then
|
||||
# give little heads-up
|
||||
showNotice "Feature not ready!!\nYou have selected: ${vdm_clone_me}" 13
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#####################################################################################################################VDM
|
||||
######################################## DELETE JOOMLA
|
||||
function joomla__TRuST__delete() {
|
||||
@ -2184,6 +2337,15 @@ function upContainers() {
|
||||
main
|
||||
}
|
||||
|
||||
# clone a container
|
||||
function cloneContainer() {
|
||||
# make sure of our container type
|
||||
VDM_CONTAINER_TYPE="${1}"
|
||||
VDM_TASK="clone"
|
||||
# execute the task
|
||||
main
|
||||
}
|
||||
|
||||
# delete a container
|
||||
function deleteContainer() {
|
||||
# make sure of our container type
|
||||
@ -2399,6 +2561,44 @@ function deletePersistentVolumes() {
|
||||
fi
|
||||
}
|
||||
|
||||
# clone persistent volume
|
||||
function clonePersistentVolume() {
|
||||
# we first check if we have some volumes
|
||||
if hasDirectories '' "${VDM_PROJECT_PATH}"; then
|
||||
# set some local variables
|
||||
local vdm_clone_volume
|
||||
local persistent
|
||||
local new_persistent
|
||||
# get containers to enable
|
||||
vdm_clone_volume=$(getSelectedDirectory "Select persistent volume\s to delete." \
|
||||
"${VDM_PROJECT_PATH}" "Select Persistent Volume to Clone")
|
||||
# check that we have something, else return to main menu
|
||||
if [ ${#vdm_clone_volume} -ge 1 ]; then
|
||||
# remove the " from the string
|
||||
persistent="${vdm_clone_volume//\"/}"
|
||||
# last serious check and then its gone
|
||||
if [ -d "${VDM_PROJECT_PATH}/${persistent}" ]; then
|
||||
# set the new persistent volume name
|
||||
new_persistent="${persistent}"
|
||||
while [ -d "${VDM_PROJECT_PATH}/${new_persistent}" ]; do
|
||||
# get the value
|
||||
new_persistent=$(getInput "Enter a new persistent volume name\n[do not use (${persistent}) or any other existing volume names]" '' 'Enter Persistent Name')
|
||||
# keep asking
|
||||
if [ -d "${VDM_PROJECT_PATH}/${new_persistent}" ]; then
|
||||
showError "You must enter a persistent volume name that does not already exist.\n\n${new_persistent} already exist."
|
||||
fi
|
||||
done
|
||||
# create this new folder
|
||||
mkdir -p "${VDM_PROJECT_PATH}/${new_persistent}"
|
||||
# clone or (copy) the files to a new directory.
|
||||
sudo cp -af "${VDM_PROJECT_PATH}/${persistent}/"* "${VDM_PROJECT_PATH}/${new_persistent}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
showError "There are no persistent volumes found in ${VDM_PROJECT_PATH}."
|
||||
fi
|
||||
}
|
||||
|
||||
# reset persistent Joomla volume
|
||||
function resetPersistentJoomlaVolumes() {
|
||||
# we first check if we have some volumes
|
||||
@ -2713,6 +2913,9 @@ function showJoomla() {
|
||||
hasDirectories '' "${VDM_PROJECT_PATH}" &&
|
||||
menu_options+=("fix" "Fix permissions of folders and files of a container") &&
|
||||
i=$((i + 1))
|
||||
# clone a container & volume
|
||||
hasDirectories 'joomla/available' &&
|
||||
menu_options+=("clone" "Clone a container") && i=$((i + 1))
|
||||
# delete a container
|
||||
hasDirectories 'joomla/available' &&
|
||||
menu_options+=("delete" "Delete a container") && i=$((i + 1))
|
||||
@ -2757,6 +2960,9 @@ function showJoomla() {
|
||||
"fix")
|
||||
fixContainersPermissions
|
||||
;;
|
||||
"clone")
|
||||
cloneContainer 'joomla'
|
||||
;;
|
||||
"delete")
|
||||
deleteContainer 'joomla'
|
||||
;;
|
||||
@ -2774,7 +2980,7 @@ function showJoomla() {
|
||||
|
||||
# menu loop
|
||||
case $CHOICE in
|
||||
"setup" | "edit" | "enable" | "disable" | "down" | "up" | "fix" | "delete" | "reset" | "joomla_env" | "bulk")
|
||||
"setup" | "edit" | "enable" | "disable" | "down" | "up" | "fix" | "clone" | "delete" | "reset" | "joomla_env" | "bulk")
|
||||
showJoomla
|
||||
;;
|
||||
esac
|
||||
@ -4017,7 +4223,7 @@ function setJoomlaPassword() {
|
||||
'joomla-17082005' 'Enter Joomla User Password')
|
||||
# keep asking if empty
|
||||
if [ ${#VDM_J_PASSWORD} -le 12 ]; then
|
||||
showError "You must enter a password with more than 4 characters!"
|
||||
showError "You must enter a password with more than 11 characters!"
|
||||
fi
|
||||
done
|
||||
# make sure it is available
|
||||
@ -4594,8 +4800,8 @@ function isFunc() {
|
||||
declare -F "$1" >/dev/null
|
||||
}
|
||||
|
||||
# Function to update the host file for Linux and macOS
|
||||
updateHostFile_unix() {
|
||||
# Update the host file for Linux and macOS
|
||||
function updateHostFile_unix() {
|
||||
# check if we should add to host file
|
||||
if allowEditHostFile; then
|
||||
# check if already in host file
|
||||
@ -4611,8 +4817,8 @@ updateHostFile_unix() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to manually edit the host file for Linux and macOS
|
||||
editHostFile_unix() {
|
||||
# Manually edit the host file for Linux and macOS
|
||||
function editHostFile_unix() {
|
||||
# check if we should add to host file
|
||||
if allowEditHostFile; then
|
||||
# if this container is enabled ask if it should be redeployed
|
||||
@ -4626,8 +4832,8 @@ editHostFile_unix() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to update the host file for Windows (MSYS/Cygwin)
|
||||
updateHostFile_windows() {
|
||||
# Update the host file for Windows (MSYS/Cygwin)
|
||||
function updateHostFile_windows() {
|
||||
local subdomain=${1:-$VDM_SUBDOMAIN}
|
||||
local domain=${2:-$VDM_DOMAIN}
|
||||
local host_file="/c/Windows/System32/drivers/etc/hosts"
|
||||
@ -4643,8 +4849,8 @@ updateHostFile_windows() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to manually edit the host file for Windows (MSYS/Cygwin)
|
||||
editHostFile_windows() {
|
||||
# Manually edit the host file for Windows (MSYS/Cygwin)
|
||||
function editHostFile_windows() {
|
||||
local host_file="/c/Windows/System32/drivers/etc/hosts"
|
||||
|
||||
if allowEditHostFile; then
|
||||
@ -4656,8 +4862,8 @@ editHostFile_windows() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to update the host file (dynamically calls the correct OS function)
|
||||
updateHostFile() {
|
||||
# Update the host file (dynamically calls the correct OS function)
|
||||
function updateHostFile() {
|
||||
case "$OS_NUMBER" in
|
||||
1|2)
|
||||
updateHostFile_unix "$@"
|
||||
@ -4672,8 +4878,8 @@ updateHostFile() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to manually edit the host file (dynamically calls the correct OS function)
|
||||
editHostFile() {
|
||||
# Manually edit the host file (dynamically calls the correct OS function)
|
||||
function editHostFile() {
|
||||
case "$OS_NUMBER" in
|
||||
1|2)
|
||||
editHostFile_unix
|
||||
|
Reference in New Issue
Block a user