Add ability to save config
This commit is contained in:
parent
1a773faccd
commit
4302bf0a64
@ -283,6 +283,61 @@ exit_script() {
|
|||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write_config() {
|
||||||
|
# This function writes the configuration to a file.
|
||||||
|
if whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --defaultno --title "Write configfile" --yesno "Do you want to write the selections to a config file?" 10 60; then
|
||||||
|
FILEPATH="/opt/community-scripts/${NSAPP}.conf"
|
||||||
|
if [[ ! -f $FILEPATH ]]; then
|
||||||
|
cat <<EOF >"$FILEPATH"
|
||||||
|
# ${NSAPP} Configuration File
|
||||||
|
# Generated on $(date)
|
||||||
|
|
||||||
|
CT_TYPE="${CT_TYPE}"
|
||||||
|
DISK_SIZE="${DISK_SIZE}"
|
||||||
|
CORE_COUNT="${DISK_SIZE}"
|
||||||
|
RAM_SIZE="${RAM_SIZE}"
|
||||||
|
HN="${HN}"
|
||||||
|
BRG="${BRG}"
|
||||||
|
APT_CACHER_IP="${APT_CACHER_IP}"
|
||||||
|
DISABLEIP6="${DISABLEIP6}"
|
||||||
|
TAGS="${TAGS}"
|
||||||
|
PW="${PW1}"
|
||||||
|
SSH="${SSH}"
|
||||||
|
SSH_AUTHORIZED_KEY="${SSH_AUTHORIZED_KEY}"
|
||||||
|
VERBOSE="${VERBOSE}"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
echo -e "${INFO}${BOLD}${GN}Writing configuration to ${FILEPATH}${CL}"
|
||||||
|
else
|
||||||
|
echo -e "${INFO}${BOLD}${RD}Configuration file already exists at ${FILEPATH}${CL}"
|
||||||
|
if whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --defaultno --title "Overwrite configfile" --yesno "Do you want to overwrite the existing config file?" 10 60; then
|
||||||
|
cat <<EOF >"$FILEPATH"
|
||||||
|
# ${NSAPP} Configuration File
|
||||||
|
# Generated on $(date)
|
||||||
|
|
||||||
|
CT_TYPE="${CT_TYPE}"
|
||||||
|
DISK_SIZE="${DISK_SIZE}"
|
||||||
|
CORE_COUNT="${DISK_SIZE}"
|
||||||
|
RAM_SIZE="${RAM_SIZE}"
|
||||||
|
HN="${HN}"
|
||||||
|
BRG="${BRG}"
|
||||||
|
APT_CACHER_IP="${APT_CACHER_IP}"
|
||||||
|
DISABLEIP6="${DISABLEIP6}"
|
||||||
|
TAGS="${TAGS}"
|
||||||
|
PW="${PW1}"
|
||||||
|
SSH="${SSH}"
|
||||||
|
SSH_AUTHORIZED_KEY="${SSH_AUTHORIZED_KEY}"
|
||||||
|
VERBOSE="${VERBOSE}"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
echo -e "${INFO}${BOLD}${GN}Writing configuration to ${FILEPATH}${CL}"
|
||||||
|
else
|
||||||
|
echo -e "${INFO}${BOLD}${RD}Configuration file not overwritten${CL}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# This function allows the user to configure advanced settings for the script.
|
# This function allows the user to configure advanced settings for the script.
|
||||||
advanced_settings() {
|
advanced_settings() {
|
||||||
whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --msgbox --title "Here is an instructional tip:" "To make a selection, use the Spacebar." 8 58
|
whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --msgbox --title "Here is an instructional tip:" "To make a selection, use the Spacebar." 8 58
|
||||||
@ -626,6 +681,7 @@ advanced_settings() {
|
|||||||
|
|
||||||
if (whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then
|
if (whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then
|
||||||
echo -e "${CREATING}${BOLD}${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
|
echo -e "${CREATING}${BOLD}${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
|
||||||
|
write_config
|
||||||
else
|
else
|
||||||
clear
|
clear
|
||||||
header_info
|
header_info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user