Merge branch 'upstream'
authorIan Kelling <ian@iankelling.org>
Tue, 7 Feb 2017 00:21:31 +0000 (16:21 -0800)
committerIan Kelling <ian@iankelling.org>
Thu, 9 Feb 2017 21:37:33 +0000 (13:37 -0800)
merges upstream example config 5.3.4~bpo8+1

1  2 
fai-revm
fai/config/basefiles/mk-basefile
fai/config/package_config/DEBIAN
fai/config/package_config/FAIBASE
fai/config/package_config/UBUNTU
fai/config/scripts/DEBIAN/20-capabilities
fai/config/scripts/DEBIAN/30-interface
fai/config/scripts/DEBIAN/40-misc
fai/config/scripts/GRUB_PC/10-setup
fai/config/scripts/LAST/50-misc

diff --combined fai-revm
index 97b6338ff1f97e9d64871c39ed9f628c98d6c132,0000000000000000000000000000000000000000..cc494cccb2c424293cf95ca05383b4c9dd44a3a7
mode 100755,000000..100755
--- /dev/null
+++ b/fai-revm
@@@ -1,138 -1,0 +1,139 @@@
 +#!/bin/bash -l
 +# Copyright (C) 2016 Ian Kelling
 +
 +# This program is free software; you can redistribute it and/or
 +# modify it under the terms of the GNU General Public License
 +# as published by the Free Software Foundation; either version 2
 +# of the License, or (at your option) any later version.
 +
 +# This program is distributed in the hope that it will be useful,
 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +# GNU General Public License for more details.
 +
 +# You should have received a copy of the GNU General Public License
 +# along with this program; if not, write to the Free Software
 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 +
 +
 +
 +cleanup() { :; }
 +set -eE -o pipefail
 +trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 +script_dir=$(dirname $(readlink -f "$BASH_SOURCE"))
 +
 +e() { echo "$*"; "$@"; }
 +
 +
 +usage() {
 +    cat <<EOF
 +# Usage: ${0##*/} [OPTIONS]
 +Setup fai or arch pxe (depending on $0 name)
 +then start a virtual machine to test the config
 +
 +Note, sometimes shutting down the existing demohost vm
 +fails. Just run again if that happens.
 +
 +-r         Do not reboot.
 +-n         Create new qcow2(s) for vm
 +-h|--help  Print help and exit.
 +
 +Note: Uses GNU getopt options parsing style
 +EOF
 +    exit $1
 +}
 +
 +
 +new_disk=false
 +reboot=true
 +temp=$(getopt -l help hnr "$@") || usage 1
 +eval set -- "$temp"
 +while true; do
 +    case $1 in
 +        -n) new_disk=true; shift ;;
 +        -r) reboot=false; shift ;;
 +        -h|--help) usage ;;
 +        --) shift; break ;;
 +        *) echo "$0: Internal error!" ; exit 1 ;;
 +    esac
 +done
 +
 +
 +# change this to test different disk counts. 1 and > 1 should be the only
 +# important things to test.
 +disk_count=1
 +
 +
 +if [[ $script_dir == /a/bin/* ]]; then
 +    # Copy our script elsewhere so we can develop it
 +    # and save it at the same time it's running
 +    rm -rf /tmp/faifreeze
 +    mkdir -p /a/tmp
 +    cp -ar /a/bin/fai /tmp/faifreeze
 +    exec /tmp/faifreeze/${BASH_SOURCE##*/} "$@"
 +fi
 +
 +cd $script_dir
 +
 +is_arch_revm() {
 +    [[ ${0##*/} == arch-revm ]]
 +}
 +
 +cleanup() { ./pxe-server; }
 +if is_arch_revm; then
 +    ./pxe-server demohost arch
 +    sleep 2
 +    # via osinfo-query os. guessing arch is closest to latest fedora.
 +    variant=fedora22
 +else
 +    ./pxe-server demohost fai
 +    sleep 2
 +    # I don't think these variants actually make a diff for us, but I
 +    # use the appropriate one when trying a new distro just in case.
 +    variant=ubuntu14.04
 +    #variant=ubuntu16.04
 +    #variant=debian8
 +fi
 +
 +name=demohost
 +
 +e s virshrm $name ||:
 +
 +
 +disk_arg=()
 +for ((i=1; i <= disk_count; i++)); do
 +    f=/var/lib/libvirt/images/${name}$i
 +    disk_arg+=("--disk path=$f")
 +    if $new_disk || [[ ! -e $f ]]; then
 +        s rm -f $f
 +        e s qemu-img create -o preallocation=metadata -f qcow2 $f 20G
 +    fi
 +done
 +
 +if [[ $SSH_CLIENT ]]; then
 +    console_arg=--noautoconsole
 +fi
 +
 +# --cpu host: this causes mkfs.btrfs to fail with a stack trace which began
 +# something like:
 +# init_module+0x108/0x1000 [raid6_pq]
 +#
 +# uniq is to stop gtk-warning spam
 +e s virt-install --os-variant $variant  -n $name --pxe -r 2048 --vcpus 1 \
 +  ${disk_arg[*]} -w bridge=br0,mac=52:54:00:9c:ef:ad \
 +  --graphics spice,listen=0.0.0.0 $console_arg |& grep -v '^ *$' | uniq &
 +
 +if [[ $SSH_CLIENT ]]; then
 +    fg
 +fi
 +
 +sleep 30
 +while ! timeout -s 9 10 ssh root@$name /bin/true; do
 +    e sleep 5
++    khfix root@$name ||:
 +done
 +cleanup() { :; }
 +e pxe-server
 +if is_arch_revm; then
 +    ./arch-init-remote $name
 +fi
index a61010a59cfe3d1654cff8770b19d5ce2e2312c6,6d6cfca3700791aa69ea37c7f89d627196800411..15fbf768fc3be6feae23a6dbdcfda1136f5f4216
@@@ -2,11 -2,8 +2,8 @@@
  
  # mk-basefile, create basefiles for some distributions
  #
- # Thomas Lange, Uni Koeln, 2011-2015
+ # Thomas Lange, Uni Koeln, 2011-2016
  # based on the Makefile implementation of Michael Goetze
- #
- # Usage example:  fai-mk-basefile -J SQUEEZE64
- # This will create a SQUEEZE64.tar.xz basefile.
  
  # Supported distributions (each i386/amd64):
  # Debian GNU/Linux
  
  # Define your local mirros here
  # For the first stage, set the CentOS/SLC mirror in /etc/rinse/rinse.conf
 -MIRROR_DEBIAN=http://httpredir.debian.org/debian/
 +MIRROR_DEBIAN=http://http.us.debian.org/debian
- #MIRROR_DEBIAN=http://localmirror/debian/
  MIRROR_UBUNTU=http://mirror.netcologne.de/ubuntu/
 +MIRROR_TRISQUEL=http://mirror.fsf.org/trisquel/
  MIRROR_CENTOS=http://mirror.netcologne.de/
- #MIRROR_CENTOS=http://localmirror
- #MIRROR_SLC=http://localmirror
  
  EXCLUDE_SQUEEZE=isc-dhcp-client,isc-dhcp-common,info,tasksel,tasksel-data
- EXCLUDE_WHEEZY=isc-dhcp-client,isc-dhcp-common,info,tasksel,tasksel-data
- EXCLUDE_JESSIE=isc-dhcp-client,isc-dhcp-common,info,tasksel,tasksel-data
+ EXCLUDE_WHEEZY=info,tasksel,tasksel-data
+ EXCLUDE_JESSIE=tasksel,tasksel-data
+ EXCLUDE_STRETCH=tasksel,tasksel-data
 -
 +EXCLUDE_BELENOS=dhcp3-client,dhcp3-common,info
  EXCLUDE_TRUSTY=dhcp3-client,dhcp3-common,info
- EXCLUDE_XENIAL=isc-dhcp-client,isc-dhcp-common,udhcpc,dibbler-client,dhcpcd5,info,tasksel,tasksel-data
+ EXCLUDE_XENIAL=tasksel,tasksel-data
  
  INCLUDE_DEBIAN=aptitude
  
@@@ -126,7 -120,7 +121,7 @@@ cleanup-rinse() 
  
  tarit() {
  
-     tar --xattrs --selinux --acl --one-file-system -C $xtmp -cf - . | $zip > $target.$ext
+     tar $attributes --one-file-system -C $xtmp -cf - . | $zip > $target.$ext
  }
  
  
@@@ -160,80 -154,30 +155,30 @@@ slc() 
  }
  
  
- squeeze() {
-     local arch=$1
-     check
-     debootstrap --arch $arch --exclude=${EXCLUDE_SQUEEZE} squeeze $xtmp ${MIRROR_DEBIAN}
-     cleanup-deb
-     tarit
- }
+ debgeneric() {
  
- wheezy() {
-     local arch=$1
-     check
-     debootstrap --arch $arch --exclude=${EXCLUDE_WHEEZY} wheezy $xtmp ${MIRROR_DEBIAN}
-     cleanup-deb
-     tarit
- }
- jessie() {
-     local arch=$1
-     check
-     debootstrap --arch $arch --exclude=${EXCLUDE_JESSIE} --include=${INCLUDE_DEBIAN} jessie $xtmp ${MIRROR_DEBIAN}
-     cleanup-deb
-     tarit
- }
- stretch() {
-     local arch=$1
-     check
-     debootstrap --arch $arch --exclude=${EXCLUDE_JESSIE} --include=${INCLUDE_DEBIAN} stretch $xtmp ${MIRROR_DEBIAN}
-     cleanup-deb
-     tarit
- }
- trusty() {
-     local arch=$1
-     check
-     debootstrap --arch $arch --exclude=${EXCLUDE_TRUSTY} --include=${INCLUDE_DEBIAN} trusty $xtmp ${MIRROR_UBUNTU}
-     cleanup-deb
-     tarit
- }
- xenial() {
-     local arch=$1
-     check
-     debootstrap --arch $arch --exclude=${EXCLUDE_XENIAL} --include=${INCLUDE_DEBIAN} xenial $xtmp ${MIRROR_UBUNTU}
-     cleanup-deb
-     tarit
- }
+     local DIST=$1
+     shift
+     local mirror=$1
  
+     if [[ $DIST =~ 64 ]]; then
+         arch=amd64
+     else
+         arch=i386
+     fi
  
- belenos() {
-     ln -sf gutsy /usr/share/debootstrap/scripts/belenos
-     local arch=$1
+     DIST=${DIST%%??}
+     dist=${DIST,,}
  
+     local exc="EXCLUDE_$DIST"
      check
-     debootstrap --arch $arch --exclude=${EXCLUDE_BELENOS} --include=${INCLUDE_DEBIAN} belenos $xtmp ${MIRROR_TRISQUEL}
+     debootstrap --arch $arch --exclude=${!exc} --include=${INCLUDE_DEBIAN} $dist $xtmp $mirror
      cleanup-deb
      tarit
  }
  
unknown() {
prtdists() {
  
-     echo "Unknown distribution. Aborting."
      echo "Available:
  
      CENTOS5_32   CENTOS5_64
      SQUEEZE32    SQUEEZE64
      WHEEZY32     WHEEZY64
      JESSIE32     JESSIE64
+     STRETCH32    STRETCH64
  "
-     exit 99
  }
  
+ usage() {
+     cat <<EOF
+ mk-basefile, create minimal base files for a Linux distritubtion
+    Copyright (C) 2011-2016 by Thomas Lange
+ Usage: mk-basefile [OPTION] ... DISTRIBUTION
+    -s                   Show list of supported linux distributions
+    -a                   Add xtattrs, acl and selinux properties to the tar file.
+    -d DIR               Use DIR for creating the temporary subtree structure.
+    -z                   Use gzip for compressing the tar file.
+    -J                   Use xz for compressing the tar file.
+    -k                   Keep the temporary subtree structure, do not remove it.
+    -h                   Print help.
+  Usage example: mk-basefile -J STRETCH64
+  This will create a STRETCH64.tar.xz basefile.
+ EOF
+     exit 0
+ }
  
  # main routine
  
  ext=tar
  zip=cat
- tmpdir=/var/tmp
+ attributes=
+ cleanup=1
  
- while getopts zJd: opt ; do
+ while getopts ashzJd:k opt ; do
      case "$opt" in
-         d) tmpdir=$OPTARG ;;
+         a) attributes="--xattrs --selinux --acl" ;;
+         d) export TMPDIR=$OPTARG ;;
          z) zip="gzip -9"; ext=tar.gz ;;
          J) zip="xz -8" ext=tar.xz ;;
