changes for trisquel 9
[automated-distro-installer] / fai / config / scripts / GRUB_PC / 11-iank
index 45c869d6b17561d4f6307026acbca8cb5656d6d8..9f0c56e19acff9db9037a048abdd01c125564950 100755 (executable)
@@ -58,7 +58,10 @@ fcopy -riBM /etc/apt
 # E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
 # so add a sleep. 1 sec is probably way more than needed.
 sleep 1
-$ROOTCMD apt-get update
+f=$FAI_ROOT/var/cache/apt/pkgcache.bin
+if [[ ! -r $f ]] || (( $(( $(date +%s) - $(stat -c %Y $f ) )) > 60*60*2 )); then
+  $ROOTCMD apt-get update
+fi
 
 
 chroot $FAI_ROOT bash <<'EOF'
@@ -84,7 +87,11 @@ chmod 700 /root/.ssh
 dpkg-reconfigure -fnoninteractive resolvconf
 
 # default jessie groups + kvm, systemd-journal, adm
-usermod -aG adm,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev iank
+for g in adm cdrom floppy sudo audio dip video plugdev netdev; do
+  if getent gropu $g >/dev/null; then
+    usermod -aG $g iank
+  fi
+done
 
 if getent group systemd-journal >/dev/null; then
   usermod -aG systemd-journal iank
@@ -101,7 +108,7 @@ EOF
 if [[ $FAI_ACTION != dirinstall ]]; then
 
 
-  if ifclass BUSTER_LINODE; then
+  if ifclass LINODE; then
     speed=19200
     # luks.crypttab=no see man systemd-cryptsetup-generator
     cmdline="luks.crypttab=no console=ttyS0,${speed}n8"
@@ -126,26 +133,33 @@ terminal_output --append serial
 EOF
 
 
-
   chroot $FAI_ROOT bash <<EOF
 set -eE -o pipefail
 # https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst
 # we remove quiet and splash, and all thats left is what we want
 
-sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT=.*"/GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"/' /etc/default/grub
+if grep -qF "$cmdline" /etc/default/grub; then
+  # already set things, exit
+  exit 0
+fi
+sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"/' /etc/default/grub
 # on xenial, no grub is displayed at all. fix that.
 # found just by noticing this in the config file, and a
 # warning about it in error.log
 sed -i '/^ *GRUB_HIDDEN_TIMEOUT/d' /etc/default/grub
 
 update-grub2
+EOF
 
+  if [[ ! FAI_WRAPPER ]]; then
+    chroot $FAI_ROOT bash <<EOF
 # Just include all of them for now incase we are creating
 # an install for a different machine.. in distro-begin, we
 # slim it down to whats used.
 find /lib/modules/*/kernel/drivers/net /lib/modules/*/kernel/net -type f -name '*.ko' -printf "%f\n" | sed 's/.ko$//' | sort -u >/etc/initramfs-tools/modules
 update-initramfs -u -k all
 EOF
+  fi
 fi