From c4769c0ca93f45d97ed66110d543969956f1242a Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 11 Mar 2025 16:05:32 +0100 Subject: [PATCH 1/2] Add ipv6 --- misc/build.func | 73 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/misc/build.func b/misc/build.func index bd55da0..510ed6a 100644 --- a/misc/build.func +++ b/misc/build.func @@ -2,7 +2,7 @@ # Author: tteck (tteckster) # Co-Author: MickLesk # Co-Author: michelroegl-brunner -# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE variables() { NSAPP=$(echo ${APP,,} | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces. @@ -14,7 +14,7 @@ variables() { RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # generates a random UUID and sets it to the RANDOM_UUID variable. } -source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) # This function sets various color variables using ANSI escape codes for formatting text in the terminal. color() { @@ -69,7 +69,7 @@ catch_errors() { # This function is called when an error occurs. It receives the exit code, line number, and command that caused the error, and displays an error message. error_handler() { - source /dev/stdin <<<$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) + source /dev/stdin <<<$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi printf "\e[?25h" local exit_code="$?" @@ -274,7 +274,7 @@ update_motd_ip() { # Function to download & save header files get_header() { local app_name=$(echo ${APP,,} | tr -d ' ') - local header_url="https://github.com/community-scripts/ProxmoxVED/raw/main/ct/headers/${app_name}" + local header_url="https://github.com/community-scripts/ProxmoxVE/raw/main/ct/headers/${app_name}" local local_header_path="/usr/local/community-scripts/headers/${app_name}" mkdir -p "/usr/local/community-scripts/headers" @@ -333,6 +333,7 @@ base_settings() { HN=$NSAPP BRG="vmbr0" NET="dhcp" + IPv6="auto" GATE="" APT_CACHER="" APT_CACHER_IP="" @@ -711,7 +712,25 @@ advanced_settings() { if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then DISABLEIP6="yes" else + IPv6="auto" DISABLEIP6="no" + if IP6=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "IPv6" --inputbox "Enter IPv6 Address (Default SLAAC)" 10 58); then + IPv6=$IP6 + echo -e "${NETWORK}${BOLD}${DGN}IPv6 Address: ${BGN}$IPv6${CL}" + if IP6GW=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Enter IPv6 Gateway" 8 58 --title "IPv6 Gateway" 3>&1 1>&2 2>&3); then + if [ -z $IP6GW ]; then + IP6GW="Default" + echo -e "${GATEWAY}${BOLD}${DGN}IPv6 Gateway: ${BGN}$IP6GW${CL}" + else + IPv6GW=",gw6=$IP6GW" + echo -e "${GATEWAY}${BOLD}${DGN}IPv6 Gateway: ${BGN}$IP6GW${CL}" + fi + else + exit_script + fi + else + IPv6="auto" + fi fi echo -e "${DISABLEIPV6}${BOLD}${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" @@ -837,9 +856,9 @@ diagnostics_check() { DIAGNOSTICS=yes #This file is used to store the diagnostics settings for the Community-Scripts API. -#https://github.com/community-scripts/ProxmoxVED/discussions/1836 +#https://github.com/community-scripts/ProxmoxVE/discussions/1836 #Your diagnostics will be sent to the Community-Scripts API for troubleshooting/statistical purposes. -#You can review the data at https://community-scripts.github.io/ProxmoxVED/data +#You can review the data at https://community-scripts.github.io/ProxmoxVE/data #If you do not wish to send diagnostics, please set the variable 'DIAGNOSTICS' to "no" in /usr/local/community-scripts/diagnostics, or use the menue. #This will disable the diagnostics feature. #To send diagnostics, set the variable 'DIAGNOSTICS' to "yes" in /usr/local/community-scripts/diagnostics, or use the menue. @@ -864,9 +883,9 @@ EOF DIAGNOSTICS=no #This file is used to store the diagnostics settings for the Community-Scripts API. -#https://github.com/community-scripts/ProxmoxVED/discussions/1836 +#https://github.com/community-scripts/ProxmoxVE/discussions/1836 #Your diagnostics will be sent to the Community-Scripts API for troubleshooting/statistical purposes. -#You can review the data at https://community-scripts.github.io/ProxmoxVED/data +#You can review the data at https://community-scripts.github.io/ProxmoxVE/data #If you do not wish to send diagnostics, please set the variable 'DIAGNOSTICS' to "no" in /usr/local/community-scripts/diagnostics, or use the menue. #This will disable the diagnostics feature. #To send diagnostics, set the variable 'DIAGNOSTICS' to "yes" in /usr/local/community-scripts/diagnostics, or use the menue. @@ -1082,9 +1101,9 @@ build_container() { TEMP_DIR=$(mktemp -d) pushd $TEMP_DIR >/dev/null if [ "$var_os" == "alpine" ]; then - export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/alpine-install.func)" + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/alpine-install.func)" else - export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/install.func)" + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/install.func)" fi export RANDOM_UUID="$RANDOM_UUID" export CACHER="$APT_CACHER" @@ -1102,7 +1121,9 @@ build_container() { export PCT_OSTYPE="$var_os" export PCT_OSVERSION="$var_version" export PCT_DISK_SIZE="$DISK_SIZE" - export PCT_OPTIONS=" + export IPv6="$IPv6" + if [[ DISABLEIP6 == "yes" ]]; then + export PCT_OPTIONS=" -features $FEATURES -hostname $HN -tags $TAGS @@ -1115,8 +1136,24 @@ build_container() { -unprivileged $CT_TYPE $PW " + else + export PCT_OPTIONS=" + -features $FEATURES + -hostname $HN + -tags $TAGS + $SD + $NS + -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU,ip6=$IPv6$IPv6GW + -onboot 1 + -cores $CORE_COUNT + -memory $RAM_SIZE + -unprivileged $CT_TYPE + $PW + " + fi + # This executes create_lxc.sh and creates the container and .conf file - bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/ct/create_lxc.sh)" || exit $? + bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/create_lxc.sh)" || exit $? LXC_CONFIG=/etc/pve/lxc/${CTID}.conf if [ "$CT_TYPE" == "0" ]; then @@ -1178,7 +1215,7 @@ http://dl-cdn.alpinelinux.org/alpine/latest-stable/community EOF' pct exec "$CTID" -- ash -c "apk add bash >/dev/null" fi - lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/$var_install.sh)" || exit $? + lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/$var_install.sh)" || exit $? } @@ -1191,7 +1228,7 @@ description() { cat < - Logo + Logo