+         k) cleanup=0 ;;
+         h) usage ;;
+         s) prtdists ; exit 0;;
+         ?) exit 3 ;; # error in option parsing
      esac
  done
  shift $(($OPTIND - 1))
  
- xtmp=$(mktemp -d $tmpdir/basefiles.XXXXXXXX)
+ xtmp=$(mktemp --tmpdir -d basefiles.XXXXXXXX)
  if [ $? -eq 1 ]; then
      echo "mktemp failed. Aborting."
      exit 2
@@@ -287,20 -260,16 +261,18 @@@ case "$target" i
      SLC6_32) slc i386 6 ;;
      SLC6_64) slc amd64 6 ;;
      SLC7_64) slc amd64 7 ;;
-     TRUSTY32) trusty i386 ;;
-     TRUSTY64) trusty amd64 ;;
-     BELENOS64) belenos amd64 ;;
-     XENIAL32) xenial i386 ;;
-     XENIAL64) xenial amd64 ;;
-     SQUEEZE32) squeeze i386 ;;
-     SQUEEZE64) squeeze amd64 ;;
-     WHEEZY32) wheezy i386 ;;
-     WHEEZY64) wheezy amd64 ;;
-     JESSIE32) jessie i386 ;;
-     JESSIE64) jessie amd64 ;;
-     STRETCH64) stretch amd64 ;;
-     *) unknown ;;
++    BELANOS*)
++        debgeneric $target $MIRROR_TRISQUEL ;;
+     TRUSTY*|XENIAL*)
+         debgeneric $target $MIRROR_UBUNTU ;;
+     SQUEEZE*|WHEEZY*|JESSIE*|STRETCH*)
+         debgeneric $target $MIRROR_DEBIAN ;;
+     *) echo "Unknown distribution. Aborting."
+        prtdists
+        exit 99 ;;
  esac
  
  # cleanup
