test alpine dns
This commit is contained in:
parent
ec91310889
commit
79d5cbfb1a
@ -255,6 +255,27 @@ grep -q "root:100000:65536" /etc/subgid || echo "root:100000:65536" >>/etc/subgi
|
|||||||
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs "$CONTAINER_STORAGE:${PCT_DISK_SIZE:-8}")
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs "$CONTAINER_STORAGE:${PCT_DISK_SIZE:-8}")
|
||||||
|
|
||||||
|
if [ "$UDHCPC_FIX" == "yes" ]; then
|
||||||
|
CT_ROOT="/var/lib/lxc/${CTID}/rootfs"
|
||||||
|
CONFIG_FILE="$CT_ROOT/etc/udhcpc/udhcpc.conf"
|
||||||
|
|
||||||
|
if [ -f "$CONFIG_FILE" ]; then
|
||||||
|
msg_info "Patching udhcpc.conf for Alpine DNS override"
|
||||||
|
sed -i '/^#*RESOLV_CONF="/d' "$CONFIG_FILE"
|
||||||
|
awk '
|
||||||
|
/^# Do not overwrite \/etc\/resolv\.conf/ {
|
||||||
|
print
|
||||||
|
print "RESOLV_CONF=\"no\""
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
' "$CONFIG_FILE" >"${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"
|
||||||
|
msg_ok "Patched udhcpc.conf (RESOLV_CONF=\"no\")"
|
||||||
|
else
|
||||||
|
msg_error "udhcpc.conf not found in $CONFIG_FILE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
msg_info "Creating LXC Container"
|
msg_info "Creating LXC Container"
|
||||||
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" &>/dev/null; then
|
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" &>/dev/null; then
|
||||||
msg_error "Container creation failed. Checking if template is corrupted."
|
msg_error "Container creation failed. Checking if template is corrupted."
|
||||||
|
@ -98,27 +98,6 @@ msg_error() {
|
|||||||
# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection
|
# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection
|
||||||
setting_up_container() {
|
setting_up_container() {
|
||||||
msg_info "Setting up Container OS"
|
msg_info "Setting up Container OS"
|
||||||
|
|
||||||
# Check if a non-default DNS is configured in /etc/resolv.conf
|
|
||||||
DNS=$(grep '^nameserver' /etc/resolv.conf | awk '{print $2}' | head -n1)
|
|
||||||
CONFIG_FILE="/etc/udhcpc/udhcpc.conf"
|
|
||||||
|
|
||||||
# Patch only if DNS is set and not 127.0.0.1
|
|
||||||
if [ -n "$DNS" ] && [ "$DNS" != "127.0.0.1" ]; then
|
|
||||||
# Remove all RESOLV_CONF= lines (active or commented)
|
|
||||||
sed -i '/^#*RESOLV_CONF="/d' "$CONFIG_FILE"
|
|
||||||
|
|
||||||
# Rebuild file with single correct entry after header
|
|
||||||
awk '
|
|
||||||
/^# Do not overwrite \/etc\/resolv\.conf/ {
|
|
||||||
print
|
|
||||||
print "RESOLV_CONF=\"no\""
|
|
||||||
next
|
|
||||||
}
|
|
||||||
{ print }
|
|
||||||
' "$CONFIG_FILE" >"${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
while [ $i -gt 0 ]; do
|
while [ $i -gt 0 ]; do
|
||||||
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then
|
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then
|
||||||
break
|
break
|
||||||
|
@ -652,6 +652,7 @@ advanced_settings() {
|
|||||||
else
|
else
|
||||||
UDHCPC_FIX="no"
|
UDHCPC_FIX="no"
|
||||||
fi
|
fi
|
||||||
|
export UDHCPC_FIX
|
||||||
|
|
||||||
if MAC1=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --inputbox "Set a MAC Address(leave blank for generated MAC)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" --inputbox "Set a MAC Address(leave blank for generated MAC)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z "$MAC1" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user