From d2539a75e72cbb605a1af3f721fac516f8d293fc Mon Sep 17 00:00:00 2001 From: Bart Sjerps Date: Fri, 10 Jul 2026 16:28:39 +0200 Subject: [PATCH] update --- config.yml | 9 +++++---- etc/profile.d/opencode.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 etc/profile.d/opencode.sh diff --git a/config.yml b/config.yml index 2f7c356..6a1ade6 100644 --- a/config.yml +++ b/config.yml @@ -66,14 +66,15 @@ - name: Create Directories file: - path: '{{ item }}' + path: '{{ item.directory }}' state: directory - mode: '0755' + mode: "{{ item.mode | default('0755') }}" owner: root group: root loop: - - /var/backups - - /opt/atclab/bin + - { directory: "/var/backups" } + - { directory: "/opt/atclab/bin" } + - { directory: "/var/user", mode: "1777" } - name: Copy etc configs copy: diff --git a/etc/profile.d/opencode.sh b/etc/profile.d/opencode.sh new file mode 100644 index 0000000..2bc61de --- /dev/null +++ b/etc/profile.d/opencode.sh @@ -0,0 +1,32 @@ +# Redirect XDG data/cache/state to local disk under /var/user/$USER. +# /var/user must allow users to create their own subdirectory. + +# This fixes Opencode on users with home directories on NFS. + + +if [ -n "$USER" ] && [ "$USER" != "root" ]; then + LOCAL_BASE="/var/user/$USER" + + test -d $LOCAL_BASE || mkdir $LOCAL_BASE + + if [ ! -d "$LOCAL_BASE" ]; then + if mkdir -p \ + "$LOCAL_BASE/.local/share" \ + "$LOCAL_BASE/.cache" \ + "$LOCAL_BASE/.local/state" 2>/dev/null + then + chmod 700 "$LOCAL_BASE" \ + "$LOCAL_BASE/.local" \ + "$LOCAL_BASE/.local/share" \ + "$LOCAL_BASE/.local/state" \ + "$LOCAL_BASE/.cache" 2>/dev/null || true + fi + fi + + if [ -d "$LOCAL_BASE" ]; then + export XDG_DATA_HOME="$LOCAL_BASE/.local/share" + export XDG_CACHE_HOME="$LOCAL_BASE/.cache" + export XDG_STATE_HOME="$LOCAL_BASE/.local/state" + fi +fi +