- rm -rf $xtmp
+ if [ $cleanup -eq 1 ]; then
+    rm -rf $xtmp
+ fi
index 1402c4f831cf36ccbd81ba6bb2ab3c7920ce11b4,bdec0d61b64c6c54b89a8ded58ec9c548f48475b..d3dc95e4052119ce48cb22d3da9aaeb405d7e559
@@@ -13,8 -13,14 +13,16 @@@ memtest86
  PACKAGES install DHCPC
  isc-dhcp-client
  
++# ian: note everything after the grub package should be refactored into
++# a new class.
  PACKAGES install GRUB_PC
- grub-pc cryptsetup btrfs-tools sudo bridge-utils netcat-openbsd grub-legacy- lilo-
 -grub-pc
++grub-pc cryptsetup btrfs-tools sudo bridge-utils netcat-openbsd
+ PACKAGES install GRUB_EFI
 -grub-efi
++grub-efi cryptsetup btrfs-tools sudo bridge-utils netcat-openbsd
  
  PACKAGES install LVM
  lvm2
+ PACKAGES install CLOUD
+ locales-all
index cab58ba8a9ad04fa4a63e2fbe229c99bac6ed265,e4851b16134994023732b7d80dfe515155e990aa..98881756fb4c28d246cdd06fb77e948629f75266
@@@ -1,6 -1,5 +1,5 @@@
- PACKAGES aptitude DEBIAN UBUNTU
 -PACKAGES install-norec DEBIAN
