allow predictable network interfaces
on dual-eth-raspi: - eth0 -> end0 - eth1 -> enx...
This commit is contained in:
30
install.py
30
install.py
@@ -60,8 +60,8 @@ TEMPLATES = {}
|
||||
TEMPLATES['bare-apu'] = f"""{COMMENT}
|
||||
|
||||
[BOX]
|
||||
type=%s
|
||||
MAC=%s
|
||||
type=%(typ)s
|
||||
MAC=%(mac)s
|
||||
|
||||
[NETWORK]
|
||||
eth0=wan
|
||||
@@ -76,8 +76,8 @@ eth3=192.168.127.254
|
||||
TEMPLATES['control-box'] = f"""{COMMENT}
|
||||
|
||||
[BOX]
|
||||
type=%s
|
||||
MAC=%s
|
||||
type=%(typ)s
|
||||
MAC=%(mac)s
|
||||
|
||||
[NETWORK]
|
||||
eth0=wan
|
||||
@@ -94,19 +94,19 @@ line2=ADDR
|
||||
TEMPLATES['dual-eth-rpi'] = f"""{COMMENT}
|
||||
|
||||
[BOX]
|
||||
type=%s
|
||||
MAC=%s
|
||||
type=%(typ)s
|
||||
MAC=%(mac)s
|
||||
|
||||
[NETWORK]
|
||||
eth0=wan
|
||||
eth1=192.168.1.1
|
||||
end0=wan
|
||||
%(mac2)s=192.168.1.1
|
||||
"""
|
||||
|
||||
GENERIC_TEMPLATE = f"""{COMMENT}
|
||||
|
||||
[BOX]
|
||||
type=%s
|
||||
MAC=%s
|
||||
type=%(typ)s
|
||||
MAC=%(mac)s
|
||||
"""
|
||||
|
||||
DHCP_HEADER = """
|
||||
@@ -550,6 +550,7 @@ def handle_config():
|
||||
print('box type:', box.typ, ' mac addr:', box.macaddr)
|
||||
print('---')
|
||||
else:
|
||||
template_args = {'mac': box.macaddr}
|
||||
if box.typ == 'apu':
|
||||
# determine if display is present
|
||||
disp = serial.Serial('/dev/ttyS1', baudrate=115200, timeout=1)
|
||||
@@ -562,6 +563,11 @@ def handle_config():
|
||||
elif box.typ == 'cm4':
|
||||
box.typ = 'dual-eth-rpi'
|
||||
print('This is a cm4, so guess its a dual-eth-rpi - please check type in created cfg file')
|
||||
template_args['mac2'] = 'enx?'
|
||||
for addr in box.network_interfaces:
|
||||
if addr.startswith('enx'):
|
||||
template_args['mac2'] = addr
|
||||
print(template_args)
|
||||
elif box.typ == 'cm3':
|
||||
print('This is a cm3 so guess its a ionopimax - please check type in created cfg file')
|
||||
box.typ = 'ionopimax'
|
||||
@@ -572,7 +578,8 @@ def handle_config():
|
||||
if template is None:
|
||||
box.typ = box.typ or 'unknown-box'
|
||||
template = GENERIC_TEMPLATE
|
||||
template = template % (box.typ, box.macaddr)
|
||||
template_args['typ'] = box.typ
|
||||
template = template % template_args
|
||||
|
||||
print('no cfg file found for this', box.typ,
|
||||
f'with mac address {box.macaddr} (hostname={box.hostname})')
|
||||
@@ -740,6 +747,7 @@ else:
|
||||
doit = True
|
||||
handle_config()
|
||||
walk(Do())
|
||||
unix_cmd(f'rm -f {TOOLS / "current"}')
|
||||
with open(TOOLS / 'current', 'w') as f:
|
||||
f.write(result)
|
||||
elif 'more'.startswith(answer.lower()):
|
||||
|
||||
Reference in New Issue
Block a user