reorganize fixup directories

- to_system_apu instead of apu_system
- to_config_desktop instead of desktop
+ remove the need of waitboot, add ExecStartPre or frappy and boxweb
This commit is contained in:
DIL5 committed 2026-10-14 15:33:10 +02:00
1 parent 19937fd737
commit 5a9ea9d779
9 files changed
+30 -88

No files matched your search

+1 -1
View File
@@ -17,5 +17,5 @@ cfg=dil5
[BOXWEB]
port=8050
wsport=8010
wsport=8051
page=dil5
+29 -31
View File
@@ -136,10 +136,10 @@ WantedBy = multi-user.target
FRAPPY_SERVICE = """[Unit]
Description = Running frappy server
After=network-online.target
Wants=network-online.target
[Service]
# wait for network is online
ExecStartPre=/bin/sh -c 'until systemctl is-active --quiet network-online.target; do sleep 1; done'
Type=simple
Environment=PYTHONPATH=/home/l_samenv/.local/lib/python3.11/site-packages/
ExecStart = /home/l_samenv/boxtools/start_frappy
@@ -162,11 +162,13 @@ WantedBy = multi-user.target
BOXWEB_SERVICE = """[Unit]
Description = Web service for local GUI on a box
After = waitboot.target
[Service]
WorkingDirectory = /home/l_samenv/boxweb
ExecStart = /usr/bin/python flaskserver.py {page}.{port}.{wsport}
TimeoutStartSec = 60
# wait for frappy server serving websocket {wsport} is running
ExecStartPre = /bin/sh -c 'until ss -H -ltn "sport = :{wsport}" | grep -q .; do sleep 1; done'
ExecStart = /usr/bin/python3 flaskserver.py {page}.{port}.{wsport}
[Install]
WantedBy = default.target
@@ -175,11 +177,14 @@ WantedBy = default.target
pip_requirements = {}
box = BoxInfo()
box.fixup_dirs = [ # (src, dst, as_root)
(TOOLS / 'to_system', Path('/'), True),
(TOOLS / f'to_system_{box.typ}', Path('/'), True),
(TOOLS / 'to_home', Path.home(), False),
]
box.hostname_changed = False
dhcp_server_cfg = []
to_system = [TOOLS / 'to_system']
def do_cmd(*command, sudo=True):
unix_cmd(*command, execute=doit, sudo=sudo)
@@ -269,14 +274,16 @@ def boxweb(port=8080, wsport=8051, page=None):
main_ports.add(wsport)
if port == 8080:
main_ports.add(80)
config = box.read_config()
servicecfg = BOXWEB_SERVICE.format(port=port, wsport=wsport, page=page)
for file, dest in (('labwc.service', '/etc/systemd/system'),
('boxweb-browser.service', '/home/l_samenv/.config/systemd/user')):
src = TOOLS / 'desktop' / file
dst = Path(dest) / file
if not page:
src = None # -> remove
do_copy(src, dst)
box.fixup_dirs.append((TOOLS / 'to_config_desktop', Path('~/.config/systemd/user').expanduser(), False))
#for file, dest in (('labwc.service', '/home/l_samenv/.config/systemd/user'),
# ('boxweb-browser.service', '/home/l_samenv/.config/systemd/user')):
# src = TOOLS / 'desktop' / file
# dst = Path(dest) / file
# if not page:
# src = None # -> remove
# do_copy(src, dst)
return port <= 1024, servicecfg
@@ -392,6 +399,8 @@ def write_when_new(filename, content, as_root=False, ignore_reduction=False):
print('\n'.join(old[-bottom_lines:-1]))
print("===")
print('.' * 80)
else:
print('write', filename)
return content
@@ -498,17 +507,12 @@ def walk_dir(action, srcpath, dstroot, files):
def walk(action):
action.as_root = True
for rootpath in to_system:
if not rootpath.exists():
continue
os.chdir(rootpath)
for srcpath, _, files in os.walk('.'):
walk_dir(action, srcpath, Path('/'), files)
os.chdir(TOOLS / 'to_home')
action.as_root = False
for srcpath, _, files in os.walk('.'):
walk_dir(action, srcpath, Path.home(), files)
for src, dst, as_root in box.fixup_dirs:
if src.exists():
action.as_root = as_root
os.chdir(src)
for srcpath, _, files in os.walk('.'):
walk_dir(action, srcpath, dst, files)
class Walker:
@@ -656,8 +660,6 @@ def handle_config():
config = box.read_config()
box.hostname = newhostname
update_host_key(newhostname)
if len(to_system) == 1:
to_system.append(TOOLS / f'to_{box.typ}')
if cfgfile is None:
return False
to_start = {} # dict <service> of <action>, <as_root>
@@ -755,10 +757,7 @@ def handle_config():
if pip_requirements:
pip()
for as_root in reload_systemd:
if as_root:
do_cmd('systemctl daemon-reload', sudo=True)
else:
do_cmd('systemctl --user daemon-reload', sudo=False)
do_cmd('systemctl daemon-reload', sudo=as_root) # '--user' will be inserted inside
for service, (action, _) in to_start.items():
show.dirty = True
if action == 'if_restart':
@@ -792,7 +791,6 @@ def handle_config():
doit = False
print(' ')
show = Show()
#walk(show)
result = handle_config()
walk(show)
-21
View File
@@ -1,21 +0,0 @@
[BOX]
type=bare-apu
MAC=00:0d:b9:59:1f:ac
[NETWORK]
; please refer to README.md for help
eth0=dhcp
eth1=192.168.2.32
eth2=192.168.3.1
eth3=192.168.127.254
[ROUTER]
; please refer to README.md for help
3000=/dev/ttyACM0
5900=192.168.2.32
33576=192.168.2.32
8080=192.168.127.254:80
3001=192.168.127.254:3001
3002=192.168.127.254:3002
3003=192.168.127.254:3003
3004=192.168.127.254:3004
File renamed without changes.
@@ -2,8 +2,6 @@
Description=LabWC Wayland compositor
[Service]
User=l_samenv
Type=simple
ExecStart=/usr/bin/labwc
Restart=on-failure
@@ -1,10 +0,0 @@
[Unit]
Description = wait a little after startup
After = network.target
[Service]
Type=oneshot
ExecStart = /usr/bin/sleep 10
[Install]
WantedBy = default.target
File renamed without changes.
-12
View File
@@ -1,12 +0,0 @@
[Unit]
Description = Running Web Browser for boxweb
Requires=labwc.service
Requires=boxweb.service
[Service]
Type=simple
ExecStart = /usr/bin/python /home/l_samenv/boxweb/start_browser.py
[Install]
WantedBy = default.target
-11
View File
@@ -1,11 +0,0 @@
[Unit]
Description=LabWC Wayland compositor
After=graphical.target
[Service]
Type=simple
ExecStart=/usr/bin/labwc
Restart=on-failure
[Install]
WantedBy=default.target