Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
ed147ece9e
|
|||
8cf856b35e
|
|||
1a83002c9d
|
|||
e627e7f4cd
|
|||
eaa5b217c8
|
|||
b7973a0011
|
138
src/octojoom
138
src/octojoom
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# The most recent program version.
|
# The most recent program version.
|
||||||
_VERSION="3.6.1"
|
_VERSION="3.6.2"
|
||||||
_V="3.6"
|
_V="3.6"
|
||||||
|
|
||||||
# Bash version required
|
# Bash version required
|
||||||
@ -18,6 +18,12 @@ BACK_TITLE=" Octoleo | ${USER}@${SERVER_HOSTNAME}"
|
|||||||
|
|
||||||
#####################################################################################################################VDM
|
#####################################################################################################################VDM
|
||||||
######################################## The environment preparation
|
######################################## 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
|
# Set OS number
|
||||||
OS_NUMBER=0 # Unknown
|
OS_NUMBER=0 # Unknown
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
@ -27,8 +33,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%%.*}"
|
||||||
@ -42,19 +48,60 @@ check_bash_version() {
|
|||||||
}
|
}
|
||||||
# Check for the appropriate version of Bash
|
# Check for the appropriate version of Bash
|
||||||
check_bash_version "$_bash_v"
|
check_bash_version "$_bash_v"
|
||||||
# make sure whiptail is installed
|
# Install whiptail on Ubuntu
|
||||||
command -v whiptail >/dev/null 2>&1 || {
|
function install_whiptail_linux() {
|
||||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require whiptail."
|
sudo apt-get update
|
||||||
exit 1
|
sudo apt-get install whiptail -y
|
||||||
}
|
}
|
||||||
# make sure curl is installed
|
# Install whiptail on macOS
|
||||||
command -v curl >/dev/null 2>&1 || {
|
function install_whiptail_macos() {
|
||||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require curl."
|
if ! command -v brew >/dev/null 2>&1; then
|
||||||
exit 1
|
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
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# make sure awk is installed
|
# make sure awk is installed
|
||||||
command -v awk >/dev/null 2>&1 || {
|
command -v awk >/dev/null 2>&1 || {
|
||||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require awk."
|
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
|
exit 1
|
||||||
}
|
}
|
||||||
# make sure rsync is installed (hmmm not always)
|
# 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."
|
# 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 +126,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
|
||||||
@ -116,11 +163,12 @@ if ! command -v docker &>/dev/null; then
|
|||||||
else
|
else
|
||||||
# If the user chooses No, exit the script with an error message
|
# If the user chooses No, exit the script with an error message
|
||||||
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script requires Docker."
|
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
|
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 +178,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 +189,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
|
||||||
@ -171,9 +219,13 @@ if ! command -v docker-compose &>/dev/null; then
|
|||||||
else
|
else
|
||||||
# If the user chooses No, exit the script with an error message
|
# 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 "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
|
exit 1
|
||||||
fi
|
fi
|
||||||
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
|
# just clear the screen
|
||||||
clear
|
clear
|
||||||
|
|
||||||
@ -262,15 +314,13 @@ function traefik__TRuST__setup() {
|
|||||||
function traefikContainer() {
|
function traefikContainer() {
|
||||||
# we build the yml file
|
# we build the yml file
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
version: "3.3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
traefik:
|
traefik:
|
||||||
container_name: traefik
|
container_name: traefik
|
||||||
image: "traefik:latest"
|
image: "traefik:latest"
|
||||||
command:
|
command:
|
||||||
${VDM_REMOVE_SECURE} - --entrypoints.web.address=:80
|
- --entrypoints.web.address=:80
|
||||||
${VDM_REMOVE_SECURE} - --entrypoints.websecure.address=:443
|
- --entrypoints.websecure.address=:443
|
||||||
# - --api.dashboard=true
|
# - --api.dashboard=true
|
||||||
# - --api.insecure=true
|
# - --api.insecure=true
|
||||||
- --providers.docker
|
- --providers.docker
|
||||||
@ -303,6 +353,7 @@ ${VDM_REMOVE_SECURE} - "traefik.http.middlewares.redirect-to-me.redirectsch
|
|||||||
|
|
||||||
networks:
|
networks:
|
||||||
traefik:
|
traefik:
|
||||||
|
external: true
|
||||||
name: ${VDM_TRAEFIK_GATEWAY:-traefik_webgateway}
|
name: ${VDM_TRAEFIK_GATEWAY:-traefik_webgateway}
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -376,8 +427,6 @@ function portainer__TRuST__setup() {
|
|||||||
function portainerContainer() {
|
function portainerContainer() {
|
||||||
# we build the yml file
|
# we build the yml file
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
version: "3.3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
portainer:
|
portainer:
|
||||||
image: portainer/portainer-ce:latest
|
image: portainer/portainer-ce:latest
|
||||||
@ -732,7 +781,6 @@ function joomlaContainer() {
|
|||||||
fi
|
fi
|
||||||
# we build the yml file
|
# we build the yml file
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
version: '2'
|
|
||||||
services:
|
services:
|
||||||
mariadb${VDM_KEY}:
|
mariadb${VDM_KEY}:
|
||||||
image: mariadb:latest
|
image: mariadb:latest
|
||||||
@ -1317,7 +1365,6 @@ function openssh__TRuST__setup() {
|
|||||||
function opensshContainer() {
|
function opensshContainer() {
|
||||||
# we build the yml file
|
# we build the yml file
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
version: "2.1"
|
|
||||||
services:
|
services:
|
||||||
openssh-server-${VDM_KEY}:
|
openssh-server-${VDM_KEY}:
|
||||||
image: lscr.io/linuxserver/openssh-server
|
image: lscr.io/linuxserver/openssh-server
|
||||||
@ -1339,6 +1386,7 @@ services:
|
|||||||
|
|
||||||
networks:
|
networks:
|
||||||
openssh:
|
openssh:
|
||||||
|
external: true
|
||||||
name: ${VDM_OPENSSH_GATEWAY:-openssh_gateway}
|
name: ${VDM_OPENSSH_GATEWAY:-openssh_gateway}
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -4017,7 +4065,7 @@ function setJoomlaPassword() {
|
|||||||
'joomla-17082005' 'Enter Joomla User Password')
|
'joomla-17082005' 'Enter Joomla User Password')
|
||||||
# keep asking if empty
|
# keep asking if empty
|
||||||
if [ ${#VDM_J_PASSWORD} -le 12 ]; then
|
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
|
fi
|
||||||
done
|
done
|
||||||
# make sure it is available
|
# make sure it is available
|
||||||
@ -4594,8 +4642,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 +4659,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 +4674,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 +4691,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 +4704,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 +4720,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
|
||||||
|
Reference in New Issue
Block a user