units + scripts: corrigir bugs herdados de JELOS no boot

Sweep encontrou 5 categorias de bugs sutis em arquivos herdados:

1. StartLimitInterval/StartLimitBurst em [Service] em 13 unidades
   (avahi, bluez, connman, samba/nmbd/smbd, sshd, tz-data, ledfix,
   xorg, fluxbox/windowmanager, samba-config). systemd silenciosamente
   ignora StartLimit* fora de [Unit], então a proteção contra
   restart-flood nunca foi aplicada. Movidas para [Unit] e renomeadas
   para o canônico StartLimitIntervalSec (StartLimitInterval é alias
   antigo).

2. Refs dangling para kodi.service em 5 units (entware, locale, sway,
   xorg, xwayland-xorg, windowmanager-fluxbox). ArchR não embarca
   Kodi; o ordering Before=kodi.service ficava como "not-found" no
   systemctl list-units. Trocado por Before=archr.target (alvo real
   de boot da UI em ArchR).

3. usercache.service e userconfig.service referenciavam
   automount.service e autostart.service sem prefixo archr-. Em ArchR
   as unidades reais chamam-se archr-automount.service /
   archr-autostart.service, então o Before= era ignorado e o setup
   corria paralelo aos mounts.

4. archr-autostart.service tinha Before=weston.service. ArchR roda
   sway, não weston. Removido (After=graphical.target já cobre).

5. nmbd.service do override ArchR queria samba-config.service que só
   existe no pacote global packages/network/samba (não no override).
   O daemons/002-samba já cria /run/samba/smb.conf manualmente, então
   Wants/After=samba-config.service eram supérfluos.

Bugs adicionais corrigidos no caminho:

- archr/autostart/050-audio: `if [ -n "/usr/sbin/quantum" ]` testa se
  uma string literal é não-vazia (sempre true) em vez de checar se o
  binário existe. Trocado para [ -x ].
- avahi: post_makeinstall_target removia /usr/sbin/avahi-dnsconfd mas
  deixava a unit avahi-dnsconfd.service órfã. Remove a unit junto.
- system-utils: video.service só faz sentido em devices que embarcam
  /usr/bin/video_sense (RK3399/RK3566/S922X). Remove a unit em
  devices que não têm o helper.
- xwayland: scripts/xorg-configure não era instalado, deixando
  xorg-configure@.service com ExecStart para um path inexistente.
  Agora copiado pra /usr/lib/xorg/xorg-configure.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Douglas Teles
