diff options
| author | Joe Carstairs <me@joeac.net> | 2026-07-03 09:30:26 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-07-03 09:30:26 +0100 |
| commit | c1525eaa60a3dcc9abf214c2afdd47b2c8163952 (patch) | |
| tree | cefde61cb5e85559f1e8f367d1c275b59c9977ae | |
| parent | dcd2e1cd19e5473233ebe223b906c4200b69bf1e (diff) | |
automatically makes user.USER service for initing XDG_RUNTIME_DIR
| -rw-r--r-- | make/openrc.mk | 4 | ||||
| -rw-r--r-- | openrc/conf.d/.gitignore | 3 | ||||
| -rw-r--r-- | openrc/conf.d/user.example | 3 | ||||
| -rw-r--r-- | openrc/conf.d/user.template | 15 |
4 files changed, 17 insertions, 8 deletions
diff --git a/make/openrc.mk b/make/openrc.mk index 7ca71fe..d3cceee 100644 --- a/make/openrc.mk +++ b/make/openrc.mk @@ -64,8 +64,8 @@ $(foreach module,$(MODULES),$(eval $(openrc_restart_rule))) /etc/init.d/user.$(USER): sudo ln -s /etc/init.d/user /etc/init.d/user.$(USER) -/etc/conf.d/user.$(USER): openrc/conf.d/user.$(USER) - sudo cp openrc/conf.d/user.$(USER) /etc/conf.d/user.$(USER) +/etc/conf.d/user.$(USER): openrc/conf.d/user.template + sudo USER=$(USER)envsubst openrc/conf.d/user.template /etc/conf.d/user.$(USER) sudo rc-update add user.$(USER) default .PHONY: uninstall_joeac.net_service diff --git a/openrc/conf.d/.gitignore b/openrc/conf.d/.gitignore deleted file mode 100644 index de4549a..0000000 --- a/openrc/conf.d/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!.gitignore -!user.example diff --git a/openrc/conf.d/user.example b/openrc/conf.d/user.example deleted file mode 100644 index 6200354..0000000 --- a/openrc/conf.d/user.example +++ /dev/null @@ -1,3 +0,0 @@ -# copy this file to user.<USER> for the user you want to be running joeac.net via OpenRC -# add in here any user setup, bearing in mind that OpenRC doesn't use your usual login flow -# this may include setting up $HOME and/or $XDG_RUNTIME_DIR diff --git a/openrc/conf.d/user.template b/openrc/conf.d/user.template new file mode 100644 index 0000000..2bf637b --- /dev/null +++ b/openrc/conf.d/user.template @@ -0,0 +1,15 @@ +UID="$$(id -u ${USER})" +if test -z "$${XDG_RUNTIME_DIR}"; then + export XDG_RUNTIME_DIR=/tmp/xdg/"$${UID}"-xdg-runtime-dir + if ! test -d "$${XDG_RUNTIME_DIR}"; then + mkdir -p "$${XDG_RUNTIME_DIR}" + chown -R ${USER}:${USER} "$${XDG_RUNTIME_DIR}" + chmod -R 0700 "$${XDG_RUNTIME_DIR}" + fi +fi +if ! test -f "$${XDG_RUNTIME_DIR}/openrc/softlevel"; then + mkdir -p "$${XDG_RUNTIME_DIR}/openrc" + touch "$${XDG_RUNTIME_DIR}/openrc/softlevel" + chown -R ${USER}:${USER} "$${XDG_RUNTIME_DIR}" + chmod -R 0700 "$${XDG_RUNTIME_DIR}" +fi |
