Chroot: Generate interfaces network config
This commit is contained in:
parent
de35719b12
commit
316a2ea748
|
@ -198,6 +198,28 @@ grep "/var/tmp" /target/etc/fstab || echo "/tmp /var/tmp no
|
|||
|
||||
### Remove all occurrences to /target
|
||||
sed -i 's;/target;;g' /target/etc/fstab
|
||||
## }}}
|
||||
## Network {{{
|
||||
net_device=$(ip r | grep "^default" | head -1 | cut -d" " -f5)
|
||||
net_address=$(ip r | grep -vE "(^default|metric)" | grep "${net_device}.*src" | head -1 | awk -F" " '{print $NF}')
|
||||
net_netmask=$(ipcalc "${net_address}" | awk '/Netmask:/{print $2;}')
|
||||
net_broadcast=$(ip a s dev "${net_device}" | awk '/inet.*brd/{print $4}')
|
||||
net_network=$(ip r | grep -vE "(^default|metric)" | grep "src ${net_address}" | head -1 | cut -d"/" -f1)
|
||||
net_gateway=$(ip r | grep "^default" | head -1 | cut -d" " -f3)
|
||||
|
||||
printf '%b' "auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
auto ${net_device}
|
||||
iface ${net_device} inet static
|
||||
address ${net_address}
|
||||
netmask ${net_netmask}
|
||||
network ${net_network}
|
||||
broadcast ${net_broadcast}
|
||||
gateway ${net_gateway}
|
||||
|
||||
source-directory /etc/network/interfaces.d" > /target/etc/network/interfaces
|
||||
|
||||
## }}}
|
||||
# }}}
|
||||
# Finish {{{
|
||||
|
|
Loading…
Reference in New Issue