mirror of
https://github.com/bin456789/reinstall.git
synced 2025-03-13 23:24:43 +08:00
alpine: 优化网络配置逻辑
This commit is contained in:
parent
c830907cef
commit
3bf44504a6
13
trans.sh
13
trans.sh
@ -273,28 +273,25 @@ install_alpine() {
|
|||||||
sed -i '/^slaac private/s/^/#/' /etc/dhcpcd.conf
|
sed -i '/^slaac private/s/^/#/' /etc/dhcpcd.conf
|
||||||
sed -i '/^#slaac hwaddr/s/^#//' /etc/dhcpcd.conf
|
sed -i '/^#slaac hwaddr/s/^#//' /etc/dhcpcd.conf
|
||||||
|
|
||||||
# 生成 lo 配置
|
# 生成 lo配置 + eth0头部
|
||||||
cat <<EOF >/etc/network/interfaces
|
cat <<EOF >/etc/network/interfaces
|
||||||
auto lo
|
auto lo
|
||||||
iface lo inet loopback
|
iface lo inet loopback
|
||||||
|
|
||||||
|
auto eth0
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 生成 ipv4 配置
|
# 生成 ipv4 配置
|
||||||
echo >>/etc/network/interfaces
|
|
||||||
if [ "$(get_netconf dhcpv4)" = 1 ]; then
|
if [ "$(get_netconf dhcpv4)" = 1 ]; then
|
||||||
# dhcpv4
|
# dhcpv4
|
||||||
cat <<EOF >>/etc/network/interfaces
|
echo "iface eth0 inet dhcp" >>/etc/network/interfaces
|
||||||
auto eth0
|
|
||||||
iface eth0 inet dhcp
|
|
||||||
EOF
|
|
||||||
else
|
else
|
||||||
# static
|
# static
|
||||||
ipv4_addr=$(get_netconf ipv4_addr)
|
ipv4_addr=$(get_netconf ipv4_addr)
|
||||||
ipv4_gateway=$(get_netconf ipv4_gateway)
|
ipv4_gateway=$(get_netconf ipv4_gateway)
|
||||||
if [ -n "$ipv4_addr" ]; then
|
if [ -n "$ipv4_addr" ]; then
|
||||||
cat <<EOF >>/etc/network/interfaces
|
cat <<EOF >>/etc/network/interfaces
|
||||||
auto eth0
|
iface eth0 inet static
|
||||||
iface eth0 inet4 static
|
|
||||||
address $ipv4_addr
|
address $ipv4_addr
|
||||||
gateway $ipv4_gateway
|
gateway $ipv4_gateway
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user