Skip to content

Commit

Permalink
Clean up /run/ at startup and move the directory creation logic to ea…
Browse files Browse the repository at this point in the history
…ch service
  • Loading branch information
hectorm committed Jul 22, 2024
1 parent f70e872 commit 4f81948
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
21 changes: 1 addition & 20 deletions scripts/bin/container-init
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -eu

# Remove leftover files
find /tmp/ -mindepth 1 -delete ||:
find /tmp/ /run/ -mindepth 1 -delete ||:

# Add GPU devices groups to additional groups
for dev in /dev/dri/*; do
Expand Down Expand Up @@ -60,25 +60,6 @@ if [ -w "${UNPRIVILEGED_USER_HOME:?}" ]; then
fi
fi

# Create /run/dbus/ directory if it does not exist
if [ ! -d /run/dbus/ ]; then
mkdir -p /run/dbus/
chmod 755 /run/dbus/
chown messagebus: /run/dbus/
fi

# Create /run/sshd/ directory if it does not exist
if [ ! -d /run/sshd/ ]; then
mkdir -p /run/sshd/
chmod 755 /run/sshd/
fi

# Create /run/udev/ directory if it does not exist
if [ ! -d /run/udev/ ]; then
mkdir -p /run/udev/
chmod 755 /run/udev/
fi

# Create /run/user/${UNPRIVILEGED_USER_UID}/ directory if it does not exist
if [ ! -d /run/user/"${UNPRIVILEGED_USER_UID:?}"/ ]; then
mkdir -p /run/user/"${UNPRIVILEGED_USER_UID:?}"/
Expand Down
4 changes: 4 additions & 0 deletions scripts/service/dbus-daemon/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

set -eu

if [ ! -d /run/dbus/ ]; then
install -m 755 -o messagebus -g messagebus -d /run/dbus/
fi

exec 2>&1
exec chpst -u messagebus dbus-daemon --system --nofork --nopidfile
4 changes: 4 additions & 0 deletions scripts/service/sshd/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

set -eu

if [ ! -d /run/sshd/ ]; then
install -m 755 -o root -g root -d /run/sshd/
fi

exec 2>&1
exec /usr/sbin/sshd -D
4 changes: 4 additions & 0 deletions scripts/service/udevd/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

set -eu

if [ ! -d /run/udev/ ]; then
install -m 755 -o root -g root -d /run/udev/
fi

exec 2>&1
exec /lib/systemd/systemd-udevd

0 comments on commit 4f81948

Please sign in to comment.