various fixes, make settable basefile dir
authorIan Kelling <iank@fsf.org>
Wed, 13 Jun 2018 02:39:41 +0000 (22:39 -0400)
committerIan Kelling <iank@fsf.org>
Wed, 13 Jun 2018 02:39:41 +0000 (22:39 -0400)
README
fai-redep
fai-revm
fai/config/basefiles/mk-basefile
faiserver-setup
grub.cfg.autodiscover [new file with mode: 0644]
myfai-chboot
myfai-chboot-local
mymk-basefile [new file with mode: 0755]

diff --git a/README b/README
index e81a467a3ca9098b788ca7cffdfac84eda94f44f..0333064685972768f67c0ac5b43c7c8aa7ed209a 100644 (file)
--- a/README
+++ b/README
@@ -70,9 +70,10 @@ All scripts meant to be used directly are listed here:
 
 # Scripts to setup the environment for the install
 
 
 # Scripts to setup the environment for the install
 
+sudo fai-cd grub.cfg.autodiscover -f -A $BASEFILE_DIR/autodiscover.iso # create autodiscover cd
+mymk-basefile # Create basefiles for various distros
 arch-pxe # Setup arch pxe boot server from an arch base image
 fai-redep # Deploy fai configuration to host "faiserver"
 arch-pxe # Setup arch pxe boot server from an arch base image
 fai-redep # Deploy fai configuration to host "faiserver"
-faiserver-revm # using pxe & preseed, create a vm which is a fai server
 faiserver-uninstall # uninstall fai-server
 faiserver-setup # install fai-server on the current machine
 myfai-chboot # setup fai tftp and nfs. useful for doing pxe-kexec
 faiserver-uninstall # uninstall fai-server
 faiserver-setup # install fai-server on the current machine
 myfai-chboot # setup fai tftp and nfs. useful for doing pxe-kexec
@@ -82,6 +83,7 @@ wrt-setup  # setup my router in general: dhcp, dns, etc.
 
 # Script to do a distro install
 
 
 # Script to do a distro install
 
+faiserver-revm # using pxe & preseed, create a vm which is a fai server
 dsfull # install & post-install a new fai distro
 arch-init-remote # install arch after it's been booted into it's setup env
 fai-kexec # Kexec this or a remote machine using host faiserver
 dsfull # install & post-install a new fai distro
 arch-init-remote # install arch after it's been booted into it's setup env
 fai-kexec # Kexec this or a remote machine using host faiserver
index 5306d9736707a8b683e9fdb4da8be9a57889659f..3e1263d39551582d085adb46560588389ec20b68 100755 (executable)
--- a/fai-redep
+++ b/fai-redep
@@ -41,7 +41,7 @@ distro=$2
 # use it, so look it up just to avoid the warning spam.
 faiserver_host=$(chost $host) || faiserver_host=$host
 
 # use it, so look it up just to avoid the warning spam.
 faiserver_host=$(chost $host) || faiserver_host=$host
 
-rsync -rlp --delete --relative --exclude /fai/config/basefiles/ fai/config root@$faiserver_host:/srv
+rsync -rlpt --delete --relative --exclude /fai/config/basefiles/ fai/config root@$faiserver_host:/srv
 
 
 scp -q ~/.ssh/home.pub \
 
 
 scp -q ~/.ssh/home.pub \
@@ -62,10 +62,9 @@ pall+=($(/a/bin/buildscripts/emacs -p; /a/bin/distro-setup/distro-pkgs $distro))
   ssh root@$faiserver_host dd of=/srv/fai/config/package_config/DESKTOP 2>/dev/null ||: # broken pipe
 
 
   ssh root@$faiserver_host dd of=/srv/fai/config/package_config/DESKTOP 2>/dev/null ||: # broken pipe
 
 
