Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
b5693c9b91
|
|||
f50f87a454
|
|||
8ee988a534
|
@ -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!"
|
||||
@ -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!"
|
||||
@ -325,7 +325,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!"
|
||||
@ -444,6 +444,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}"
|
||||
@ -567,7 +569,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 +643,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 +685,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 +700,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 +711,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 +730,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 +756,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
|
||||
}
|
||||
@ -1469,8 +1476,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
|
||||
@ -1673,13 +1684,13 @@ octoleoQuietly(){
|
||||
|
||||
--quiet"
|
||||
|
||||
whiptail --msgbox --scrolltext "${message}" 30 112
|
||||
whiptail --msgbox "${message}" --fb --backtitle " Octoleo" 32 112
|
||||
}
|
||||
|
||||
# show the help menu
|
||||
function showHelpMenu() {
|
||||
help=$(showHelp)
|
||||
whiptail --msgbox --scrolltext "${help}" 30 112
|
||||
whiptail --msgbox --scrolltext "${help}" --fb --backtitle " Octoleo" 30 90
|
||||
}
|
||||
|
||||
#####################################################################################################################VDM
|
||||
@ -1688,7 +1699,9 @@ function showHelpMenu() {
|
||||
# show Joomla menu
|
||||
function showJoomla() {
|
||||
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." \
|
||||
"2)" "Setup new container" \
|
||||
"3)" "Enable existing container" \
|
||||
@ -1727,7 +1740,9 @@ function showJoomla() {
|
||||
# show Openssh menu
|
||||
function showOpenssh() {
|
||||
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." \
|
||||
"2)" "Setup new container" \
|
||||
"3)" "Enable existing container" \
|
||||
@ -1762,7 +1777,9 @@ function showOpenssh() {
|
||||
# show Traefik menu
|
||||
function showTraefik() {
|
||||
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." \
|
||||
"2)" "Setup Traefik" \
|
||||
"3)" "Enable Traefik" \
|
||||
@ -1785,7 +1802,9 @@ function showTraefik() {
|
||||
# show Portainer menu
|
||||
function showPortainer() {
|
||||
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." \
|
||||
"2)" "Setup Portainer" \
|
||||
"3)" "Enable Portainer" \
|
||||
@ -1809,7 +1828,9 @@ function showPortainer() {
|
||||
function mainMenu() {
|
||||
while true; do
|
||||
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" \
|
||||
"2)" "Openssh containers" \
|
||||
"3)" "Traefik container" \
|
||||
@ -2011,6 +2032,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
|
||||
@ -2095,7 +2128,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