Split off creating and setting up 'home-fix.sh'
This commit is contained in:
53
post-inst.sh
53
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
|
||||
|
||||
Reference in New Issue
Block a user