mirror of
https://github.com/elitak/nixos-infect
synced 2024-11-10 05:54:20 +00:00
Fix hardcode of eth0 in several places
The problem was that some VPS (from GigaCloud provider, Ukraine) provided `ens3` interface name, but after infection it was renamed to `eth0` via udev rules.
This commit is contained in:
parent
914dad1039
commit
89b92f3de1
1 changed files with 8 additions and 3 deletions
11
nixos-infect
11
nixos-infect
|
@ -67,9 +67,13 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nameservers=($(grep ^nameserver /etc/resolv.conf | cut -f2 -d' '))
|
nameservers=($(grep ^nameserver /etc/resolv.conf | cut -f2 -d' '))
|
||||||
|
if [ "$eth0_name" = eth* ]; then
|
||||||
|
predictable_inames="usePredictableInterfaceNames = lib.mkForce false;"
|
||||||
|
else
|
||||||
|
predictable_inames="usePredictableInterfaceNames = lib.mkForce true;"
|
||||||
|
fi
|
||||||
cat > /etc/nixos/networking.nix << EOF
|
cat > /etc/nixos/networking.nix << EOF
|
||||||
{ ... }: {
|
{ lib, ... }: {
|
||||||
# This file was populated at runtime with the networking
|
# This file was populated at runtime with the networking
|
||||||
# details gathered from the active system.
|
# details gathered from the active system.
|
||||||
networking = {
|
networking = {
|
||||||
|
@ -79,6 +83,7 @@ EOF
|
||||||
defaultGateway = "${gateway}";
|
defaultGateway = "${gateway}";
|
||||||
defaultGateway6 = "${gateway6}";
|
defaultGateway6 = "${gateway6}";
|
||||||
dhcpcd.enable = false;
|
dhcpcd.enable = false;
|
||||||
|
$predictable_inames
|
||||||
interfaces = {
|
interfaces = {
|
||||||
$eth0_name = {
|
$eth0_name = {
|
||||||
ipv4.addresses = [$(for a in "${eth0_ip4s[@]}"; do echo -n "
|
ipv4.addresses = [$(for a in "${eth0_ip4s[@]}"; do echo -n "
|
||||||
|
@ -92,7 +97,7 @@ EOF
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services.udev.extraRules = ''
|
services.udev.extraRules = ''
|
||||||
ATTR{address}=="${ether0}", NAME="eth0"
|
ATTR{address}=="${ether0}", NAME="${eth0_name}"
|
||||||
$extraRules1
|
$extraRules1
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue