From 0e9623b6625193bcc6208e5b3953b65339375830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Sun, 17 Nov 2024 22:09:33 -0500 Subject: [PATCH 1/3] Centralize all standard LXC options to avoid code duplication --- misc/build.func | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/misc/build.func b/misc/build.func index aee3366a8b8..200793c5779 100644 --- a/misc/build.func +++ b/misc/build.func @@ -129,6 +129,37 @@ ssh_check() { fi } +# This function allows to centralize all common options so that services only need to define settings that need to be overridden (Avoid duplication of information) +base_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="4" + CORE_COUNT="1" + RAM_SIZE="512" + BRG="vmbr0" + NET="dhcp" + GATE="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + # Since these 2 are defined outside of default_settings function, avoid overwriting them. To align everything, they should use another constant variable (say OSTYPE), but that would require updating the default_settings function for all existing scripts + if [ -z "$var_os" ]; then + var_os="debian" + fi + if [ -z "$var_version" ]; then + var_version="12" + fi +} + # This function displays the default values for various settings. echo_default() { echo -e "${DGN}Using Distribution: ${BGN}$var_os${CL}" @@ -491,6 +522,7 @@ install_script() { NEXTID=$(pvesh get /cluster/nextid) timezone=$(cat /etc/timezone) header_info + base_settings if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then header_info echo -e "${BL}Using Default Settings${CL}" From 15d8382c170701e0f6ff9d23185ff6cb7149ac6d Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 20 Nov 2024 11:26:36 +1300 Subject: [PATCH 2/3] Updated comment wording MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> --- misc/build.func | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/build.func b/misc/build.func index 200793c5779..48327c6148b 100644 --- a/misc/build.func +++ b/misc/build.func @@ -129,7 +129,7 @@ ssh_check() { fi } -# This function allows to centralize all common options so that services only need to define settings that need to be overridden (Avoid duplication of information) +# This function sets base settings which are common for all scripts. The settings can be overriden in default_settings or advanced_settings which are defined in each script base_settings() { CT_TYPE="1" PW="" From be35a96052547e881a831b793087731a5fc41779 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 20 Nov 2024 11:26:43 +1300 Subject: [PATCH 3/3] Updated comment wording MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Håvard Gjøby Thom <34199185+havardthom@users.noreply.github.com> --- misc/build.func | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/build.func b/misc/build.func index 48327c6148b..9575f7a6746 100644 --- a/misc/build.func +++ b/misc/build.func @@ -151,7 +151,7 @@ base_settings() { VLAN="" SSH="no" VERB="no" - # Since these 2 are defined outside of default_settings function, avoid overwriting them. To align everything, they should use another constant variable (say OSTYPE), but that would require updating the default_settings function for all existing scripts + # Since these 2 are only defined outside of default_settings function, we add a temporary fallback. TODO: To align everything, we should add these as constant variables (e.g. OSTYPE and OSVERSION), but that would currently require updating the default_settings function for all existing scripts if [ -z "$var_os" ]; then var_os="debian" fi