dev
This commit is contained in:
parent
69a3d1b4d5
commit
3a88d6853d
114
ct/create_lxc.sh
114
ct/create_lxc.sh
@ -9,26 +9,28 @@
|
|||||||
# This sets verbose mode if the global variable is set to "yes"
|
# This sets verbose mode if the global variable is set to "yes"
|
||||||
# if [ "$VERBOSE" == "yes" ]; then set -x; fi
|
# if [ "$VERBOSE" == "yes" ]; then set -x; fi
|
||||||
|
|
||||||
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func)
|
||||||
|
|
||||||
# This function sets color variables for formatting output in the terminal
|
# This function sets color variables for formatting output in the terminal
|
||||||
# Colors
|
# Colors
|
||||||
YW=$(echo "\033[33m")
|
# YW=$(echo "\033[33m")
|
||||||
YWB=$(echo "\033[93m")
|
# YWB=$(echo "\033[93m")
|
||||||
BL=$(echo "\033[36m")
|
# BL=$(echo "\033[36m")
|
||||||
RD=$(echo "\033[01;31m")
|
# RD=$(echo "\033[01;31m")
|
||||||
GN=$(echo "\033[1;92m")
|
# GN=$(echo "\033[1;92m")
|
||||||
|
|
||||||
# Formatting
|
# # Formatting
|
||||||
CL=$(echo "\033[m")
|
# CL=$(echo "\033[m")
|
||||||
UL=$(echo "\033[4m")
|
# UL=$(echo "\033[4m")
|
||||||
BOLD=$(echo "\033[1m")
|
# BOLD=$(echo "\033[1m")
|
||||||
BFR="\\r\\033[K"
|
# BFR="\\r\\033[K"
|
||||||
HOLD=" "
|
# HOLD=" "
|
||||||
TAB=" "
|
# TAB=" "
|
||||||
|
|
||||||
# Icons
|
# # Icons
|
||||||
CM="${TAB}✔️${TAB}${CL}"
|
# CM="${TAB}✔️${TAB}${CL}"
|
||||||
CROSS="${TAB}✖️${TAB}${CL}"
|
# CROSS="${TAB}✖️${TAB}${CL}"
|
||||||
INFO="${TAB}💡${TAB}${CL}"
|
# INFO="${TAB}💡${TAB}${CL}"
|
||||||
|
|
||||||
# This sets error handling options and defines the error_handler function to handle errors
|
# This sets error handling options and defines the error_handler function to handle errors
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
@ -46,52 +48,52 @@ function error_handler() {
|
|||||||
exit 200
|
exit 200
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function displays a spinner.
|
# # This function displays a spinner.
|
||||||
function spinner() {
|
# function spinner() {
|
||||||
local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
|
# local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
|
||||||
local spin_i=0
|
# local spin_i=0
|
||||||
local interval=0.1
|
# local interval=0.1
|
||||||
printf "\e[?25l"
|
# printf "\e[?25l"
|
||||||
|
|
||||||
local color="${YWB}"
|
# local color="${YWB}"
|
||||||
|
|
||||||
while true; do
|
# while true; do
|
||||||
printf "\r ${color}%s${CL}" "${frames[spin_i]}"
|
# printf "\r ${color}%s${CL}" "${frames[spin_i]}"
|
||||||
spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
# spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
||||||
sleep "$interval"
|
# sleep "$interval"
|
||||||
done
|
# done
|
||||||
}
|
# }
|
||||||
|
|
||||||
# This function displays an informational message with a yellow color.
|
# # This function displays an informational message with a yellow color.
|
||||||
function msg_info() {
|
# function msg_info() {
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}"
|
# echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}"
|
||||||
spinner &
|
# spinner &
|
||||||
SPINNER_PID=$!
|
# SPINNER_PID=$!
|
||||||
}
|
# }
|
||||||
|
|
||||||
function msg_warn() {
|
# function msg_warn() {
|
||||||
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi
|
# if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi
|
||||||
printf "\e[?25h"
|
# printf "\e[?25h"
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
echo -e "${BFR}${INFO}${YWB}${msg}${CL}"
|
# echo -e "${BFR}${INFO}${YWB}${msg}${CL}"
|
||||||
}
|
# }
|
||||||
|
|
||||||
# This function displays a success message with a green color.
|
# # This function displays a success message with a green color.
|
||||||
function msg_ok() {
|
# function msg_ok() {
|
||||||
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi
|
# if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi
|
||||||
printf "\e[?25h"
|
# printf "\e[?25h"
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
echo -e "${BFR}${CM}${GN}${msg}${CL}"
|
# echo -e "${BFR}${CM}${GN}${msg}${CL}"
|
||||||
}
|
# }
|
||||||
|
|
||||||
# This function displays a error message with a red color.
|
# # This function displays a error message with a red color.
|
||||||
function msg_error() {
|
# function msg_error() {
|
||||||
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi
|
# if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi
|
||||||
printf "\e[?25h"
|
# printf "\e[?25h"
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
echo -e "${BFR}${CROSS}${RD}${msg}${CL}"
|
# echo -e "${BFR}${CROSS}${RD}${msg}${CL}"
|
||||||
}
|
# }
|
||||||
|
|
||||||
# This checks for the presence of valid Container Storage and Template Storage locations
|
# This checks for the presence of valid Container Storage and Template Storage locations
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
|
205
misc/build.func
205
misc/build.func
@ -15,50 +15,51 @@ variables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func)
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func)
|
||||||
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func)
|
||||||
|
|
||||||
# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
# # This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
||||||
color() {
|
# color() {
|
||||||
# Colors
|
# # Colors
|
||||||
YW=$(echo "\033[33m")
|
# YW=$(echo "\033[33m")
|
||||||
YWB=$(echo "\033[93m")
|
# YWB=$(echo "\033[93m")
|
||||||
BL=$(echo "\033[36m")
|
# BL=$(echo "\033[36m")
|
||||||
RD=$(echo "\033[01;31m")
|
# RD=$(echo "\033[01;31m")
|
||||||
BGN=$(echo "\033[4;92m")
|
# BGN=$(echo "\033[4;92m")
|
||||||
GN=$(echo "\033[1;92m")
|
# GN=$(echo "\033[1;92m")
|
||||||
DGN=$(echo "\033[32m")
|
# DGN=$(echo "\033[32m")
|
||||||
|
|
||||||
# Formatting
|
# # Formatting
|
||||||
CL=$(echo "\033[m")
|
# CL=$(echo "\033[m")
|
||||||
BOLD=$(echo "\033[1m")
|
# BOLD=$(echo "\033[1m")
|
||||||
HOLD=" "
|
# HOLD=" "
|
||||||
TAB=" "
|
# TAB=" "
|
||||||
|
|
||||||
# Icons
|
# # Icons
|
||||||
CM="${TAB}✔️${TAB}"
|
# CM="${TAB}✔️${TAB}"
|
||||||
CROSS="${TAB}✖️${TAB}"
|
# CROSS="${TAB}✖️${TAB}"
|
||||||
INFO="${TAB}💡${TAB}${CL}"
|
# INFO="${TAB}💡${TAB}${CL}"
|
||||||
OS="${TAB}🖥️${TAB}${CL}"
|
# OS="${TAB}🖥️${TAB}${CL}"
|
||||||
OSVERSION="${TAB}🌟${TAB}${CL}"
|
# OSVERSION="${TAB}🌟${TAB}${CL}"
|
||||||
CONTAINERTYPE="${TAB}📦${TAB}${CL}"
|
# CONTAINERTYPE="${TAB}📦${TAB}${CL}"
|
||||||
DISKSIZE="${TAB}💾${TAB}${CL}"
|
# DISKSIZE="${TAB}💾${TAB}${CL}"
|
||||||
CPUCORE="${TAB}🧠${TAB}${CL}"
|
# CPUCORE="${TAB}🧠${TAB}${CL}"
|
||||||
RAMSIZE="${TAB}🛠️${TAB}${CL}"
|
# RAMSIZE="${TAB}🛠️${TAB}${CL}"
|
||||||
SEARCH="${TAB}🔍${TAB}${CL}"
|
# SEARCH="${TAB}🔍${TAB}${CL}"
|
||||||
VERBOSE_CROPPED="🔍${TAB}"
|
# VERBOSE_CROPPED="🔍${TAB}"
|
||||||
VERIFYPW="${TAB}🔐${TAB}${CL}"
|
# VERIFYPW="${TAB}🔐${TAB}${CL}"
|
||||||
CONTAINERID="${TAB}🆔${TAB}${CL}"
|
# CONTAINERID="${TAB}🆔${TAB}${CL}"
|
||||||
HOSTNAME="${TAB}🏠${TAB}${CL}"
|
# HOSTNAME="${TAB}🏠${TAB}${CL}"
|
||||||
BRIDGE="${TAB}🌉${TAB}${CL}"
|
# BRIDGE="${TAB}🌉${TAB}${CL}"
|
||||||
NETWORK="${TAB}📡${TAB}${CL}"
|
# NETWORK="${TAB}📡${TAB}${CL}"
|
||||||
GATEWAY="${TAB}🌐${TAB}${CL}"
|
# GATEWAY="${TAB}🌐${TAB}${CL}"
|
||||||
DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
# DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
||||||
DEFAULT="${TAB}⚙️${TAB}${CL}"
|
# DEFAULT="${TAB}⚙️${TAB}${CL}"
|
||||||
MACADDRESS="${TAB}🔗${TAB}${CL}"
|
# MACADDRESS="${TAB}🔗${TAB}${CL}"
|
||||||
VLANTAG="${TAB}🏷️${TAB}${CL}"
|
# VLANTAG="${TAB}🏷️${TAB}${CL}"
|
||||||
ROOTSSH="${TAB}🔑${TAB}${CL}"
|
# ROOTSSH="${TAB}🔑${TAB}${CL}"
|
||||||
CREATING="${TAB}🚀${TAB}${CL}"
|
# CREATING="${TAB}🚀${TAB}${CL}"
|
||||||
ADVANCED="${TAB}🧩${TAB}${CL}"
|
# ADVANCED="${TAB}🧩${TAB}${CL}"
|
||||||
}
|
# }
|
||||||
|
|
||||||
# This function enables error handling in the script by setting options and defining a trap for the ERR signal.
|
# This function enables error handling in the script by setting options and defining a trap for the ERR signal.
|
||||||
catch_errors() {
|
catch_errors() {
|
||||||
@ -79,78 +80,78 @@ error_handler() {
|
|||||||
echo -e "\n$error_message\n"
|
echo -e "\n$error_message\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function displays an informational message with logging support.
|
# # This function displays an informational message with logging support.
|
||||||
declare -A MSG_INFO_SHOWN
|
# declare -A MSG_INFO_SHOWN
|
||||||
SPINNER_ACTIVE=0
|
# SPINNER_ACTIVE=0
|
||||||
SPINNER_PID=""
|
# SPINNER_PID=""
|
||||||
SPINNER_MSG=""
|
# SPINNER_MSG=""
|
||||||
|
|
||||||
trap 'stop_spinner' EXIT INT TERM HUP
|
# trap 'stop_spinner' EXIT INT TERM HUP
|
||||||
|
|
||||||
start_spinner() {
|
# start_spinner() {
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
|
# local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
|
||||||
local spin_i=0
|
# local spin_i=0
|
||||||
local interval=0.1
|
# local interval=0.1
|
||||||
|
|
||||||
SPINNER_MSG="$msg"
|
# SPINNER_MSG="$msg"
|
||||||
printf "\r\e[2K" >&2
|
# printf "\r\e[2K" >&2
|
||||||
|
|
||||||
{
|
# {
|
||||||
while [[ "$SPINNER_ACTIVE" -eq 1 ]]; do
|
# while [[ "$SPINNER_ACTIVE" -eq 1 ]]; do
|
||||||
printf "\r\e[2K%s %b" "${frames[spin_i]}" "${YW}${SPINNER_MSG}${CL}" >&2
|
# printf "\r\e[2K%s %b" "${frames[spin_i]}" "${YW}${SPINNER_MSG}${CL}" >&2
|
||||||
spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
# spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
||||||
sleep "$interval"
|
# sleep "$interval"
|
||||||
done
|
# done
|
||||||
} &
|
# } &
|
||||||
|
|
||||||
SPINNER_PID=$!
|
# SPINNER_PID=$!
|
||||||
disown "$SPINNER_PID"
|
# disown "$SPINNER_PID"
|
||||||
}
|
# }
|
||||||
|
|
||||||
stop_spinner() {
|
# stop_spinner() {
|
||||||
if [[ ${SPINNER_PID+v} && -n "$SPINNER_PID" ]] && kill -0 "$SPINNER_PID" 2>/dev/null; then
|
# if [[ ${SPINNER_PID+v} && -n "$SPINNER_PID" ]] && kill -0 "$SPINNER_PID" 2>/dev/null; then
|
||||||
kill "$SPINNER_PID" 2>/dev/null
|
# kill "$SPINNER_PID" 2>/dev/null
|
||||||
sleep 0.1
|
# sleep 0.1
|
||||||
kill -0 "$SPINNER_PID" 2>/dev/null && kill -9 "$SPINNER_PID" 2>/dev/null
|
# kill -0 "$SPINNER_PID" 2>/dev/null && kill -9 "$SPINNER_PID" 2>/dev/null
|
||||||
wait "$SPINNER_PID" 2>/dev/null || true
|
# wait "$SPINNER_PID" 2>/dev/null || true
|
||||||
fi
|
# fi
|
||||||
SPINNER_ACTIVE=0
|
# SPINNER_ACTIVE=0
|
||||||
unset SPINNER_PID
|
# unset SPINNER_PID
|
||||||
}
|
# }
|
||||||
|
|
||||||
spinner_guard() {
|
# spinner_guard() {
|
||||||
if [[ "$SPINNER_ACTIVE" -eq 1 ]] && [[ -n "$SPINNER_PID" ]]; then
|
# if [[ "$SPINNER_ACTIVE" -eq 1 ]] && [[ -n "$SPINNER_PID" ]]; then
|
||||||
kill "$SPINNER_PID" 2>/dev/null
|
# kill "$SPINNER_PID" 2>/dev/null
|
||||||
wait "$SPINNER_PID" 2>/dev/null || true
|
# wait "$SPINNER_PID" 2>/dev/null || true
|
||||||
SPINNER_ACTIVE=0
|
# SPINNER_ACTIVE=0
|
||||||
unset SPINNER_PID
|
# unset SPINNER_PID
|
||||||
fi
|
# fi
|
||||||
}
|
# }
|
||||||
|
|
||||||
msg_info() {
|
# msg_info() {
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
[[ -n "${MSG_INFO_SHOWN["$msg"]+x}" ]] && return
|
# [[ -n "${MSG_INFO_SHOWN["$msg"]+x}" ]] && return
|
||||||
MSG_INFO_SHOWN["$msg"]=1
|
# MSG_INFO_SHOWN["$msg"]=1
|
||||||
|
|
||||||
spinner_guard
|
# spinner_guard
|
||||||
SPINNER_ACTIVE=1
|
# SPINNER_ACTIVE=1
|
||||||
start_spinner "$msg"
|
# start_spinner "$msg"
|
||||||
}
|
# }
|
||||||
|
|
||||||
msg_ok() {
|
# msg_ok() {
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
stop_spinner
|
# stop_spinner
|
||||||
printf "\r\e[2K%s %b\n" "${CM}" "${GN}${msg}${CL}" >&2
|
# printf "\r\e[2K%s %b\n" "${CM}" "${GN}${msg}${CL}" >&2
|
||||||
unset MSG_INFO_SHOWN["$msg"]
|
# unset MSG_INFO_SHOWN["$msg"]
|
||||||
}
|
# }
|
||||||
|
|
||||||
msg_error() {
|
# msg_error() {
|
||||||
stop_spinner
|
# stop_spinner
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2
|
# printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2
|
||||||
#log_message "ERROR" "$msg"
|
# #log_message "ERROR" "$msg"
|
||||||
}
|
# }
|
||||||
|
|
||||||
# log_message() {
|
# log_message() {
|
||||||
# local level="$1"
|
# local level="$1"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2021-2025 community-scripts ORG
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
# Author: michelroegl-brunner
|
|
||||||
# License: MIT | https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/LICENSE
|
# License: MIT | https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/LICENSE
|
||||||
|
|
||||||
|
# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
||||||
color() {
|
color() {
|
||||||
# Colors
|
# Colors
|
||||||
YW=$(echo "\033[33m")
|
YW=$(echo "\033[33m")
|
||||||
@ -20,7 +20,7 @@ color() {
|
|||||||
|
|
||||||
# Icons
|
# Icons
|
||||||
CM="${TAB}✔️${TAB}"
|
CM="${TAB}✔️${TAB}"
|
||||||
CROSS="${TAB}✖️${TAB}${CL}"
|
CROSS="${TAB}✖️${TAB}"
|
||||||
INFO="${TAB}💡${TAB}${CL}"
|
INFO="${TAB}💡${TAB}${CL}"
|
||||||
OS="${TAB}🖥️${TAB}${CL}"
|
OS="${TAB}🖥️${TAB}${CL}"
|
||||||
OSVERSION="${TAB}🌟${TAB}${CL}"
|
OSVERSION="${TAB}🌟${TAB}${CL}"
|
||||||
@ -43,14 +43,16 @@ color() {
|
|||||||
ROOTSSH="${TAB}🔑${TAB}${CL}"
|
ROOTSSH="${TAB}🔑${TAB}${CL}"
|
||||||
CREATING="${TAB}🚀${TAB}${CL}"
|
CREATING="${TAB}🚀${TAB}${CL}"
|
||||||
ADVANCED="${TAB}🧩${TAB}${CL}"
|
ADVANCED="${TAB}🧩${TAB}${CL}"
|
||||||
FUSE="${TAB}🔧${TAB}${CL}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function displays an informational message with logging support.
|
||||||
declare -A MSG_INFO_SHOWN
|
declare -A MSG_INFO_SHOWN
|
||||||
SPINNER_ACTIVE=0
|
SPINNER_ACTIVE=0
|
||||||
SPINNER_PID=""
|
SPINNER_PID=""
|
||||||
SPINNER_MSG=""
|
SPINNER_MSG=""
|
||||||
|
|
||||||
|
trap 'stop_spinner' EXIT INT TERM HUP
|
||||||
|
|
||||||
start_spinner() {
|
start_spinner() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
|
local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
|
||||||
@ -92,56 +94,27 @@ spinner_guard() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message() {
|
|
||||||
local level="$1"
|
|
||||||
local message="$2"
|
|
||||||
local timestamp
|
|
||||||
local logdate
|
|
||||||
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
|
||||||
logdate=$(date '+%Y-%m-%d')
|
|
||||||
|
|
||||||
LOGDIR="/usr/local/community-scripts/logs"
|
|
||||||
mkdir -p "$LOGDIR"
|
|
||||||
|
|
||||||
LOGFILE="${LOGDIR}/${logdate}_${NSAPP}.log"
|
|
||||||
echo "$timestamp - $level: $message" >>"$LOGFILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_info() {
|
msg_info() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
if [ "${SPINNER_ACTIVE:-0}" -eq 1 ]; then
|
[[ -n "${MSG_INFO_SHOWN["$msg"]+x}" ]] && return
|
||||||
return
|
MSG_INFO_SHOWN["$msg"]=1
|
||||||
fi
|
|
||||||
|
|
||||||
|
spinner_guard
|
||||||
SPINNER_ACTIVE=1
|
SPINNER_ACTIVE=1
|
||||||
start_spinner "$msg"
|
start_spinner "$msg"
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_ok() {
|
msg_ok() {
|
||||||
if [ -n "${SPINNER_PID:-}" ] && ps -p "$SPINNER_PID" >/dev/null 2>&1; then
|
|
||||||
kill "$SPINNER_PID" >/dev/null 2>&1
|
|
||||||
wait "$SPINNER_PID" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
printf "\r\e[2K${CM}${GN}%b${CL}\n" "$msg" >&2
|
stop_spinner
|
||||||
unset SPINNER_PID
|
printf "\r\e[2K%s %b\n" "${CM}" "${GN}${msg}${CL}" >&2
|
||||||
SPINNER_ACTIVE=0
|
unset MSG_INFO_SHOWN["$msg"]
|
||||||
|
|
||||||
log_message "OK" "$msg"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_error() {
|
msg_error() {
|
||||||
if [ -n "${SPINNER_PID:-}" ] && ps -p "$SPINNER_PID" >/dev/null 2>&1; then
|
stop_spinner
|
||||||
kill "$SPINNER_PID" >/dev/null 2>&1
|
|
||||||
wait "$SPINNER_PID" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
printf "\r\e[2K${CROSS}${RD}%b${CL}\n" "$msg" >&2
|
printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2
|
||||||
unset SPINNER_PID
|
|
||||||
SPINNER_ACTIVE=0
|
|
||||||
log_message "ERROR" "$msg"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shell_check() {
|
shell_check() {
|
||||||
|
220
misc/core.func.bak
Normal file
220
misc/core.func.bak
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
|
# Author: michelroegl-brunner
|
||||||
|
# License: MIT | https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/LICENSE
|
||||||
|
|
||||||
|
color() {
|
||||||
|
# Colors
|
||||||
|
YW=$(echo "\033[33m")
|
||||||
|
YWB=$(echo "\033[93m")
|
||||||
|
BL=$(echo "\033[36m")
|
||||||
|
RD=$(echo "\033[01;31m")
|
||||||
|
BGN=$(echo "\033[4;92m")
|
||||||
|
GN=$(echo "\033[1;92m")
|
||||||
|
DGN=$(echo "\033[32m")
|
||||||
|
|
||||||
|
# Formatting
|
||||||
|
CL=$(echo "\033[m")
|
||||||
|
BOLD=$(echo "\033[1m")
|
||||||
|
HOLD=" "
|
||||||
|
TAB=" "
|
||||||
|
|
||||||
|
# Icons
|
||||||
|
CM="${TAB}✔️${TAB}"
|
||||||
|
CROSS="${TAB}✖️${TAB}${CL}"
|
||||||
|
INFO="${TAB}💡${TAB}${CL}"
|
||||||
|
OS="${TAB}🖥️${TAB}${CL}"
|
||||||
|
OSVERSION="${TAB}🌟${TAB}${CL}"
|
||||||
|
CONTAINERTYPE="${TAB}📦${TAB}${CL}"
|
||||||
|
DISKSIZE="${TAB}💾${TAB}${CL}"
|
||||||
|
CPUCORE="${TAB}🧠${TAB}${CL}"
|
||||||
|
RAMSIZE="${TAB}🛠️${TAB}${CL}"
|
||||||
|
SEARCH="${TAB}🔍${TAB}${CL}"
|
||||||
|
VERBOSE_CROPPED="🔍${TAB}"
|
||||||
|
VERIFYPW="${TAB}🔐${TAB}${CL}"
|
||||||
|
CONTAINERID="${TAB}🆔${TAB}${CL}"
|
||||||
|
HOSTNAME="${TAB}🏠${TAB}${CL}"
|
||||||
|
BRIDGE="${TAB}🌉${TAB}${CL}"
|
||||||
|
NETWORK="${TAB}📡${TAB}${CL}"
|
||||||
|
GATEWAY="${TAB}🌐${TAB}${CL}"
|
||||||
|
DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
||||||
|
DEFAULT="${TAB}⚙️${TAB}${CL}"
|
||||||
|
MACADDRESS="${TAB}🔗${TAB}${CL}"
|
||||||
|
VLANTAG="${TAB}🏷️${TAB}${CL}"
|
||||||
|
ROOTSSH="${TAB}🔑${TAB}${CL}"
|
||||||
|
CREATING="${TAB}🚀${TAB}${CL}"
|
||||||
|
ADVANCED="${TAB}🧩${TAB}${CL}"
|
||||||
|
FUSE="${TAB}🔧${TAB}${CL}"
|
||||||
|
}
|
||||||
|
|
||||||
|
declare -A MSG_INFO_SHOWN
|
||||||
|
SPINNER_ACTIVE=0
|
||||||
|
SPINNER_PID=""
|
||||||
|
SPINNER_MSG=""
|
||||||
|
|
||||||
|
start_spinner() {
|
||||||
|
local msg="$1"
|
||||||
|
local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
|
||||||
|
local spin_i=0
|
||||||
|
local interval=0.1
|
||||||
|
|
||||||
|
SPINNER_MSG="$msg"
|
||||||
|
printf "\r\e[2K" >&2
|
||||||
|
|
||||||
|
{
|
||||||
|
while [[ "$SPINNER_ACTIVE" -eq 1 ]]; do
|
||||||
|
printf "\r\e[2K%s %b" "${frames[spin_i]}" "${YW}${SPINNER_MSG}${CL}" >&2
|
||||||
|
spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
||||||
|
sleep "$interval"
|
||||||
|
done
|
||||||
|
} &
|
||||||
|
|
||||||
|
SPINNER_PID=$!
|
||||||
|
disown "$SPINNER_PID"
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_spinner() {
|
||||||
|
if [[ ${SPINNER_PID+v} && -n "$SPINNER_PID" ]] && kill -0 "$SPINNER_PID" 2>/dev/null; then
|
||||||
|
kill "$SPINNER_PID" 2>/dev/null
|
||||||
|
sleep 0.1
|
||||||
|
kill -0 "$SPINNER_PID" 2>/dev/null && kill -9 "$SPINNER_PID" 2>/dev/null
|
||||||
|
wait "$SPINNER_PID" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
SPINNER_ACTIVE=0
|
||||||
|
unset SPINNER_PID
|
||||||
|
}
|
||||||
|
|
||||||
|
spinner_guard() {
|
||||||
|
if [[ "$SPINNER_ACTIVE" -eq 1 ]] && [[ -n "$SPINNER_PID" ]]; then
|
||||||
|
kill "$SPINNER_PID" 2>/dev/null
|
||||||
|
wait "$SPINNER_PID" 2>/dev/null || true
|
||||||
|
SPINNER_ACTIVE=0
|
||||||
|
unset SPINNER_PID
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message() {
|
||||||
|
local level="$1"
|
||||||
|
local message="$2"
|
||||||
|
local timestamp
|
||||||
|
local logdate
|
||||||
|
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
|
logdate=$(date '+%Y-%m-%d')
|
||||||
|
|
||||||
|
LOGDIR="/usr/local/community-scripts/logs"
|
||||||
|
mkdir -p "$LOGDIR"
|
||||||
|
|
||||||
|
LOGFILE="${LOGDIR}/${logdate}_${NSAPP}.log"
|
||||||
|
echo "$timestamp - $level: $message" >>"$LOGFILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_info() {
|
||||||
|
local msg="$1"
|
||||||
|
if [ "${SPINNER_ACTIVE:-0}" -eq 1 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
SPINNER_ACTIVE=1
|
||||||
|
start_spinner "$msg"
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_ok() {
|
||||||
|
if [ -n "${SPINNER_PID:-}" ] && ps -p "$SPINNER_PID" >/dev/null 2>&1; then
|
||||||
|
kill "$SPINNER_PID" >/dev/null 2>&1
|
||||||
|
wait "$SPINNER_PID" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
local msg="$1"
|
||||||
|
printf "\r\e[2K${CM}${GN}%b${CL}\n" "$msg" >&2
|
||||||
|
unset SPINNER_PID
|
||||||
|
SPINNER_ACTIVE=0
|
||||||
|
|
||||||
|
log_message "OK" "$msg"
|
||||||
|
}
|
||||||
|
|
||||||
|
msg_error() {
|
||||||
|
if [ -n "${SPINNER_PID:-}" ] && ps -p "$SPINNER_PID" >/dev/null 2>&1; then
|
||||||
|
kill "$SPINNER_PID" >/dev/null 2>&1
|
||||||
|
wait "$SPINNER_PID" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
local msg="$1"
|
||||||
|
printf "\r\e[2K${CROSS}${RD}%b${CL}\n" "$msg" >&2
|
||||||
|
unset SPINNER_PID
|
||||||
|
SPINNER_ACTIVE=0
|
||||||
|
log_message "ERROR" "$msg"
|
||||||
|
}
|
||||||
|
|
||||||
|
shell_check() {
|
||||||
|
if [[ "$(basename "$SHELL")" != "bash" ]]; then
|
||||||
|
clear
|
||||||
|
msg_error "Your default shell is currently not set to Bash. To use these scripts, please switch to the Bash shell."
|
||||||
|
echo -e "\nExiting..."
|
||||||
|
sleep 2
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
root_check() {
|
||||||
|
if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then
|
||||||
|
clear
|
||||||
|
msg_error "Please run this script as root."
|
||||||
|
echo -e "\nExiting..."
|
||||||
|
sleep 2
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
pve_check() {
|
||||||
|
if ! pveversion | grep -Eq "pve-manager/8\.[1-9](\.[0-9]+)*"; then
|
||||||
|
msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported"
|
||||||
|
echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
|
||||||
|
echo -e "Exiting..."
|
||||||
|
sleep 2
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
arch_check() {
|
||||||
|
if [ "$(dpkg --print-architecture)" != "amd64" ]; then
|
||||||
|
echo -e "\n ${INFO}${YWB}This script will not work with PiMox! \n"
|
||||||
|
echo -e "\n ${YWB}Visit https://github.com/asylumexp/Proxmox for ARM64 support. \n"
|
||||||
|
echo -e "Exiting..."
|
||||||
|
sleep 2
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh_check() {
|
||||||
|
if command -v pveversion >/dev/null 2>&1; then
|
||||||
|
if [ -n "${SSH_CLIENT:+x}" ]; then
|
||||||
|
if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then
|
||||||
|
echo "you've been warned"
|
||||||
|
else
|
||||||
|
clear
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
exit-script() {
|
||||||
|
clear
|
||||||
|
echo -e "\n${CROSS}${RD}User exited script${CL}\n"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
set_std_mode() {
|
||||||
|
if [ "$VERB" = "yes" ]; then
|
||||||
|
STD=""
|
||||||
|
else
|
||||||
|
STD="silent"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
silent() {
|
||||||
|
if [ "$VERB" = "no" ]; then
|
||||||
|
"$@" >>"$LOGFILE" 2>&1
|
||||||
|
else
|
||||||
|
"$@" 2>&1 | tee -a "$LOGFILE"
|
||||||
|
fi
|
||||||
|
}
|
@ -5,36 +5,38 @@
|
|||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
# https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
||||||
|
|
||||||
color() {
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func)
|
||||||
# Colors
|
|
||||||
YW=$(echo "\033[33m")
|
|
||||||
YWB=$(echo "\033[93m")
|
|
||||||
BL=$(echo "\033[36m")
|
|
||||||
RD=$(echo "\033[01;31m")
|
|
||||||
GN=$(echo "\033[1;92m")
|
|
||||||
|
|
||||||
# Formatting
|
# color() {
|
||||||
CL=$(echo "\033[m")
|
# # Colors
|
||||||
BFR="\\r\\033[K"
|
# YW=$(echo "\033[33m")
|
||||||
BOLD=$(echo "\033[1m")
|
# YWB=$(echo "\033[93m")
|
||||||
HOLD=" "
|
# BL=$(echo "\033[36m")
|
||||||
TAB=" "
|
# RD=$(echo "\033[01;31m")
|
||||||
|
# GN=$(echo "\033[1;92m")
|
||||||
|
|
||||||
# System
|
# # Formatting
|
||||||
RETRY_NUM=10
|
# CL=$(echo "\033[m")
|
||||||
RETRY_EVERY=3
|
# BFR="\\r\\033[K"
|
||||||
|
# BOLD=$(echo "\033[1m")
|
||||||
|
# HOLD=" "
|
||||||
|
# TAB=" "
|
||||||
|
|
||||||
# Icons
|
# # System
|
||||||
CM="${TAB}✔️${TAB}${CL}"
|
# RETRY_NUM=10
|
||||||
CROSS="${TAB}✖️${TAB}${CL}"
|
# RETRY_EVERY=3
|
||||||
INFO="${TAB}💡${TAB}${CL}"
|
|
||||||
NETWORK="${TAB}📡${TAB}${CL}"
|
# # Icons
|
||||||
OS="${TAB}🖥️${TAB}${CL}"
|
# CM="${TAB}✔️${TAB}${CL}"
|
||||||
OSVERSION="${TAB}🌟${TAB}${CL}"
|
# CROSS="${TAB}✖️${TAB}${CL}"
|
||||||
HOSTNAME="${TAB}🏠${TAB}${CL}"
|
# INFO="${TAB}💡${TAB}${CL}"
|
||||||
GATEWAY="${TAB}🌐${TAB}${CL}"
|
# NETWORK="${TAB}📡${TAB}${CL}"
|
||||||
DEFAULT="${TAB}⚙️${TAB}${CL}"
|
# OS="${TAB}🖥️${TAB}${CL}"
|
||||||
}
|
# OSVERSION="${TAB}🌟${TAB}${CL}"
|
||||||
|
# HOSTNAME="${TAB}🏠${TAB}${CL}"
|
||||||
|
# GATEWAY="${TAB}🌐${TAB}${CL}"
|
||||||
|
# DEFAULT="${TAB}⚙️${TAB}${CL}"
|
||||||
|
# }
|
||||||
|
|
||||||
# Function to set STD mode based on verbosity
|
# Function to set STD mode based on verbosity
|
||||||
set_std_mode() {
|
set_std_mode() {
|
||||||
@ -86,45 +88,46 @@ error_handler() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function displays a spinner.
|
# # This function displays a spinner.
|
||||||
spinner() {
|
# spinner() {
|
||||||
local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
|
# local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
|
||||||
local spin_i=0
|
# local spin_i=0
|
||||||
local interval=0.1
|
# local interval=0.1
|
||||||
printf "\e[?25l"
|
# printf "\e[?25l"
|
||||||
|
|
||||||
local color="${YWB}"
|
# local color="${YWB}"
|
||||||
|
|
||||||
while true; do
|
# while true; do
|
||||||
printf "\r ${color}%s${CL}" "${frames[spin_i]}"
|
# printf "\r ${color}%s${CL}" "${frames[spin_i]}"
|
||||||
spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
# spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
||||||
sleep "$interval"
|
# sleep "$interval"
|
||||||
done
|
# done
|
||||||
}
|
# }
|
||||||
|
|
||||||
# This function displays an informational message with a yellow color.
|
# # This function displays an informational message with a yellow color.
|
||||||
msg_info() {
|
# msg_info() {
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}"
|
# echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}"
|
||||||
spinner &
|
# spinner &
|
||||||
SPINNER_PID=$!
|
# SPINNER_PID=$!
|
||||||
}
|
# }
|
||||||
|
|
||||||
# This function displays a success message with a green color.
|
# # This function displays a success message with a green color.
|
||||||
msg_ok() {
|
# msg_ok() {
|
||||||
if [ -n "$SPINNER_PID" ] && ps -p "$SPINNER_PID" >/dev/null; then kill "$SPINNER_PID" >/dev/null; fi
|
# if [ -n "$SPINNER_PID" ] && ps -p "$SPINNER_PID" >/dev/null; then kill "$SPINNER_PID" >/dev/null; fi
|
||||||
printf "\e[?25h"
|
# printf "\e[?25h"
|
||||||
local msg="$1"
|
# local msg="$1"
|
||||||
echo -e "${BFR}${CM}${GN}${msg}${CL}"
|
# echo -e "${BFR}${CM}${GN}${msg}${CL}"
|
||||||
}
|
# }
|
||||||
|
|
||||||
|
# # This function displays a error message with a red color.
|
||||||
|
# msg_error() {
|
||||||
|
# if [ -n "$SPINNER_PID" ] && ps -p "$SPINNER_PID" >/dev/null; then kill "$SPINNER_PID" >/dev/null; fi
|
||||||
|
# printf "\e[?25h"
|
||||||
|
# local msg="$1"
|
||||||
|
# echo -e "${BFR}${CROSS}${RD}${msg}${CL}"
|
||||||
|
# }
|
||||||
|
|
||||||
# This function displays a error message with a red color.
|
|
||||||
msg_error() {
|
|
||||||
if [ -n "$SPINNER_PID" ] && ps -p "$SPINNER_PID" >/dev/null; then kill "$SPINNER_PID" >/dev/null; fi
|
|
||||||
printf "\e[?25h"
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR}${CROSS}${RD}${msg}${CL}"
|
|
||||||
}
|
|
||||||
# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection
|
# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection
|
||||||
setting_up_container() {
|
setting_up_container() {
|
||||||
msg_info "Setting up Container OS"
|
msg_info "Setting up Container OS"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user