diff --git a/init.sh b/init.sh index 73b46c8..430f525 100755 --- a/init.sh +++ b/init.sh @@ -838,6 +838,18 @@ initUsers() isNotice "Removed a stale cron spool for $sudo_user_name (recycled uid)." fi sudo rm -f "$spool_dir/easydocker" + + # /home/$sudo_user_name may be owned by a stale uid from a previous install + # (e.g. the EasyDocker rename): useradd doesn't reclaim an existing home dir, + # so files inside — incl. restic's cache dir under ~/.cache/restic — end up + # unreadable by the new manager. restic then logs `mkdir: permission denied` + # every backup (non-fatal but slows them). Same recycled-uid pattern as the + # cron spool above. Idempotent: no-op when ownership already matches. + if [[ -d "/home/$sudo_user_name" \ + && "$(stat -c %u "/home/$sudo_user_name" 2>/dev/null)" != "$mgr_uid" ]]; then + sudo chown -R "$sudo_user_name":"$sudo_user_name" "/home/$sudo_user_name" + isNotice "Reclaimed /home/$sudo_user_name from a stale uid (recycled or rename)." + fi # Install-phase sudo: the heavy install runs AS this user (see the handoff in # completeInitMessage) and needs BROAD root — useradd for the docker-install # user, rootless setup, apt, sysctl, etc. So grant a temporary validated