cleanup classes, populate ssh server keys
authorIan Kelling <ian@iankelling.org>
Thu, 5 Jan 2017 15:53:37 +0000 (07:53 -0800)
committerIan Kelling <ian@iankelling.org>
Mon, 6 Feb 2017 06:21:42 +0000 (22:21 -0800)
23 files changed:
README
fai-redep
fai/config/class/50-host-classes
fai/config/files/etc/apt/preferences.d/belenos/BELANOS [moved from fai/config/files/etc/apt/preferences.d/belenos/BELANOS64 with 100% similarity]
fai/config/files/etc/apt/preferences.d/stable/LINODESTABLE [deleted symlink]
fai/config/files/etc/apt/preferences.d/stable/STABLE
fai/config/files/etc/apt/preferences.d/testing/LINODESTABLE [deleted symlink]
fai/config/files/etc/apt/preferences.d/testing/STABLE [deleted file]
fai/config/files/etc/apt/sources.list.d/belanos.list/BELANOS [moved from fai/config/files/etc/apt/sources.list.d/belanos.list/BELENOS64 with 100% similarity]
fai/config/files/etc/apt/sources.list.d/stable-non-free.list/STABLE_NON_FREE [deleted file]
fai/config/files/etc/apt/sources.list.d/stable.list/STABLE_LINODE [moved from fai/config/files/etc/apt/sources.list.d/linodestable.list/LINODESTABLE with 53% similarity]
fai/config/files/etc/apt/sources.list.d/stable.list/STABLE_NONFREE [new file with mode: 0644]
fai/config/files/etc/apt/sources.list.d/testing-non-free.list/DEBIAN_NON_FREE [deleted file]
fai/config/files/etc/apt/sources.list.d/testing.list/STABLE_FREE [new symlink]
fai/config/files/etc/apt/sources.list.d/testing.list/STABLE_NONFREE [new symlink]
fai/config/files/etc/apt/sources.list.d/testing.list/TESTING_FREE [moved from fai/config/files/etc/apt/sources.list.d/testing.list/DEBIAN with 75% similarity]
fai/config/files/etc/apt/sources.list.d/testing.list/TESTING_NONFREE [new file with mode: 0644]
fai/config/files/etc/apt/sources.list.d/unstable-non-free.list/DEBIAN_NON_FREE [deleted file]
fai/config/files/etc/apt/sources.list.d/unstable.list/DEBIAN [deleted file]
fai/config/files/root/fai-check/STABLE_BOOTSTRAP
fai/config/hooks/partition.DEFAULT
fai/config/scripts/GRUB_PC/11-ian
wrt-setup

diff --git a/README b/README
index def4fb536001f36899977f1db8c79eb997c8191a..c3a88f8f183fdf56bdcc3e7801ce314c44294aaf 100644 (file)
--- a/README
+++ b/README
@@ -41,7 +41,7 @@ arch-init-remote # install arch (after it's been booted into it's setup env)
 chboot # Set grub to boot into a different distro (installed earlier)
 install-chboot # reinstall chboot to /boot subvols, for when it changes
 dsfull # install & setup a new fai distro (if data partition already synced)
-eboot # reboot and keep disks encrypted
+eboot # reboot without automatic disk decryption
 fai-kexec # kexec to fai tftp server that pxe would normally point to
 fai-revm  # test fai on a fresh vm
 faiserver-revm # create a vm which is a fai server using pxe & preseed file
index c342d4b6020b89cf3c77ee5466190d99b83e6df2..b035ef55a74283163b544f8d58b78f0b89c0121e 100755 (executable)
--- a/fai-redep
+++ b/fai-redep
@@ -41,8 +41,13 @@ scp -q ~/.ssh/id_rsa.pub \
 # these files are not exposed.
 s scp -qr /q/root/luks /q/root/shadow \
   root@$faiserver_host:/srv/fai/config/distro-install-common
