## Copyright (C) 2018 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

[Unit]
Description=Enables unrestricted admin mode under Qubes OS
Wants=sysmaint-boot.target
After=sysmaint-boot.target
ConditionPathExists=/usr/share/qubes/marker-vm
ConditionKernelCommandLine=remove-sysmaint-qubes

## The self-removal runs 'apt purge' (via sysmaint-boot -> dummy-dependency),
## which takes '/var/lib/dpkg/lock-frontend'. Order it before the Qubes
## rc.local runner: qubes-misc-post.service executes '/rw/config/rc.local'
## (and '/rw/config/rc.local.d/*.rc'), which may itself invoke dpkg/apt. Without
## this ordering the two run concurrently at boot, contend for the dpkg lock,
## and the purge aborts with 'Could not get lock /var/lib/dpkg/lock-frontend'.
Before=qubes-misc-post.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/user-sysmaint-split/sysmaint-boot remove-sysmaint-qubes

[Install]
WantedBy=basic.target
