Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralize all standard LXC options to avoid code duplication #322

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions misc/build.func
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,37 @@ ssh_check() {
fi
}

# 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=""
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 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
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}"
Expand Down Expand Up @@ -491,6 +522,7 @@ install_script() {
NEXTID=$(pvesh get /cluster/nextid)
timezone=$(cat /etc/timezone)
header_info
base_settings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its wrong here? Need to replace with Row 529 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, essentially you load all the standard (base) settings (eg. 4GB HDD, 512Mb RAM, 1 CPU...) with the base_settings function, then calling default_settings allows to overide them with whatever is defined in the actual installation script (eg. 20Gb HDD, 4CPU...)

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}"
Expand Down