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')