+
+# should tar ssh all the files, but these ones really justified it
+tar -cz /p/c/machine_specific/*/filesystem/etc/ssh | \
+  ssh root@$faiserver_host tar -xz -C /srv/fai/config/distro-install-common
 scp -q /a/bin/fai/devbyid root@$faiserver_host:/srv/fai/nfsroot/usr/local/bin
 
+
 # built BELANOS basefile with mk-basefile -J BELENOS64. it's stored in
 # it's own repo which is published alongside this one called
 # fai-basefiles due to being a large binary file.
index 12349be3c298ae578213f97def5256207f54903c..278bcce785df60383646fa068bbbd1281b26d2b7 100755 (executable)
 
 
 # For multi-boot system.
-# Check that we aren't in a pxe boot environment.
+# We check that we aren't in a pxe boot environment.
 # There is probably a better way to do this.
 # We check the reverse condition in 51-multi-boot,
 # and set what os we are installing, but don't check it
-# into git since it changes regularly. Each host needs
-# to have a class of either DEBIAN + (STABLE or STRETCH64 or STABLE_BOOTSTRAP),
-# or UBUNTU + XENIAL64.
+# into git since it changes regularly.
+# It's code looks like this:
+# if [[ ! -e /a/bin/fai/fai-wrapper ]]; then
+#     case $HOSTNAME in
+#         tp) DEBIAN STABLE VOL_STABLE STABLE_FREE;;
+#         # add more multi-boot hostnames here
+#     esac
+# fi
+#
+# Each host defines the base distro: UBUNTU or DEBIAN.
+# the disto version, also the basefile name if we aren't installing debian stable:
+# STABLE, STRETCH64, XENIAL64, BELANOS64
+# the distro subvol name, we can add as many of these as we want:
+# VOL_STABLE, VOL_STABLE_BOOTSTRAP, VOL_STRETCH, VOL_XENIAL, VOL_BELANOS
+# and the class which defines the apt sources files we want,
+# STABLE_FREE, STABLE_NONFREE, TESTING_FREE, TESTING_NONFREE,
+# XENIAL_FREE (no XENIAL_NONFREE setup yet), BELANOS, STABLE_LINODE.
+# This is a little redundant in some cases, but it keeps things
+# simpler.
+#
 #
 # Other notable classes:
 #
 #
 # RAID0: Use raid 0 even if there are >= 4 disks with boot partititions.
 #
-# It's shell looks like this:
-# if [[ ! -e /a/bin/fai/fai-wrapper ]]; then
-#     case $HOSTNAME in
-#         tp) DEBIAN STABLE ;;
-#         # add more multi-boot hostnames here
-#     esac
-# fi
 #
 if [[ -e /a/bin/fai/fai-wrapper ]]; then
     source /a/bin/distro-functions/src/identify-distros
@@ -59,16 +69,19 @@ if [[ -e /a/bin/fai/fai-wrapper ]]; then
 fi
 
 # use a list of classes for our demo machine
-echo "FAIBASE PARTITION_PROMPT"
+echo "FAIBASE"
+
+#echo "PARTITION_PROMPT"
+#echo REPARTITION
+
 case $HOSTNAME in
     frodo|treetowl)
-        echo "DEBIAN_NON_FREE"
         if [[ -e /a/bin/fai/fai-wrapper ]] && isdebian-stable; then
-            echo "STABLE_NON_FREE"
+            echo "STABLE_NONFREE"
         fi
         ;;
     lj|lj)
-        echo "LINODESTABLE" ;;
+        echo "STABLE STABLE_LINODE" ;;
 esac
 
 if grep ^52:54:00: /sys/class/net/eth0/address &>/dev/null; then
diff --git a/fai/config/files/etc/apt/preferences.d/stable/LINODESTABLE b/fai/config/files/etc/apt/preferences.d/stable/LINODESTABLE
deleted file mode 120000 (symlink)
index 31109f8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-STABLE
\ No newline at end of file
index bc0047b99141dc4684f5765ed1900ce8517a49e3..662b9573d79ecbff98c835c86b23524f804661e7 100644 (file)
@@ -11,3 +11,11 @@ Explanation:
 Package: tar linux-image-amd64 linux-base btrfs-tools
 Pin: release a=jessie-backports
 Pin-Priority: 500
+
+Package: *
+Pin: release a=testing
+Pin-Priority: -10
+
+Package: *
+Pin: release a=testing-updates
+Pin-Priority: -10
diff --git a/fai/config/files/etc/apt/preferences.d/testing/LINODESTABLE b/fai/config/files/etc/apt/preferences.d/testing/LINODESTABLE
deleted file mode 120000 (symlink)
index 31109f8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-STABLE
\ No newline at end of file
diff --git a/fai/config/files/etc/apt/preferences.d/testing/STABLE b/fai/config/files/etc/apt/preferences.d/testing/STABLE
deleted file mode 100644 (file)
index 2203269..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-Package: *
-Pin: release a=testing
-Pin-Priority: -10
-
-Package: *
-Pin: release a=testing-updates
-Pin-Priority: -10
diff --git a/fai/config/files/etc/apt/sources.list.d/stable-non-free.list/STABLE_NON_FREE b/fai/config/files/etc/apt/sources.list.d/stable-non-free.list/STABLE_NON_FREE
deleted file mode 100644 (file)
index 689921e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-deb http://http.us.debian.org/debian jessie contrib non-free
-deb-src http://http.us.debian.org/debian jessie contrib non-free
-
-deb http://security.debian.org/ jessie/updates contrib non-free
-deb-src http://security.debian.org/ jessie/updates contrib non-free
-
-deb http://http.us.debian.org/debian jessie-updates contrib non-free
-deb-src http://http.us.debian.org/debian jessie-updates contrib non-free
-
-deb http://http.debian.net/debian jessie-backports contrib non-free
-deb-src http://http.debian.net/debian jessie-backports contrib non-free
similarity index 53%
rename from fai/config/files/etc/apt/sources.list.d/linodestable.list/LINODESTABLE
rename to fai/config/files/etc/apt/sources.list.d/stable.list/STABLE_LINODE
index 3e04cd4387969aa4358d429787295413cf34a4fc..3e6e1833757c8207627d31c757a1cb92cd3e197d 100644 (file)
@@ -10,3 +10,15 @@ deb-src http://mirrors.linode.com/debian/ jessie-updates main
 
 deb http://mirrors.linode.com/debian/ jessie-backports main
 deb-src http://mirrors.linode.com/debian/ jessie-backports main
+
+deb http://mirrors.linode.com/debian testing main
+deb-src http://mirrors.linode.com/debian testing main
+
+deb http://security.debian.org/ testing/updates main
+deb-src http://security.debian.org/ testing/updates main
+
+deb http://mirrors.linode.com/debian testing-updates main
+deb-src http://mirrors.linode.com/debian testing-updates main
+
+deb http://mirrors.linode.com/debian unstable main
+deb-src http://mirrors.linode.com/debian unstable main
diff --git a/fai/config/files/etc/apt/sources.list.d/stable.list/STABLE_NONFREE b/fai/config/files/etc/apt/sources.list.d/stable.list/STABLE_NONFREE
new file mode 100644 (file)
index 0000000..d5cc0db
--- /dev/null
@@ -0,0 +1,11 @@
+deb http://http.us.debian.org/debian jessie main contrib non-free
+deb-src http://http.us.debian.org/debian jessie main contrib non-free
+
+deb http://security.debian.org/ jessie/updates main contrib non-free
+deb-src http://security.debian.org/ jessie/updates main contrib non-free
+
+deb http://http.us.debian.org/debian jessie-updates main contrib non-free
+deb-src http://http.us.debian.org/debian jessie-updates main contrib non-free
+
+deb http://http.debian.net/debian jessie-backports main contrib non-free
+deb-src http://http.debian.net/debian jessie-backports main contrib non-free
diff --git a/fai/config/files/etc/apt/sources.list.d/testing-non-free.list/DEBIAN_NON_FREE b/fai/config/files/etc/apt/sources.list.d/testing-non-free.list/DEBIAN_NON_FREE
deleted file mode 100644 (file)
index 35fc32e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-deb http://http.us.debian.org/debian testing contrib non-free
-deb-src http://http.us.debian.org/debian testing contrib non-free
-
-deb http://security.debian.org/ testing/updates contrib non-free
-deb-src http://security.debian.org/ testing/updates contrib non-free
-
-deb http://http.us.debian.org/debian testing-updates contrib non-free
-deb-src http://http.us.debian.org/debian testing-updates contrib non-free
diff --git a/fai/config/files/etc/apt/sources.list.d/testing.list/STABLE_FREE b/fai/config/files/etc/apt/sources.list.d/testing.list/STABLE_FREE
new file mode 120000 (symlink)
index 0000000..586e320
--- /dev/null
@@ -0,0 +1 @@
+TESTING_FREE
\ No newline at end of file
diff --git a/fai/config/files/etc/apt/sources.list.d/testing.list/STABLE_NONFREE b/fai/config/files/etc/apt/sources.list.d/testing.list/STABLE_NONFREE
new file mode 120000 (symlink)
index 0000000..b277a35
--- /dev/null
@@ -0,0 +1 @@
+TESTING_NONFREE
\ No newline at end of file
similarity index 75%
rename from fai/config/files/etc/apt/sources.list.d/testing.list/DEBIAN
rename to fai/config/files/etc/apt/sources.list.d/testing.list/TESTING_FREE
index cddde59fec01ac56bf18e19ac327dc18d69baac8..031bddf61888326bf40f3b423e60195cca40f50a 100644 (file)
@@ -6,3 +6,6 @@ deb-src http://security.debian.org/ testing/updates main
 
 deb http://http.us.debian.org/debian testing-updates main
 deb-src http://http.us.debian.org/debian testing-updates main
+
+deb http://http.us.debian.org/debian unstable main
+deb-src http://http.us.debian.org/debian unstable main
diff --git a/fai/config/files/etc/apt/sources.list.d/testing.list/TESTING_NONFREE b/fai/config/files/etc/apt/sources.list.d/testing.list/TESTING_NONFREE
new file mode 100644 (file)
index 0000000..3b57312
--- /dev/null
@@ -0,0 +1,11 @@
+deb http://http.us.debian.org/debian testing main contrib non-free
+deb-src http://http.us.debian.org/debian testing main contrib non-free
+
+deb http://security.debian.org/ testing/updates main contrib non-free
+deb-src http://security.debian.org/ testing/updates main contrib non-free
+
+deb http://http.us.debian.org/debian testing-updates main contrib non-free
+deb-src http://http.us.debian.org/debian testing-updates main contrib non-free
+
+deb http://http.us.debian.org/debian unstable main contrib non-free
+deb-src http://http.us.debian.org/debian unstable main contrib non-free
diff --git a/fai/config/files/etc/apt/sources.list.d/unstable-non-free.list/DEBIAN_NON_FREE b/fai/config/files/etc/apt/sources.list.d/unstable-non-free.list/DEBIAN_NON_FREE
deleted file mode 100644 (file)
index 4a92405..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-deb http://http.us.debian.org/debian unstable contrib non-free
-deb-src http://http.us.debian.org/debian unstable contrib non-free
diff --git a/fai/config/files/etc/apt/sources.list.d/unstable.list/DEBIAN b/fai/config/files/etc/apt/sources.list.d/unstable.list/DEBIAN
deleted file mode 100644 (file)
index 520a1a8..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-deb http://http.us.debian.org/debian unstable main
-deb-src http://http.us.debian.org/debian unstable main
index e448c7f7b1bd7429d0ad27e24304d07b40acb272..c06702901fd46a1f097da9d51ad569e7e1aae492 100755 (executable)
@@ -3,21 +3,32 @@
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
-# keep it short so we don't delay too much wnen we don't have networking.
-NETWORK_TIMOUT_SECS=10
+# Keep it short so we don't delay too much wnen we don't have networking.
+# In practice, on my home network, on an x200, it took 15 seconds, so
+# give it an extra 10 seconds, which seems fairly short as I write this.
+NETWORK_TIMOUT_SECS=25
 did_fai_check=false
+
+m() { printf "%s\n" "$*";  "$@"; }
+
 check-fai() {
     # we could just as well check if last_boot != /debianstable_boostrap
     # the intent with this one is just a little clearer.
     if [[ $did_fai_check == true ]]; then
         grub-editenv /mnt/grubenv set did_fai_check=os_true
+        # our service does not wait for network-online.target,
+        # because it will wait for too long when we don't have a network
+        # connection. So, we wait for 10 seconds.
         # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
         deadline=$(( `date +%s` + NETWORK_TIMOUT_SECS ))
-        while ! systemctl status network-online.target && \
-                (( `date +%s` < deadline )); do
+        while ! nc -zu faiserver 69; do
+            if (( `date +%s` > deadline )); then
+                echo "fai-check: hit $NETWORK_TIMOUT_SECS s tftp server timeout"
+                return 0
+            fi
             sleep 1
         done
-        pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||:
+        pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||:
     else
         return 0
     fi
@@ -30,7 +41,9 @@ for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \
     mount $dev /mnt
     if $first; then
         if [[ -e /mnt/grubenv ]]; then
+            set -x
             source <(grub-editenv /mnt/grubenv list)
+            set +x
         fi
         first=false
         check-fai
index c4f26ea811bc21e1dbcf00f6907a026f67f67e41..8dffd82b89c18a4fec5fd6616a5c6aa722ef35ac 100755 (executable)
@@ -190,15 +190,15 @@ fi
 
 
 if [[ ! $DISTRO ]]; then
-    if ifclass STABLE_BOOTSTRAP; then
+    if ifclass VOL_STABLE_BOOTSTRAP; then
         DISTRO=debianstable_bootstrap
-    elif ifclass STRETCH64; then
+    elif ifclass VOL_STRETCH; then
         DISTRO=debiantesting
-    elif ifclass STABLE; then
+    elif ifclass VOL_STABLE; then
         DISTRO=debianstable
-    elif ifclass XENIAL64; then
+    elif ifclass VOL_XENIAL; then
         DISTRO=ubuntuxenial
-    elif ifclass BELENOS64; then
+    elif ifclass VOL_BELENOS; then
         DISTRO=trisquelbelenos
     else
         echo "PARTITIONER ERROR: no distro class/var set" >&2
index 765034041aedc7b3f2e4a0305ce9447e5cdeed19..866cc6f3fc670933209a4bd92459c48e9c969876 100755 (executable)
@@ -24,10 +24,12 @@ EOF
 apt-get install -y pxe-kexec
 EOFOUTER
 
-fcopy -r /boot # -r = recursive
-# note: # fcopy -i = ignore nonmatching class error, always return 0.
+# -r = recursive
+# -i = ignore non-matching class warnings, always exit 0
+# -B = no backup files
+fcopy -riB /boot
 # this is also done by FABASE/10-misc by default.
-fcopy -ir /root
+fcopy -riB /root
 if ifclass STABLE_BOOTSTRAP; then
   fcopy -ri /etc/systemd/system
   chroot $FAI_ROOT bash <<'EOFOUTER'
@@ -36,24 +38,28 @@ EOFOUTER
   exit 0
 fi
 
-dir=/q/root/shadow
-fai_shadow=$FAI/distro-install-common/shadow
-if [[ ! -e $dir && -e $fai_shadow ]]; then
-  mkdir -p $dir
-  mount -o bind $fai_shadow $dir
-fi
-$FAI/distro-install-common/end
+bind-common() {
+    src=$1
+    dst=$2
+    if [[ ! -e $dst && -e $src ]]; then
+      mkdir -p $dst
+      mount -o bind $src $dst
+    fi
 
+}
+bind-common $FAI/distro-install-common/shadow /q/root/shadow
+
+# todo, port this over to the arch install script.
+cp -rT $FAI/distro-install-common/p/c/machine_specific/$HOSTNAME/filesystem/etc/ssh /target/etc/ssh
+
+$FAI/distro-install-common/end
 
 # these get copied in an earlier stage by fai, but leaving it here since
 # I run this as a single post-fai script to update things that have changed.
-fcopy -ri /etc/apt/preferences.d
-fcopy -ri /etc/apt/sources.list.d
+fcopy -riB /etc/apt
 $ROOTCMD apt-get update
 
-
-
-rm -f $FAI_ROOT/etc/apt/sources.list
+fcopy -riB /etc/ssh
 
 chroot $FAI_ROOT bash <<'EOF'
 set -eE -o pipefail
index 82f71934ad72f59b28905226b4f2e27882218758..c04708da3276d2533e015eb81631d11f50e2b157 100755 (executable)
--- a/wrt-setup
+++ b/wrt-setup
@@ -235,10 +235,10 @@ EOF
 dnsmasq_restart=false
 v cedit /etc/hosts <<EOF || dnsmasq_restart=true
 192.168.1.1 wrt
-192.168.1.2 treetowl $IMPERSONAL_DOMAIN
+192.168.1.2 treetowl $IMPERSONAL_DOMAIN faiserver
 192.168.1.3 frodo
 192.168.1.4 htpc
-192.168.1.5 x2 faiserver
+192.168.1.5 x2
 192.168.1.6 demohost
 #192.168.1.7 faiserver
 192.168.1.8 tp
@@ -311,7 +311,7 @@ dhcp-host=00:1f:16:16:39:24,set:x2,192.168.1.5,x2
 # reformatted. The mac is from doing a virt-install, cancelling it,
 # and copying the generated mac, so it should be randomish.
 dhcp-host=52:54:00:9c:ef:ad,set:demohost,192.168.1.6,demohost
-dhcp-host=52:54:00:56:09:f9,set:faiserver,192.168.1.7,faiserver
+#dhcp-host=52:54:00:56:09:f9,set:faiserver,192.168.1.7,faiserver
 dhcp-host=80:fa:5b:1c:6e:cf,set:tp,192.168.1.8,tp
 # this is the ip it picks by default if dhcp fails,
 # so might as well use it.