2026-06-24 11:09:58 -03:00
parent fd1398b472
commit e90a0708c8
27 changed files with 79 additions and 47 deletions
@@ -3,7 +3,8 @@ Description=Avahi Daemon
After=network.target avahi-defaults.service
Requires=avahi-defaults.service
ConditionPathExists=/storage/.cache/services/avahi.conf
StartLimitIntervalSec=60
StartLimitBurst=10
[Service]
Restart=on-failure
EnvironmentFile=-/run/archr/debug/avahi.conf
@@ -11,8 +12,6 @@ ExecStart=/usr/sbin/avahi-daemon -s $AVAHI_DEBUG
ExecReload=/usr/sbin/avahi-daemon -r
TimeoutStopSec=1s
RestartSec=2
StartLimitInterval=60
StartLimitBurst=10
[Install]
WantedBy=multi-user.target
@@ -4,7 +4,7 @@ After=syslog.target bluetooth-defaults.service
Requires=bluetooth-defaults.service
ConditionPathExists=/storage/.cache/services/bluez.conf
StartLimitIntervalSec=0
[Service]
NotifyAccess=main
EnvironmentFile=/storage/.cache/services/bluez.conf
@@ -15,7 +15,6 @@ LimitNPROC=1
TimeoutStopSec=1s
Restart=on-failure
RestartSec=2
StartLimitInterval=0
[Install]
WantedBy=bluetooth.target
@@ -6,7 +6,7 @@ Before=network.target multi-user.target shutdown.target
After=dbus.service network-base.service
Wants=network.target
ConditionPathExists=!/dev/.kernel_ipconfig
StartLimitIntervalSec=0
[Service]
Type=dbus
BusName=net.connman
@@ -15,7 +15,6 @@ EnvironmentFile=-/run/archr/debug/connman.conf
ExecStart=/bin/sh -c ". /usr/lib/connman/connman-setup; exec /usr/sbin/connmand -nr $CONNMAN_MAIN $CONNMAN_DEBUG"
StandardOutput=null
RestartSec=2
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
@@ -3,7 +3,7 @@ Description=OpenSSH server daemon
After=network.target
ConditionKernelCommandLine=|ssh
ConditionPathExists=|/storage/.cache/services/sshd.conf
StartLimitIntervalSec=0
[Service]
Restart=on-failure
EnvironmentFile=-/storage/.cache/services/sshd.conf
@@ -12,7 +12,6 @@ ExecStart=/usr/sbin/sshd -D $SSH_ARGS
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=1s
RestartSec=2
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
@@ -4,7 +4,7 @@ Wants=network-online.target samba-config.service
After=network-online.target samba-config.service
ConditionPathExists=!/storage/.cache/services/samba.disabled
ConditionPathExists=/run/samba/smb.conf
StartLimitIntervalSec=0
[Service]
Type=forking
PIDFile=/run/samba/nmbd.pid
@@ -13,7 +13,6 @@ ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=1s
Restart=always
RestartSec=2
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
@@ -4,7 +4,7 @@ Wants=network-online.target nmbd.service
After=network-online.target nmbd.service
ConditionPathExists=!/storage/.cache/services/samba.disabled
ConditionPathExists=/run/samba/smb.conf
StartLimitIntervalSec=0
[Service]
Type=forking
PIDFile=/run/samba/smbd.pid
@@ -14,7 +14,6 @@ ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=1s
Restart=always
RestartSec=2
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
@@ -2,9 +2,8 @@
Description=Samba Configuration
DefaultDependencies=false
After=basic.target
StartLimitIntervalSec=0
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/samba/samba-config
StartLimitInterval=0
@@ -1,12 +1,11 @@
[Unit]
Description=LEDfix Service
After=network-online.target
StartLimitIntervalSec=0
[Service]
Type=oneshot
ExecStart=/bin/sh /usr/bin/ledfix
RemainAfterExit=yes
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
@@ -1,8 +1,11 @@
[Unit]
Description=Compile locale definition files
ConditionPathExists=!/storage/.cache/locpath
ConditionPathExists=!/storage/.kodi/addons/service.locale/locpath
Before=kodi.service
# /storage/.kodi/... era checado para fugir do locale do Kodi quando o
# usuário tinha o addon service.locale instalado. ArchR não embarca
# Kodi, então a verificação extra só polui o systemd-analyze; basta o
# guard de /storage/.cache/locpath para evitar recompilar a cada boot.
Before=archr.target
[Service]
Type=oneshot
@@ -3,14 +3,13 @@ Description=Setup Timezone data
DefaultDependencies=no
Before=systemd-udevd.service
After=var.mount systemd-tmpfiles-setup.service
StartLimitIntervalSec=0
[Service]
Type=oneshot
Environment=TIMEZONE=UTC
EnvironmentFile=-/storage/.cache/timezone
ExecStart=/bin/ln -sf /usr/share/zoneinfo/${TIMEZONE} /var/run/localtime
RemainAfterExit=yes
StartLimitInterval=0
[Install]
WantedBy=sysinit.target
@@ -1,6 +1,6 @@
[Unit]
Description=Sway Wayland Compositor
Before=graphical.target kodi.service
Before=graphical.target archr.target
After=multi-user.target
ConditionKernelCommandLine=!installer
@@ -2,8 +2,8 @@
Description=Fluxbox Window Manager
Requires=xorg.service
After=xorg.service
Before=kodi.service
Before=archr.target
StartLimitIntervalSec=0
[Service]
Environment=DISPLAY=:0
Environment=HOME=/storage
@@ -11,7 +11,6 @@ ExecStart=/usr/bin/fluxbox
KillMode=process
Restart=always
RestartSec=1
StartLimitInterval=0
TimeoutStopSec=1s
[Install]
@@ -1,16 +1,15 @@
[Unit]
Description=Xorg Server
Before=graphical.target kodi.service
Before=graphical.target archr.target
After=multi-user.target
ConditionKernelCommandLine=!installer
StartLimitIntervalSec=0
[Service]
Type=notify
EnvironmentFile=-/run/archr/debug/xorg.conf
ExecStart=/usr/bin/xorg-launch -nolisten tcp vt01 $XORG_DEBUG
Restart=always
RestartSec=2
StartLimitInterval=0
[Install]
WantedBy=graphical.target