++PACKAGES install-norec DEBIAN UBUNTU
  fai-client
- cron
  debconf-utils
  file
  less
@@@ -8,7 -7,6 +7,6 @@@ linuxlog
  rdate
  rsync
  openssh-client openssh-server
- strace
  time
  procinfo
  nullmailer
index 697224d8b7cd539154af75740ae3138430fdcda2,afd01e721465ee42aaf20a63a10554c6413adec2..1c7f8e0aa826c13035d87e5ba721c6d7a6c26690
@@@ -13,9 -13,9 +13,9 @@@ PACKAGES install DHCP
  isc-dhcp-client
  
  PACKAGES install GRUB_PC
 -grub-pc
 +grub-pc cryptsetup btrfs-tools bridge-utils netcat-openbsd
  
- PACKAGES aptitude-r XORG
+ PACKAGES install XORG
  ubuntu-desktop
  ubuntu-standard
  ubuntu-minimal
index 0b3e2e513b95c9db8af89042593b435fbe0bdb03,ea650fa984a90231f58afccd6b056c0e05a761d8..b057587a65d9f5328592f7c1772a0b384576a125
@@@ -4,9 -4,6 +4,9 @@@
  # Restore them here.
  #
  
 +# note on an ubuntu 16.04 system, these caps were set without this script
 +# running. I wonder if it is actually needed on a debian 8 system.
 +
  set -e
  
  if [ ! -x $target/sbin/setcap ] ; then
