Create /home/$USERNAME in RELEASE class with up2date files from /etc/skel
authorMichael Prokop <mika@grml.org>
Fri, 24 Feb 2017 12:10:18 +0000 (13:10 +0100)
committerMichael Prokop <mika@grml.org>
Fri, 24 Feb 2017 12:14:11 +0000 (13:14 +0100)
Until now we removed everything from /home/grml in the RELEASE
class. The grml-home init script from grml-etc then used to copy
files from /etc/skel to /home/grml during bootup. Instead lets do
this during ISO build time to speed up the boot process. To
ensure that no unwanted files are in /home/grml (actually:
/home/$USERNAME) we remove the directory, recreate it and then
copy all files from /etc/skel.

This fixes the problem that /home/grml is empty and has wrong
permissions if grml-home isn't executed (which is happening
with systemd nowadays where we don't execute grml-home during
bootup).

Closes grml/release-planning#7 @ GH

etc/grml/fai/config/scripts/RELEASE/98-clean-chroot

index 06dfe69..626267f 100755 (executable)
@@ -8,7 +8,7 @@
 
 set -u
 set -e
 
 set -u
 set -e
-
+. "$GRML_LIVE_CONFIG"
 
 echo "Removing /var/lib/apt/lists/*-stuff, dpkg-status-old and pkgcache.bin"
 rm -f $target/var/lib/apt/lists/*Packages \
 
 echo "Removing /var/lib/apt/lists/*-stuff, dpkg-status-old and pkgcache.bin"
 rm -f $target/var/lib/apt/lists/*Packages \
@@ -32,9 +32,13 @@ echo "Removing all files inside /root"
 rm -rf $target/root
 mkdir -m 0755 $target/root
 
 rm -rf $target/root
 mkdir -m 0755 $target/root
 
-echo "Removing all files inside /home/grml"
-rm -rf $target/home/grml
-mkdir -m 0755 $target/home/grml
+echo "Removing all files inside /home/${USERNAME}"
+rm -rf "${target}/home/${USERNAME}"
+mkdir -m 0755 "${target}/home/${USERNAME}"
+$ROOTCMD chown "${USERNAME}:${USERNAME}" "/home/${USERNAME}"
+
+echo "Syncing /home/${USERNAME}/ with data from /etc/skel/:"
+$ROOTCMD su -s /bin/sh "${USERNAME}" -c "rsync -Hav /etc/skel/ /home/${USERNAME}/"
 
 ## END OF FILE #################################################################
 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2
 
 ## END OF FILE #################################################################
 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2