various fixes mostly for linode
[automated-distro-installer] / fai / config / scripts / GRUB_PC / 11-iank
index 45c869d6b17561d4f6307026acbca8cb5656d6d8..8f2c7604e9bfd6b1e150c9cbe33fc7c0d3b01b56 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'
@@ -101,7 +104,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 +129,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