@@@ -14,7 -11,7 +14,7 @@@
  fi
  
  for FILE in /bin/ping /bin/ping6 /usr/bin/fping /usr/bin/fping6; do
-     if [ -x $target/$FILE ] ; then
+     if [ -x $target/$FILE -a ! -h $target/$FILE ] ; then
          if $ROOTCMD /sbin/setcap cap_net_raw+ep $FILE; then
              echo "Setcap worked! $FILE is not suid!"
          fi
index e249b6746cd3f7d6eb893263a46922a96c761a80,924b2363ab7ff6ef4085b1146ee629b1b4902772..832461cbb7d6a7083d4153bedf85151355f2d971
@@@ -1,77 -1,52 +1,77 @@@
  #! /bin/bash
  
 +# modified from upstream fai example
  error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
  
- if ! ifclass STABLE; then
 -
+ newnicnames() {
+     # determine predictable network names only for stretch and above
+     [ $do_init_tasks -eq 0 ] && return
+     ver=$($ROOTCMD dpkg-query --showformat='${Version}' --show udev)
+     if dpkg --compare-versions $ver lt 220-7; then
+       return
+     fi
+     [ -z $NIC1 ] && return
+     fields="ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH"
+     for field in $fields; do
+       name=$(udevadm info /sys/class/net/$NIC1 | sed -rn "s/^E: $field=(.+)/\1/p")
+       if [[ $name ]]; then
+           NIC1=$name
+           break
+       fi
+     done
 +    if ifclass VM; then
-         # older distro still uses eth0
-         if ifclass BELENOS64; then
-             NIC1=eth0
-         else
-             # For a vm, we only get  ID_NET_NAME_MAC from below,
-             # but when it reboots, it uses ID_NET_NAME_SLOT.
-             NIC1=ens3
-         fi
-     else
-         # get persistent interface name. Note, these class conditions
-         # will need to get modified for new oses. testing vm doesn't use
-         # it right now, but other vms do I'm sure.
-         for field in ID_NET_NAME_FROM_DATABASE \
-                          ID_NET_NAME_ONBOARD \
-                          ID_NET_NAME_SLOT \
-                          ID_NET_NAME_PATH \
-                          ID_NET_NAME_MAC; do
-             name=$(udevadm info /sys/class/net/$NIC1 | sed -rn "s/^E: $field=(.+)/\1/p")
-             if [[ $name ]]; then
-                 NIC1=$name
-                 break
-             fi
-         done
-         if [[ ! $name ]]; then
-             echo "$0: error: could not find systemd predictable network name"
-             exit 1
-         fi
++        NIC1=ens3
++        return
 +    fi
- fi
+     if [[ ! $name ]]; then
+       echo "$0: error: could not find systemd predictable network name. Using $NIC1."
+     fi
+ }
+ newnicnames
+ CIDR=$(ip -o -f inet addr show $NIC1 | awk '{print $4}')
+ if ifclass DHCPC && [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]; then
  
