We want the function to be called function.

This commit is contained in:
Llewellyn van der Merwe 2024-05-27 10:01:49 +02:00
parent 0d2649601a
commit b7973a0011
Signed by: Llewellyn
GPG Key ID: A9201372263741E7

View File

@ -27,8 +27,8 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
OS_NUMBER=3 OS_NUMBER=3
fi fi
# Function to check Bash version # Check Bash version
check_bash_version() { function check_bash_version() {
local bash_version="$1" local bash_version="$1"
local version_string="$BASH_VERSION" local version_string="$BASH_VERSION"
local major_version="${version_string%%.*}" local major_version="${version_string%%.*}"
@ -62,8 +62,8 @@ command -v awk >/dev/null 2>&1 || {
# echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require rsync." # echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require rsync."
# exit 1 # exit 1
#} #}
# Function to check and install Docker on Linux # Check and install Docker on Linux
install_docker_linux() { function install_docker_linux() {
echo "Installing Docker on Linux..." echo "Installing Docker on Linux..."
# Add Docker GPG key and repository to sources.list. # 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 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
@ -79,15 +79,15 @@ install_docker_linux() {
sudo systemctl start docker.service sudo systemctl start docker.service
echo "Docker is installed." echo "Docker is installed."
} }
# Function to check and install Docker on macOS # Check and install Docker on macOS
install_docker_macos() { function install_docker_macos() {
echo "Installing Docker on macOS..." echo "Installing Docker on macOS..."
brew install --cask docker brew install --cask docker
open /Applications/Docker.app open /Applications/Docker.app
echo "Docker is installed. Please follow the prompts to complete the installation." echo "Docker is installed. Please follow the prompts to complete the installation."
} }
# Function to check and install Docker on Windows (MSYS/Cygwin) # Check and install Docker on Windows (MSYS/Cygwin)
install_docker_windows() { function install_docker_windows() {
echo "Please download and install Docker Desktop from https://www.docker.com/products/docker-desktop" echo "Please download and install Docker Desktop from https://www.docker.com/products/docker-desktop"
echo "Docker Desktop is required for Windows environments." echo "Docker Desktop is required for Windows environments."
exit 0 exit 0
@ -119,8 +119,8 @@ if ! command -v docker &>/dev/null; then
exit 1 exit 1
fi fi
fi fi
# Function to install Docker Compose on Linux # Install Docker Compose on Linux
install_docker_compose_linux() { function install_docker_compose_linux() {
echo "Installing Docker Compose on Linux..." echo "Installing Docker Compose on Linux..."
# Download the latest Docker Compose binary. # 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/') COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
@ -130,8 +130,8 @@ install_docker_compose_linux() {
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
echo "Docker Compose is installed." echo "Docker Compose is installed."
} }
# Function to install Docker Compose on macOS # Install Docker Compose on macOS
install_docker_compose_macos() { function install_docker_compose_macos() {
echo "Installing Docker Compose on macOS..." echo "Installing Docker Compose on macOS..."
# Download the latest Docker Compose binary. # 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/') COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
@ -141,8 +141,8 @@ install_docker_compose_macos() {
sudo ln -s /usr/local/bin/docker-compose /usr/local/bin/docker-compose sudo ln -s /usr/local/bin/docker-compose /usr/local/bin/docker-compose
echo "Docker Compose is installed." echo "Docker Compose is installed."
} }
# Function to install Docker Compose on Windows (MSYS/Cygwin) # Install Docker Compose on Windows (MSYS/Cygwin)
install_docker_compose_windows() { function install_docker_compose_windows() {
echo "Please download Docker Compose from https://github.com/docker/compose/releases" echo "Please download Docker Compose from https://github.com/docker/compose/releases"
echo "and place it in a directory included in your PATH." echo "and place it in a directory included in your PATH."
exit 0 exit 0
@ -4594,8 +4594,8 @@ function isFunc() {
declare -F "$1" >/dev/null declare -F "$1" >/dev/null
} }
# Function to update the host file for Linux and macOS # Update the host file for Linux and macOS
updateHostFile_unix() { function updateHostFile_unix() {
# check if we should add to host file # check if we should add to host file
if allowEditHostFile; then if allowEditHostFile; then
# check if already in host file # check if already in host file
@ -4611,8 +4611,8 @@ updateHostFile_unix() {
fi fi
} }
# Function to manually edit the host file for Linux and macOS # Manually edit the host file for Linux and macOS
editHostFile_unix() { function editHostFile_unix() {
# check if we should add to host file # check if we should add to host file
if allowEditHostFile; then if allowEditHostFile; then
# if this container is enabled ask if it should be redeployed # if this container is enabled ask if it should be redeployed
@ -4626,8 +4626,8 @@ editHostFile_unix() {
fi fi
} }
# Function to update the host file for Windows (MSYS/Cygwin) # Update the host file for Windows (MSYS/Cygwin)
updateHostFile_windows() { function updateHostFile_windows() {
local subdomain=${1:-$VDM_SUBDOMAIN} local subdomain=${1:-$VDM_SUBDOMAIN}
local domain=${2:-$VDM_DOMAIN} local domain=${2:-$VDM_DOMAIN}
local host_file="/c/Windows/System32/drivers/etc/hosts" local host_file="/c/Windows/System32/drivers/etc/hosts"
@ -4643,8 +4643,8 @@ updateHostFile_windows() {
fi fi
} }
# Function to manually edit the host file for Windows (MSYS/Cygwin) # Manually edit the host file for Windows (MSYS/Cygwin)
editHostFile_windows() { function editHostFile_windows() {
local host_file="/c/Windows/System32/drivers/etc/hosts" local host_file="/c/Windows/System32/drivers/etc/hosts"
if allowEditHostFile; then if allowEditHostFile; then
@ -4656,8 +4656,8 @@ editHostFile_windows() {
fi fi
} }
# Function to update the host file (dynamically calls the correct OS function) # Update the host file (dynamically calls the correct OS function)
updateHostFile() { function updateHostFile() {
case "$OS_NUMBER" in case "$OS_NUMBER" in
1|2) 1|2)
updateHostFile_unix "$@" updateHostFile_unix "$@"
@ -4672,8 +4672,8 @@ updateHostFile() {
esac esac
} }
# Function to manually edit the host file (dynamically calls the correct OS function) # Manually edit the host file (dynamically calls the correct OS function)
editHostFile() { function editHostFile() {
case "$OS_NUMBER" in case "$OS_NUMBER" in
1|2) 1|2)
editHostFile_unix editHostFile_unix