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

@ -107,9 +107,6 @@ GENERIC_TEMPLATE = f"""{COMMENT}
[BOX] [BOX]
type=%s type=%s
MAC=%s MAC=%s
[NETWORK]
eth0=wan
""" """
DHCP_HEADER = """ DHCP_HEADER = """
@ -508,6 +505,8 @@ def handle_config():
print('WARNING: missing type in BOX section') print('WARNING: missing type in BOX section')
print('This is a cm3 so guess its a ionopimax') print('This is a cm3 so guess its a ionopimax')
box.typ = 'ionopimax' box.typ = 'ionopimax'
print('box type:', box.typ, ' mac addr:', box.macaddr)
print('---')
else: else:
if box.typ == 'apu': if box.typ == 'apu':
# determine if display is present # determine if display is present
@ -524,6 +523,9 @@ def handle_config():
elif box.typ == 'cm3': 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' 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) template = TEMPLATES.get(box.typ)
if template is None: if template is None:
box.typ = box.typ or 'unknown-box' box.typ = box.typ or 'unknown-box'
@ -593,9 +595,10 @@ def handle_config():
to_start['isc-dhcp-server'] = 'restart' to_start['isc-dhcp-server'] = 'restart'
show.dirty = True show.dirty = True
try: try:
replace_in_file('/etc/default/isc-dhcp-server', if replace_in_file(
r'INTERFACESv4="(.*)"', ' '.join( '/etc/default/isc-dhcp-server', r'INTERFACESv4="(.*)"', ' '.join(
[n for n in box.network_interfaces if n != box.main_if])) [n for n in box.network_interfaces if n != box.main_if])):
show.dirty = True
except FileNotFoundError: except FileNotFoundError:
if 'yes'.startswith(input('install isc-dhcp-server? [y]')): if 'yes'.startswith(input('install isc-dhcp-server? [y]')):
unix_cmd('apt-get install isc-dhcp-server') unix_cmd('apt-get install isc-dhcp-server')

View File

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