mak box type more consistent and display it anyway

- 'rpi' instead of 'ionopi' for a simple raspberry pi
+ fix dirty flag when dhcp server is modified
This commit is contained in:
2025-04-14 10:36:00 +02:00
committed by l_samenv
parent 094694df49
commit cf4706d1e2
2 changed files with 14 additions and 12 deletions

View File

@ -45,7 +45,7 @@ except ImportError:
if serial is None:
exit()
TOOLS = BoxInfo.TOOLS
BOX_TYPES = {'ionopi', 'ionopimax', 'control-box', 'bare-apu', 'dual-eth-rpi'}
@ -107,9 +107,6 @@ GENERIC_TEMPLATE = f"""{COMMENT}
[BOX]
type=%s
MAC=%s
[NETWORK]
eth0=wan
"""
DHCP_HEADER = """
@ -508,6 +505,8 @@ def handle_config():
print('WARNING: missing type in BOX section')
print('This is a cm3 so guess its a ionopimax')
box.typ = 'ionopimax'
print('box type:', box.typ, ' mac addr:', box.macaddr)
print('---')
else:
if box.typ == 'apu':
# determine if display is present
@ -522,8 +521,11 @@ def handle_config():
box.typ = 'dual-eth-rpi'
print('This is a cm4, so guess its a dual-eth-rpi - please check type in created cfg file')
elif box.typ == 'cm3':
print('This is a cm3 so guess its a ionopimax - please check type in created cfg file')
print('This is a cm3 so guess its a ionopimax - please check type in created cfg file')
box.typ = 'ionopimax'
elif box.typ == 'rpi':
print('This is a simple rpi, so guess its a ionopi - please check type in created cfg file')
box.typ = 'ionopi'
template = TEMPLATES.get(box.typ)
if template is None:
box.typ = box.typ or 'unknown-box'
@ -593,9 +595,10 @@ def handle_config():
to_start['isc-dhcp-server'] = 'restart'
show.dirty = True
try:
replace_in_file('/etc/default/isc-dhcp-server',
r'INTERFACESv4="(.*)"', ' '.join(
[n for n in box.network_interfaces if n != box.main_if]))
if replace_in_file(
'/etc/default/isc-dhcp-server', r'INTERFACESv4="(.*)"', ' '.join(
[n for n in box.network_interfaces if n != box.main_if])):
show.dirty = True
except FileNotFoundError:
if 'yes'.startswith(input('install isc-dhcp-server? [y]')):
unix_cmd('apt-get install isc-dhcp-server')

View File

@ -68,9 +68,9 @@ class BoxInfo:
CFGDIR = TOOLS / 'cfg'
BOX_TYPES = {
'00:0d:b9': 'apu', # bare apu or control box
'b8:27:eb': 'cm3', # guess iono pi max
'e4:5f:01': 'ionopi', # guess iono pi
'd8:3a:dd': 'cm4', # guess dual-eth-rpi
'b8:27:eb': 'cm3', # compute module 3 (guess iono pi max)
'e4:5f:01': 'rpi', # simple raspberry pi (guess ionopi)
'd8:3a:dd': 'cm4', # compute module 4 (guess dual-eth-rpi)
}
def __init__(self, macaddr=None, relcfg=None):
@ -96,7 +96,6 @@ class BoxInfo:
with open(ifdev) as f:
self.network_interfaces[ifname] = addr = f.read().strip().lower()
if ifname in ('eth0', 'enp1s0'):
print('my mac address', addr)
macaddr = addr
self.main_if = ifname
self.macaddr = macaddr