${APP} LXC

@@ -1201,18 +1238,18 @@ description() { spend Coffee

- + GitHub - Discussions + Discussions - Issues + Issues EOF @@ -1250,7 +1287,7 @@ exit_script() { #200 exit codes indicate error in create_lxc.sh #100 exit codes indicate error in install.func - if [ $exit_code -ne 0 ]; then + if [ $exit_code -ne 0 ]; then case $exit_code in 100) post_update_to_api "failed" "100: Unexpected error in create_lxc.sh" ;; 101) post_update_to_api "failed" "101: No network connection detected in create_lxc.sh" ;; From 2449c9826688ce8d1030de98d66a5e337ab19a2b Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Tue, 11 Mar 2025 16:09:43 +0100 Subject: [PATCH 2/2] ipv6 --- misc/build.func | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/misc/build.func b/misc/build.func index 510ed6a..f67673e 100644 --- a/misc/build.func +++ b/misc/build.func @@ -14,7 +14,7 @@ variables() { RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # generates a random UUID and sets it to the RANDOM_UUID variable. } -source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) # This function sets various color variables using ANSI escape codes for formatting text in the terminal. color() { @@ -69,7 +69,7 @@ catch_errors() { # This function is called when an error occurs. It receives the exit code, line number, and command that caused the error, and displays an error message. error_handler() { - source /dev/stdin <<<$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) + source /dev/stdin <<<$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi printf "\e[?25h" local exit_code="$?" @@ -274,7 +274,7 @@ update_motd_ip() { # Function to download & save header files get_header() { local app_name=$(echo ${APP,,} | tr -d ' ') - local header_url="https://github.com/community-scripts/ProxmoxVE/raw/main/ct/headers/${app_name}" + local header_url="https://github.com/community-scripts/ProxmoxVED/raw/main/ct/headers/${app_name}" local local_header_path="/usr/local/community-scripts/headers/${app_name}" mkdir -p "/usr/local/community-scripts/headers" @@ -1101,9 +1101,9 @@ build_container() { TEMP_DIR=$(mktemp -d) pushd $TEMP_DIR >/dev/null if [ "$var_os" == "alpine" ]; then - export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/alpine-install.func)" + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/alpine-install.func)" else - export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/install.func)" + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/install.func)" fi export RANDOM_UUID="$RANDOM_UUID" export CACHER="$APT_CACHER" @@ -1153,7 +1153,7 @@ build_container() { fi # This executes create_lxc.sh and creates the container and .conf file - bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/create_lxc.sh)" || exit $? + bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/ct/create_lxc.sh)" || exit $? LXC_CONFIG=/etc/pve/lxc/${CTID}.conf if [ "$CT_TYPE" == "0" ]; then @@ -1215,7 +1215,7 @@ http://dl-cdn.alpinelinux.org/alpine/latest-stable/community EOF' pct exec "$CTID" -- ash -c "apk add bash >/dev/null" fi - lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/$var_install.sh)" || exit $? + lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/$var_install.sh)" || exit $? } @@ -1228,7 +1228,7 @@ description() { cat < - Logo + Logo

${APP} LXC

@@ -1241,15 +1241,15 @@ description() { - GitHub + GitHub - Discussions + Discussions - Issues + Issues EOF