mirror of
https://github.com/dockur/proxmox.git
synced 2026-07-27 16:54:51 +07:00
fix: Check if files can be written (#77)
This commit is contained in:
+20
-4
@@ -145,7 +145,7 @@ configureDNS() {
|
|||||||
(( high < 254 )) && ranges+="dhcp-range=set:${fa},${base}.$((high + 1)),${base}.254"$'\n'
|
(( high < 254 )) && ranges+="dhcp-range=set:${fa},${base}.$((high + 1)),${base}.254"$'\n'
|
||||||
ranges="${ranges%$'\n'}" # strip trailing newline
|
ranges="${ranges%$'\n'}" # strip trailing newline
|
||||||
|
|
||||||
sed 's/^ //' > "$file" <<EOF
|
if ! sed 's/^ //' > "$file" <<EOF
|
||||||
|
|
||||||
# Listen only on bridge
|
# Listen only on bridge
|
||||||
interface=$fa
|
interface=$fa
|
||||||
@@ -171,6 +171,10 @@ configureDNS() {
|
|||||||
dhcp-option=252,"\n"
|
dhcp-option=252,"\n"
|
||||||
dhcp-option=vendor:MSFT,2,1i
|
dhcp-option=vendor:MSFT,2,1i
|
||||||
EOF
|
EOF
|
||||||
|
then
|
||||||
|
error "Failed to write dnsmasq config file: $file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -184,25 +188,33 @@ setInterfaces() {
|
|||||||
# Add all available network interfaces
|
# Add all available network interfaces
|
||||||
local file="/etc/network/interfaces.new"
|
local file="/etc/network/interfaces.new"
|
||||||
|
|
||||||
sed 's/^ //' > "$file" <<EOF
|
if ! sed 's/^ //' > "$file" <<EOF
|
||||||
auto lo
|
auto lo
|
||||||
iface lo inet loopback
|
iface lo inet loopback
|
||||||
EOF
|
EOF
|
||||||
|
then
|
||||||
|
error "Failed to write network interface config file: $file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
while IFS= read -r i; do
|
while IFS= read -r i; do
|
||||||
|
|
||||||
[[ "${i,,}" == "${fa,,}" ]] && continue
|
[[ "${i,,}" == "${fa,,}" ]] && continue
|
||||||
|
|
||||||
sed 's/^ //' >> "$file" <<EOF
|
if ! sed 's/^ //' >> "$file" <<EOF
|
||||||
|
|
||||||
auto $i
|
auto $i
|
||||||
iface $i inet manual
|
iface $i inet manual
|
||||||
EOF
|
EOF
|
||||||
|
then
|
||||||
|
error "Failed to append interface $i to config file: $file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
done < <(ip -o link show | awk -F': ' '{print $2}' | grep -v lo | sed 's/@.*//')
|
done < <(ip -o link show | awk -F': ' '{print $2}' | grep -v lo | sed 's/@.*//')
|
||||||
|
|
||||||
# Configure bridge
|
# Configure bridge
|
||||||
sed 's/^ //' >> "$file" <<EOF
|
if ! sed 's/^ //' >> "$file" <<EOF
|
||||||
|
|
||||||
auto $fa
|
auto $fa
|
||||||
iface $fa inet static
|
iface $fa inet static
|
||||||
@@ -213,6 +225,10 @@ EOF
|
|||||||
|
|
||||||
source /etc/network/interfaces.d/*
|
source /etc/network/interfaces.d/*
|
||||||
EOF
|
EOF
|
||||||
|
then
|
||||||
|
error "Failed to append bridge config to file: $file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user