@@ -7,6 +7,7 @@ variables() {
77# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
88color() {
99 YW=$(echo "\033[33m")
10+ YWB=$(echo "\033[93m")
1011 BL=$(echo "\033[36m")
1112 RD=$(echo "\033[01;31m")
1213 BGN=$(echo "\033[4;92m")
@@ -501,6 +502,41 @@ install_script() {
501502 fi
502503}
503504
505+ check_container_ressources() {
506+ local required_ram="$var_ram" # Expected RAM in MB
507+ local required_cpu="$var_cpu" # Expected number of Cores
508+ local app_name="${APP}" # Name of App
509+
510+ # Check actual RAM & Cores
511+ local current_ram
512+ current_ram=$(free -m | awk '/^Mem:/{print $2}')
513+ current_cpu=$(nproc)
514+
515+ # Check whether the current RAM is less than the required RAM or the CPU cores are less than required
516+ if [[ "$current_ram" -lt "$required_ram" ]] || [[ "$current_cpu" -lt "$required_cpu" ]]; then
517+ echo -e "\n⚠️${HOLD} ${GN}Required: ${required_cpu} CPU, ${required_ram}MB RAM ${CL}| ${RD}Current: ${current_cpu} CPU, ${current_ram}MB RAM${CL}"
518+ echo -e "${YWB}Please ensure that the ${app_name} LXC is configured with at least ${var_cpu} vCPU and ${var_ram} MB RAM for the build process.${CL}\n"
519+ exit 1
520+ else
521+ echo -e ""
522+ fi
523+ }
524+
525+ check_storage() {
526+ # Check if the /boot partition is more than 80% full
527+ if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then
528+ # Prompt the user for confirmation to continue
529+ echo -e "⚠️${HOLD} ${YWB}Warning: Storage is dangerously low.${CL}"
530+ echo -e "Continue anyway? <y/N>${CL}"
531+ read -r -p "" prompt
532+ # Check if the input is 'y' or 'yes', otherwise exit with status 1
533+ if [[ ! ${prompt,,} =~ ^(y|yes)$ ]]; then
534+ echo -e "❌${HOLD} ${YWB}Exiting based on incorrect user input.${CL}"
535+ exit 1
536+ fi
537+ fi
538+ }
539+
504540start() {
505541 if command -v pveversion >/dev/null 2>&1; then
506542 if ! (whiptail --backtitle "Proxmox VE Helper Scripts" --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
0 commit comments