-rsync -rplt --delete /a/bin/fai-basefiles/basefiles root@$faiserver_host:/srv/fai/config
+rsync -rplt --delete $BASEFILE_DIR/*.gz root@$faiserver_host:/srv/fai/config/basefiles/
 ssh root@$faiserver_host bash <<'EOF'
 set -eE -o pipefail
 ssh root@$faiserver_host bash <<'EOF'
 set -eE -o pipefail
-set -x
 # make it the root because pxe-kexec only looks there.
 # It wouldn't be too hard to change if we needed.
 # We could also just dump things in /srv/tftp, but fai
 # make it the root because pxe-kexec only looks there.
 # It wouldn't be too hard to change if we needed.
 # We could also just dump things in /srv/tftp, but fai
index 30f541995fc98e2e43ebf83c4f01cbf0af767e86..79333773f6bf63a4d6437bc210e8b0e5123ebf6c 100755 (executable)
--- a/fai-revm
+++ b/fai-revm
@@ -101,7 +101,13 @@ else
     sleep 2
   else
     fai-monitor&
     sleep 2
   else
     fai-monitor&
-    boot_arg="--cdrom /a/bin/fai-basefiles/autodiscover.iso"
+    if [[ $BASEFILE_DIR ]]; then
+      BASEFILE_DIR=/tmp
+    fi
+    if [[ ! -e $BASEFILE_DIR/autodiscover.iso ]]; then
+      fai-cd grub.cfg.autodiscover -f -A $BASEFILE_DIR/autodiscover.iso
+    fi
+    boot_arg="--cdrom $BASEFILE_DIR/autodiscover.iso"
     e fai-redep
     e myfai-chboot default
   fi
     e fai-redep
     e myfai-chboot default
   fi
@@ -158,7 +164,7 @@ while ! timeout -s 9 10 ssh -oBatchMode=yes root@$name /bin/true; do
   e sleep 5
 done
 unset _errcatch_cleanup
   e sleep 5
 done
 unset _errcatch_cleanup
-e pxe-server
+e ./pxe-server $dhcp_arg
 if is_arch_revm; then
   ./arch-init-remote $name
 fi
 if is_arch_revm; then
   ./arch-init-remote $name
 fi
index ccfd3677ec218fb7086eec123a33d7e6a2adc3ba..8f2bd4aaf78c4e253c9d64b69edbd0e6b1a7d55e 100755 (executable)
@@ -1,5 +1,4 @@
 #! /bin/bash
 #! /bin/bash
-set -x
 # mk-basefile, create basefiles for some distributions
 #
 # Thomas Lange, Uni Koeln, 2011-2017
 # mk-basefile, create basefiles for some distributions
 #
 # Thomas Lange, Uni Koeln, 2011-2017
index 28e71e370dacc61542200f8ceac48c55c7a27797..b9fe68f037cf7c6f5e8821e3d61e0106289de7a3 100755 (executable)
@@ -30,8 +30,7 @@ that using a hostname does not work.
 Separate from running this, faiserver needs to be setup in dns
 to point to whatever host this is run on.
 
 Separate from running this, faiserver needs to be setup in dns
 to point to whatever host this is run on.
 
-For running on arm, it expects Ian's fai-basefiles repository at
-/a/bin/fai-basefiles
+It expects $BASEFILE_DIR/STRETCH64.tar.gz to exist.
 
 EOF
   exit $1
 
 EOF
   exit $1
@@ -186,7 +185,7 @@ fi
 if armhf; then
   cd /srv/fai
   rm -rf nfsroot
 if armhf; then
   cd /srv/fai
   rm -rf nfsroot
-  tar Jxf /a/bin/fai-basefiles/basefiles/STRETCH64.tar.xz
+  tar Jxf $BASEFILE_DIR/STRETCH64.tar.xz
   # background: Can't build the nfsroot on my arm system now.  First,
   # fai-make-nfsroot won't work out of the box. One idea to make it work
   # is by installing qemu-user-static, then copying qemu-x86_64-static
   # background: Can't build the nfsroot on my arm system now.  First,
   # fai-make-nfsroot won't work out of the box. One idea to make it work
   # is by installing qemu-user-static, then copying qemu-x86_64-static
@@ -242,7 +241,7 @@ EOF
 else # not armhf
   # note, this copies the -B arg to
   # /srv/fai/nfsroot/var/tmp/base.tar.xz
 else # not armhf
   # note, this copies the -B arg to
   # /srv/fai/nfsroot/var/tmp/base.tar.xz
-  e fai-setup -evf -B /a/bin/fai-basefiles/basefiles/STRETCH64.tar.gz
+  e fai-setup -evf -B $BASEFILE_DIR/STRETCH64.tar.gz
   # fai-setup expert mode avoids writing to /var/log/fai/variables
   # at least config_src is needed for autodiscover
   $sed '/^FAI_CONFIGDIR|^FAI_CONFIG_SRC|^LOGUSER/d' /var/log/fai/variables
   # fai-setup expert mode avoids writing to /var/log/fai/variables
   # at least config_src is needed for autodiscover
   $sed '/^FAI_CONFIGDIR|^FAI_CONFIG_SRC|^LOGUSER/d' /var/log/fai/variables
diff --git a/grub.cfg.autodiscover b/grub.cfg.autodiscover
new file mode 100644 (file)
index 0000000..b1516bb
--- /dev/null
@@ -0,0 +1,87 @@
+## grub2 configuration
+set default="FAI server via dns"
+set timeout=2
+set resolution=1024x768
+
+if loadfont /boot/grub/unicode.pf2 ; then
+   insmod png
+   set gfxmode=640x480
+   insmod gfxterm
+   insmod vbe
+   terminal_output gfxterm
+fi
+
+if background_image /boot/grub/fai.png ; then
+  set color_normal=black/black
+  set color_highlight=red/black
+  set menu_color_normal=black/black
+  set menu_color_highlight=black/yellow
+else
+  set menu_color_normal=white/black
+  set menu_color_highlight=black/yellow
+fi
+
+# make sure we can access partitions
+insmod part_msdos
+insmod part_gpt
+
+if [ ${iso_path} ] ; then
+    set loopback="findiso=${iso_path}"
+fi
+
+menuentry "" --unrestricted {
+    set gfxpayload=$resolution
+}
+menuentry "        +------------------------------------------------------+" --unrestricted {
+    set gfxpayload=$resolution
+}
+
+menuentry "        |        Fully  Automatic  Installation                |" --unrestricted {
+    set gfxpayload=$resolution
+
+}
+menuentry "        |     _VERSIONSTRING_     |" --unrestricted {
+    set gfxpayload=$resolution
+
+}
+menuentry "        |        (c) Thomas Lange  lange@debian.org            |" --unrestricted {
+    set gfxpayload=$resolution
+}
+menuentry "        +------------------------------------------------------+" --unrestricted {
+    set gfxpayload=$resolution
+}
+}
+menuentry "" --unrestricted {
+    set gfxpayload=$resolution
+}
+
+menuentry "Autodiscover the FAI server" {
+    set gfxpayload=$resolution
+    linux   /boot/vmlinuz FAI_FLAGS="menu,verbose,createvt" fai.discover aufs rootovl root=/dev/nfs ip=dhcp quiet
+    initrd  /boot/initrd.img
+}
+
+# ian: Added this from fai
+# note, we could replace faiserver with an ip if we didn't want to mess with dns.
+# args are copied from myfai-chboot-local
+menuentry "FAI server via dns" {
+    set gfxpayload=$resolution
+    linux   /boot/vmlinuz FAI_FLAGS=verbose,sshd,createvt,reboot FAI_CONFIG_SRC=nfs://faiserver/srv/fai/config root=/dev/nfs rw nfsroot=faiserver:/srv/fai/nfsroot,vers=3,nolock aufs rootovl ip=dhcp FAI_FLAGS=verbose,sshd,createvt,reboot
+    initrd  /boot/initrd.img
+}
+
+
+menuentry "Boot OS of first partition on first disk" --unrestricted {
+    if [ -d (cd) ]; then
+       chainloader (hd0)+1
+    fi
+
+    if [ "$root" = "hd1" ]; then
+       chainloader (hd0)+1
+    fi
+
+    if [ "$root" = "hd0" ]; then
+       set root=(hd1)
+       chainloader (hd1)+1
+   fi
+}
index 0d036b9160749f23f4bb237ed280f78f192e0371..cbba8b5b97abe269d5e4b41b138e9b31fd1256aa 100755 (executable)
@@ -29,9 +29,6 @@ to disable the nfs server.
 EOF
   exit $1
 }
 EOF
   exit $1
 }
-if [[ ! $1 ]]; then
-  usage 1
-fi
 case $1 in
   -h|--help) usage ;;
 esac
 case $1 in
   -h|--help) usage ;;
 esac
index 49ee6f6efcb6c9ce9ad67d7f30fee83fab3f35c7..f46c32d9308c33a4277402cd6a9e1818848708aa 100755 (executable)
@@ -35,6 +35,11 @@ e() {
 
 host=$1
 
 
 host=$1
 
+rm -f /srv/tftp/fai/pxelinux.cfg/*
+if [[ ! $1 ]]; then
+  exit 0
+fi
+
 # assuming ipv4, or else we might need to deal with multiple addresses
 # in an ipv4 + ipv6 network.
 my_ip=$(ip -4 route get 8.8.8.8 | sed -nr 's,^.*src\s+(\S+).*,\1,p')
 # assuming ipv4, or else we might need to deal with multiple addresses
 # in an ipv4 + ipv6 network.
 my_ip=$(ip -4 route get 8.8.8.8 | sed -nr 's,^.*src\s+(\S+).*,\1,p')
@@ -88,10 +93,6 @@ else
 EOF
 fi
 
 EOF
 fi
 
-rm -f /srv/tftp/fai/pxelinux.cfg/*
-if [[ ! $1 ]]; then
-  exit 0
-fi
 
 
 # man page doesn't explain this, but this deletes & thus disables
 
 
 # man page doesn't explain this, but this deletes & thus disables
diff --git a/mymk-basefile b/mymk-basefile
new file mode 100755 (executable)
index 0000000..2a7f453
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
+script_dir="${x%/*}"
+
+usage() {
+  cat <<EOF
+Usage: ${0##*/} [-h|--help] [mk-basefile_args]
+Wrap fai's mk-basefile so output dir is $BASEFILE_DIR if it exists.
+
+And fix things for trisquel. mk-basefile has a trisquel mirror added.
+
+fai-project maintains ubuntu and debian basefiles, but it doesn't update
+them often. Better to build our all our own.
+
+
+Args I've used before:
+
+-z STRETCH64
+-z XENIAL64
+-z FLIDAS64
+-z BELENOS64
+
+-h|--help  Print help and exit.
+
+Note: Uses GNU getopt options parsing style
+EOF
+  $script_dir/fai/config/basefiles/mk-basefile -h
+  exit $1
+}
+
+case $1 in
+  -h|--help)
+    usage
+    ;;
+esac
+
+if [[ $EUID != 0 ]]; then
+  s=sudo
+fi
+
+cd /usr/share/debootstrap/scripts
+for d in belenos flidas; do
+  if [[ ! -L $d && ! -e $d ]]; then
+    $s ln -sf gutsy $d;
+  fi
+done
+
+if [[ $BASEFILE_DIR ]]; then
+  cd $BASEFILE_DIR
+fi
+
+$s $script_dir/fai/config/basefiles/mk-basefile "$@"