- if ifclass DHCPC && [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
- then
 -    cat > $target/etc/network/interfaces <<-EOF
 +    if ifclass VM; then
++
++        # note, this condition would apply to the elif below too,
++        # but I don't specify a static ip in fai, so not bothering
 +        cat > $target/etc/network/interfaces <<-EOF
-         # generated by FAI
-         auto lo $NIC1
-         iface lo inet loopback
-         iface $NIC1 inet dhcp
+       # generated by FAI
+       auto lo $NIC1
+       iface lo inet loopback
+       iface $NIC1 inet dhcp
  EOF
- elif [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]
- then
-     [ -n "$IPADDR" ] && cat > $target/etc/network/interfaces <<-EOF
-         # generated by FAI
-         auto lo $NIC1
-         iface lo inet loopback
-         iface $NIC1 inet static
-           address $IPADDR
-           netmask $NETMASK
-           broadcast $BROADCAST
-           gateway $GATEWAYS
 +    else
 +        cat > $target/etc/network/interfaces <<-EOF
 +        # generated by FAI
 +        auto lo br0
 +        iface lo inet loopback
 +        iface $NIC1 inet manual
 +        # make a bridge by default so we can have bridged vms.
 +        # Some example I read had stp on, but i don't need stp,
 +        # and it causes a vm to fail pxe boot, presumably unless
 +        # you add some delay.
 +        # http://wiki.libvirt.org/page/PXE_boot_%28or_dhcp%29_on_guest_failed
 +        iface br0 inet dhcp
 +          bridge_ports $NIC1
 +          bridge_stp off
 +          bridge_maxwait 0
 +EOF
 +    fi
 -      [ -n "$CIDR" ] && cat > $target/etc/network/interfaces <<-EOF
+ elif [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ]; then
++    [ -n "$CIDR" ] && cat > $target/etc/network/interfaces <<-EOF
+       # generated by FAI
+       auto lo $NIC1
+       iface lo inet loopback
+       iface $NIC1 inet static
+         address $CIDR
+         gateway $GATEWAYS
  EOF
      [ -n "$NETWORK" ] && echo "localnet $NETWORK" > $target/etc/networks
      if [ ! -L $target/etc/resolv.conf -a -e /etc/resolv.conf ]; then
index b6fd305c348f2a5450ffb64b86600cb77637950b,8308bbe33dae7b662437697b6d7959cfc11d5ce4..8d4e85d7f6f5f3456d53e43396ee49cc6f33927c
@@@ -1,24 -1,8 +1,24 @@@
  #! /bin/bash
  
- # (c) Thomas Lange, 2001-2015, lange@debian.org
+ # (c) Thomas Lange, 2001-2016, lange@debian.org
  # (c) Michael Goetze, 2010-2011, mgoetze@mgoetze.net
  
 +
 +# on ubuntu 16.04 which didn't run this script, some things which didn't
 +# apply:
 +# /etc/dpkg/dpkg.cfg.d/fai didn't exist,
 +# machine-id was already setup.
 +
 +# on that system and a debian stretch system, after reboot,
 +# some things done here don't seem to persist:
 +# some thin/etc/mtab is symlink somewhere else,
 +# and mailname is $HOSTNAME.lan
 +
 +# the adjtime thing is to support changing the system clock
 +# from representing UTC (the default) to localtime (windows default).
 +
 +# afaik, the only useful thing here for me is setting /etc/hostname
 +
  error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
  
  # a list of modules which are loaded at boot time
@@@ -27,9 -11,9 +27,9 @@@ for module in $MODULESLIST; d
  done
  
  fcopy -Mv /etc/hostname || echo $HOSTNAME > $target/etc/hostname
- ainsl -av /etc/mailname ${HOSTNAME}
+ ainsl -a /etc/mailname ${HOSTNAME}
  if [ ! -e $target/etc/adjtime ]; then
-     printf "0.0 0 0.0\n0\nUTC" > $target/etc/adjtime
+     printf "0.0 0 0.0\n0\nUTC\n" > $target/etc/adjtime
  fi
  if [ "$UTC" = "yes" ]; then
      sed -i -e 's:^LOCAL$:UTC:' $target/etc/adjtime
@@@ -50,11 -34,15 +50,15 @@@ f
  
  ln -fs /proc/mounts $target/etc/mtab
  
- rm -f $target/etc/dpkg/dpkg.cfg.d/fai
+ rm -f $target/etc/dpkg/dpkg.cfg.d/fai $target/etc/dpkg/dpkg.cfg.d/unsafe-io
  
- [ $FAI_ACTION = "install" -a -f /etc/fai/fai.conf ] && cp /etc/fai/fai.conf $target/etc/fai/fai.conf
- ainsl -av /etc/fai/fai.conf "FAI_CONFIG_SRC=$FAI_CONFIG_SRC"
+ if [ $FAI_ACTION = "install" -o $FAI_ACTION = "dirinstall" ] ; then
+   [ -f /etc/fai/fai.conf ] && cp /etc/fai/fai.conf $target/etc/fai/fai.conf
+ fi
+ ainsl -a /etc/fai/fai.conf "FAI_CONFIG_SRC=$FAI_CONFIG_SRC"
  
  fcopy -Miv /etc/fai/fai.conf
+ fcopy -iv /etc/rc.local
  
  exit $error
index 88b557ea694876147a48fdfceef7ec3f4f743b40,7a0476081db7598e988f5823a4d6a90ffd3bc048..160dfa2e35fd05333a5b98a895b90e826818aa72
@@@ -4,6 -4,11 +4,11 @@@
  error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
  
  set -a
+ # do not set up grub during dirinstall
+ if [ "$FAI_ACTION" = "dirinstall" ] ; then
+     exit 0
+ fi
  # during softupdate use this file
  [ -r $LOGDIR/disk_var.sh ] && . $LOGDIR/disk_var.sh
  
@@@ -21,24 -26,33 +26,36 @@@ if [ $FAI_ACTION != "install" ]; the
  fi
  
  $ROOTCMD grub-mkdevicemap --no-floppy
 -GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
  
  # Check if RAID is used for the boot device
  if [[ $BOOT_DEVICE =~ '/dev/md' ]]; then
 +    GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
      raiddev=${BOOT_DEVICE#/dev/}
      # install grub on all members of RAID
      for device in `LC_ALL=C perl -ne 'if(/^'$raiddev'\s.+raid\d+\s(.+)/){ $_=$1; s/\d+\[\d+\]//g; print }' /proc/mdstat`; do
        echo Install grub on /dev/$device
        $ROOTCMD grub-install --no-floppy "/dev/$device"
      done
+ elif [[ $GROOT =~ 'hostdisk' ]]; then
+     cat > $target/boot/grub/device.map <<EOF
+ (hd0)   $BOOT_DEVICE
+ EOF
+     $ROOTCMD grub-install --no-floppy --modules=part_msdos $BOOT_DEVICE
+     if [ $? -eq 0 ]; then
+         echo "Grub installed on hostdisk $BOOT_DEVICE"
+     fi
+     rm $target/boot/grub/device.map
  else
 -    $ROOTCMD grub-install --no-floppy "$GROOT"
 -    if [ $? -eq 0 ]; then
 -        echo "Grub installed on $BOOT_DEVICE = $GROOT"
 -    fi
 +    for dev in $BOOT_DEVICE; do
 +        GROOT=$($ROOTCMD grub-probe -tdrive -d $dev)
 +        $ROOTCMD grub-install --no-floppy "$GROOT"
 +        if [ $? -eq 0 ]; then
 +            echo "Grub installed on $dev = $GROOT"
 +        fi
 +    done
  fi
  $ROOTCMD update-grub
  
index 232b0c807d2feb1f3edeb84b49c5cd58655d1fdf,a1cf1d1eaa4ef49e33b77f758b640fa3d9f4afac..2a8f2f129a6b47faa295b2f34ed6507595317d2d
@@@ -1,10 -1,10 +1,10 @@@
  #! /bin/bash
  
- # copyright Thomas Lange 2001-2015, lange@debian.org
+ # copyright Thomas Lange 2001-2016, lange@debian.org
  
  error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
  
- if [ "$FAI_ACTION" = "dirinstall" ] ; then
+ if [ "$FAI_ACTION" = "dirinstall" -o $do_init_tasks -eq 0 ] ; then
    :
  else
    # check if mdadm has been forgotten
      fi
    fi
  
 -  usedm=$(dmsetup ls | egrep -v '^live-rw|^live-base|^No devices found' | wc -l)
 -  if [ $usedm -ne 0 ]; then
 -    if [ ! -d $target/etc/lvm ]; then
 -      echo ERROR: Found lvm devices, but the lvm2 package was not installed
 -      error=1
 -    fi
 -  fi
 +  # # commented because it does false possitive
 +  # usedm=$(dmsetup ls | egrep -v '^live-rw|^live-base|^No devices found' | wc -l)
 +  # if [ $usedm -ne 0 ]; then
 +  #   if [ ! -d $target/etc/lvm ]; then
 +  #       echo ERROR: Found lvm devices, but the lvm2 package was not installed
 +  #       error=1
 +  #   fi
 +  # fi
  fi
  
  # remove backup files from cfengine, but only if cfengine is installed
@@@ -46,7 -45,7 +46,7 @@@ if [ $do_init_tasks -eq 1 ] ; the
  fi
  
  # Make sure everything is configured properly
 -if ifclass DEBIAN ; then
 +if ifclass DEBIAN || ifclass UBUNTU; then
          echo "Running \"apt-get -f install\" for the last time."
          $ROOTCMD apt-get -f install
  fi
@@@ -59,4 -58,36 +59,36 @@@ f
  # copy sources.list
  fcopy -iM /etc/apt/sources.list
  
+ setrel() {
+     # if release is not set, try to determine it
+     if [ -n "$release" ]; then
+       return
+     fi
+     if [ ! -f $target/etc/os-release ]; then
+       return
+     fi
+     dists="jessie stretch xenial trusty"
+     for d in $dists; do
+       if grep -iq $d $target/etc/os-release; then
+           release=$d
+           break
+       fi
+     done
+     echo "\$release set to $release"
+ }
+ # if installation was done from CD, replace useless sources.list
+ setrel
+ if [ -f $target/etc/apt/sources.list -a -n "$release" ]; then
+     grep -q 'file generated by fai-cd' $target/etc/apt/sources.list && cat <<EOF > $target/etc/apt/sources.list
+ deb http://httpredir.debian.org/debian $release main contrib non-free
+ deb http://httpredir.debian.org/debian-security $release/updates main contrib non-free
+ deb [trusted=yes] http://fai-project.org/download $release koeln
+ EOF
+ fi
  exit $error