-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init: add a basic [email protected] to ensure basic runtime in…
…tegration on initful containers (graphics, sound, keyring, authorities) Signed-off-by: Luca Di Maio <[email protected]>
- Loading branch information
Showing
1 changed file
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1864,13 +1864,43 @@ if command -v systemctl 2> /dev/null; then | |
done | ||
fi | ||
|
||
# Let's do a minimal user-integration for the user when using system | ||
# as the [email protected] will trigger the [email protected] which will | ||
# undo all the integration we did at the start of the script | ||
# | ||
# This will ensure the basic integration for x11/wayland/pipewire/keyring | ||
if [ -e /usr/lib/systemd/system/[email protected] ]; then | ||
cat << EOF > /usr/lib/systemd/system/[email protected] | ||
[Unit] | ||
Description=User runtime integration for UID %i | ||
After=user@%i.service | ||
Requires=user-runtime-dir@%i.service | ||
[Service] | ||
User=%i | ||
Type=oneshot | ||
ExecStart=sh -c "ln -sf /run/host/run/user/\$(id -ru)/keyring/ /run/user/\$(id -ru)/ ; \ | ||
ln -sf /run/host/run/user/\$(id -ru)/wayland-0 /run/user/\$(id -ru)/ ; \ | ||
ln -sf /run/host/run/user/\$(id -ru)/pipewire-0 /run/user/\$(id -ru)/ ; \ | ||
ln -sf /run/host/run/user/\$(id -ru)/ICEauthority /run/user/\$(id -ru)/ ; \ | ||
ln -sf /run/host/run/user/\$(id -ru)/.mutter* /run/user/\$(id -ru)/" | ||
Slice=user-%i.slice | ||
EOF | ||
|
||
fi | ||
|
||
# Now we can launch init | ||
printf "distrobox: Firing up init system...\n" | ||
printf "container_setup_done\n" | ||
|
||
if [ -e /usr/lib/systemd/systemd ] || [ -e /lib/systemd/systemd ]; then | ||
# Start user systemd unit, this will attempt until systemd is ready | ||
sh -c "while true; do sleep 1; systemctl start user@${container_user_name}.service 2>/dev/null && exit 0; done" & | ||
sh -c "while true; do \ | ||
sleep 1; \ | ||
systemctl start user@${container_user_name}.service 2>/dev/null && \ | ||
systemctl start user-integration@${container_user_name}.service 2>/dev/null && \ | ||
exit 0; \ | ||
done" & | ||
|
||
[ -e /usr/lib/systemd/systemd ] && exec /usr/lib/systemd/systemd --system --log-target=console --unit=multi-user.target | ||
[ -e /lib/systemd/systemd ] && exec /lib/systemd/systemd --system --log-target=console --unit=multi-user.target | ||
|