From 648d07f3555f65b73ab781f67b5ac5b6604fc648 Mon Sep 17 00:00:00 2001 From: "Jean (east-high-Nerd)" Date: Wed, 24 Dec 2025 16:14:33 -0500 Subject: [PATCH] Split off creating and setting up 'home-fix.sh' --- home-fix-setup.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++ post-inst.sh | 53 +++--------------------------------------- 2 files changed, 62 insertions(+), 50 deletions(-) create mode 100644 home-fix-setup.sh diff --git a/home-fix-setup.sh b/home-fix-setup.sh new file mode 100644 index 0000000..1dbf819 --- /dev/null +++ b/home-fix-setup.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -euo pipefail + +baseDir="$(realpath "$(dirname "${0}")")" + +source \ + /etc/os-release +source \ + "${baseDir}/system.conf" + + +cat << EOF | tee /usr/bin/home-fix.sh &> /dev/null +#!/bin/bash +set -euo pipefail + +chown -R ${username}:${username} /home/${username} + +sudo -u ${username} cp -a /etc/skel/. /home/${username} + +if [[ ! -z "\$(find -P /home/${username}/ | grep '\.face')" ]]; then + find -P /home/${username}/ | grep '\.face' | xargs -d '\n' -I {} rm {} +fi + +if [[ ! -z "\$(find -P /var/spool/cron | grep 'root')" ]]; then + rm \$(find -P /var/spool/cron | grep 'root') +fi + +printf "\$(date +%Y-%m-%d\ %H:%M:%S) I did the thing\n" | tee /var/log/home-fix.log &> /dev/null + +if [[ -f '/usr/bin/home-fix.sh' ]]; then + rm /usr/bin/home-fix.sh +fi + +zfs snapshot ${hostname,,}/ROOT/${ID}@home-fix + +zfs snapshot -r ${hostname,,}/home/${username}@home-fix +EOF + +chmod \ + +x \ + /usr/bin/home-fix.sh + +if [[ "${ID}" == 'fedora' ]]; then + printf \ + "@reboot\tsudo -u ${username} '${baseDir}/finalize.sh'\n@reboot\t/usr/bin/home-fix.sh\n" | \ + tee /var/spool/cron/root &> /dev/null +elif [[ "${ID}" == 'debian' ]]; then + printf \ + "@reboot\tsudo -u ${username} '${baseDir}/finalize.sh'\n@reboot\t/usr/bin/home-fix.sh\n" | \ + tee /var/spool/cron/crontabs/root &> /dev/null + + chown \ + :crontab \ + /var/spool/cron/crontabs/root + + chmod \ + 0600 \ + /var/spool/cron/crontabs/root +fi diff --git a/post-inst.sh b/post-inst.sh index 553ff37..9ed8437 100755 --- a/post-inst.sh +++ b/post-inst.sh @@ -203,56 +203,9 @@ EOF tee /etc/apt/apt.conf.d/99-apt_moo &> /dev/null fi -if [[ ! "${*}" = *--no-part* ]]; then - cat << EOF | tee /usr/bin/home-fix.sh &> /dev/null -#!/bin/bash -set -euo pipefail - -chown -R ${USERNAME}:${USERNAME} /home/${USERNAME} - -sudo -u ${USERNAME} cp -a /etc/skel/. /home/${USERNAME} - -if [[ ! -z "\$(find -P /home/${USERNAME}/ | grep '\.face')" ]]; then - find -P /home/${USERNAME}/ | grep '\.face' | xargs -d '\n' -I {} rm {} -fi - -if [[ ! -z "\$(find -P /var/spool/cron | grep 'root')" ]]; then - rm \$(find -P /var/spool/cron | grep 'root') -fi - -printf "\$(date +%Y-%m-%d\ %H:%M:%S) I did the thing\n" | tee /var/log/home-fix.log &> /dev/null - -if [[ -f '/usr/bin/home-fix.sh' ]]; then - rm /usr/bin/home-fix.sh -fi - -zfs snapshot ${HOSTNAME,,}/ROOT/${ID}@home-fix - -zfs snapshot -r ${HOSTNAME,,}/home/${USERNAME}@home-fix -EOF - - chmod \ - +x \ - /usr/bin/home-fix.sh - - if [[ "${ID}" == 'fedora' ]]; then - printf \ - "@reboot\tsudo -u ${USERNAME} '${BASEDIR}/finalize.sh'\n@reboot\t/usr/bin/home-fix.sh\n" | \ - tee /var/spool/cron/root &> /dev/null - elif [[ "${ID}" == 'debian' ]]; then - printf \ - "@reboot\tsudo -u ${USERNAME} '${BASEDIR}/finalize.sh'\n@reboot\t/usr/bin/home-fix.sh\n" | \ - tee /var/spool/cron/crontabs/root &> /dev/null - - chown \ - :crontab \ - /var/spool/cron/crontabs/root - - chmod \ - 0600 \ - /var/spool/cron/crontabs/root - fi -fi +# if [[ ! "${*}" = *--no-part* ]]; then + "${baseDir}/home-fix-setup.sh" +# fi if [[ ! -f '/usr/bin/shutdown' ]]; then ln -s /sbin/shutdown /usr/bin/shutdown