various fixes
authorIan Kelling <ian@iankelling.org>
Wed, 23 Nov 2016 02:28:17 +0000 (18:28 -0800)
committerIan Kelling <ian@iankelling.org>
Mon, 6 Feb 2017 06:21:42 +0000 (22:21 -0800)
fai-redep
fai/config/class/50-host-classes
fai/config/distro-install-common/libreboot_grub.cfg
fai/config/files/root/fai-check/STABLE_BOOTSTRAP
faiserver-setup
myfai-chboot
pxe-server
wrt-setup

index ca8fb6096bff0dd8bc4c7d8102dda78ba348ee07..c342d4b6020b89cf3c77ee5466190d99b83e6df2 100755 (executable)
--- a/fai-redep
+++ b/fai-redep
@@ -65,3 +65,5 @@ chmod -R a+rX /srv/fai/config/distro-install-common
 #u=http://fai-project.org/download/basefiles/XENIAL64.tar.xz
 #wget -nv -N $u
 EOF
 #u=http://fai-project.org/download/basefiles/XENIAL64.tar.xz
 #wget -nv -N $u
 EOF
+
+faiserver-enable
index f8e46de7fbe8560d026bccb7eebf4151a3acb483..12349be3c298ae578213f97def5256207f54903c 100755 (executable)
 #     esac
 # fi
 #
 #     esac
 # fi
 #
-if [[ -e /a/bin/fai/fai-wrapper ]] && isdebian-stable; then
-    echo "STABLE"
+if [[ -e /a/bin/fai/fai-wrapper ]]; then
+    source /a/bin/distro-functions/src/identify-distros
+    if isdebian-stable; then
+        echo "STABLE"
+    fi
 fi
 
 # use a list of classes for our demo machine
 fi
 
 # use a list of classes for our demo machine
index 32ab3922a5a79945b50260007ece5148a6f498a7..69e1c52db3a1eaa3a4d543f350ca1f1c1fdff0cb 100644 (file)
@@ -13,7 +13,15 @@ function save_chosen {
     save_vars did_fai_check last_boot
 }
 
     save_vars did_fai_check last_boot
 }
 
-# we don't set this to fai check so we can't get into
+# fai_check is so we can act like a pxe boot, but just for fai, and by
+# using /debian_bootstrap to do it.  We toggle on and off the grub var
+# did_fai_check so we can do the check every other boot. Then
+# /debian_bootstrap checks for that var on boot and if we want to do a
+# fai check, it does it, then reboots. But it also sets did_fai_check to
+# a 3rd state os_true which means we did the fai check, and we don't
+# want to do it again. This is useful for systems without libreboot.
+
+# We don't set this to fai check so we can't get into
 # an infinite reboot cycle. We depend on the os to
 # create the initial grubenv file.
 set default=/debianstable_bootstrap # could use 0 here.
 # an infinite reboot cycle. We depend on the os to
 # create the initial grubenv file.
 set default=/debianstable_bootstrap # could use 0 here.
@@ -23,7 +31,7 @@ for part in (ahci*4) (ata*4); do
     envfile=$part/grubenv
     if [ -s $envfile ]; then
         load_env --file $envfile
     envfile=$part/grubenv
     if [ -s $envfile ]; then
         load_env --file $envfile
-        if [ x$did_fai_check != xtrue -a x$last_boot != x$default ]; then
+        if [ x$did_fai_check == xfalse -a x$last_boot != x$default ]; then
             set default=fai-check
         elif [ ! -z $last_boot ]; then
             set default=$last_boot
             set default=fai-check
         elif [ ! -z $last_boot ]; then
             set default=$last_boot
index 15c865f671f1007cf05a5361a0524375103946b5..e448c7f7b1bd7429d0ad27e24304d07b40acb272 100755 (executable)
@@ -5,12 +5,12 @@ 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.
 NETWORK_TIMOUT_SECS=10
-fai_check=false
+did_fai_check=false
 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
 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
-        fai_check=true
+        grub-editenv /mnt/grubenv set did_fai_check=os_true
         # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
         deadline=$(( `date +%s` + NETWORK_TIMOUT_SECS ))
         while ! systemctl status network-online.target && \
         # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
         deadline=$(( `date +%s` + NETWORK_TIMOUT_SECS ))
         while ! systemctl status network-online.target && \
@@ -45,7 +45,8 @@ for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \
     umount /mnt
 done
 
     umount /mnt
 done
 
-if $fai_check && [[ $last_boot != /debianstable_boostrap ]]; then
+# the check for last_boot is not needed afaik, just sanity check.
+if [[ $did_fai_check == true && $last_boot != /debianstable_boostrap ]]; then
     # no need to reboot if we actually want to boot into this os.
     reboot
 fi
     # no need to reboot if we actually want to boot into this os.
     reboot
 fi
index 96485a5634ea1c34db1210207107124517ecb51c..a48a00c43def737cfe45334657991c0f00ad670b 100755 (executable)
@@ -52,6 +52,22 @@ fi
 
 # for debian:
 
 
 # for debian:
 
+
+apt-get update
+# all the dependencies except the dhcp server
+deps="$(apt-cache show fai-quickstart | grep ^Depends: |head -n 1|\
+              sed -r 's/^Depends:|,|\|[^,]+|isc-dhcp-server//g')"
+to_install=(tar)
+for pkg in $deps; do
+    dpkg -s $pkg &>/dev/null && continue ||:
+    to_install+=($pkg)
+    # just so we have a record.
+    echo `date` $pkg >>/var/log/fai-manually-installed-packages.log
+done
+if [[ $to_install ]]; then
+  apt-get -y install ${to_install[@]}
+fi
+
 r=http://http.us.debian.org/debian
 # like default, but scrap httpredir, and nonfree.
 # All my systems should be able to get along without nonfree
 r=http://http.us.debian.org/debian
 # like default, but scrap httpredir, and nonfree.
 # All my systems should be able to get along without nonfree
@@ -78,21 +94,6 @@ Pin-Priority: 500
 EOF
 fi
 
 EOF
 fi
 
-apt-get update
-# all the dependencies except the dhcp server
-deps="$(apt-cache show fai-quickstart | grep ^Depends: |head -n 1|\
-              sed -r 's/^Depends:|,|\|[^,]+|isc-dhcp-server//g')"
-to_install=(tar)
-for pkg in $deps; do
-    dpkg -s $pkg &>/dev/null && continue ||:
-    to_install+=($pkg)
-    # just so we have a record.
-    echo `date` $pkg >>/var/log/fai-manually-installed-packages.log
-done
-if [[ $to_install ]]; then
-  apt-get -y install ${to_install[@]}
-fi
-
 
 # tried out a stretch base, doesn't work yet.
 $sed -f - /etc/fai/nfsroot.conf <<EOF
 
 # tried out a stretch base, doesn't work yet.
 $sed -f - /etc/fai/nfsroot.conf <<EOF
index 32addc589e4f2a2b9455ec4d48b47ff39c5dc40c..1abead8c5922a7feb7bcc1df6c1adcbf9b4e9841 100755 (executable)
@@ -17,8 +17,3 @@ cd "${BASH_SOURCE%/*}" # directory of the script
 
 host=$(chost faiserver)
 ssh root@$host bash -s "$@" <myfai-chboot-local
 
 host=$(chost faiserver)
 ssh root@$host bash -s "$@" <myfai-chboot-local
-if [[ $1 ]]; then
-    ./faiserver-enable
-else
-    ./faiserver-disable
-fi
index 9c3f917fcaceee7a488453759aa6eed44b528250..15d52e74cc6a47984e7756765e8b0ac3ebeefe44 100755 (executable)
@@ -31,8 +31,9 @@ usage() {
 Usage: ${0##*/} [OPTIONS] [HOST TYPE]
 One line description
 
 Usage: ${0##*/} [OPTIONS] [HOST TYPE]
 One line description
 
+Without HOST TYPE, disable pxe server and fai server.
 TYPE is one of arch, plain, fai.
 TYPE is one of arch, plain, fai.
-HOST is a hostname known to the dhcp server, or default for all, or none to disable
+HOST is a hostname known to the dhcp server, or default for all
 
 -r         Don't redeploy fai config. For example, if there is a different host
            that is mid-install.
 
 -r         Don't redeploy fai config. For example, if there is a different host
            that is mid-install.
index 8293e9d1325fa961e2a894f0c3df71da6dd69032..b244bcaa8985955dba072980afbb0db164324e22 100755 (executable)
--- a/wrt-setup
+++ b/wrt-setup
@@ -231,9 +231,9 @@ v cedit /etc/hosts <<EOF || dnsmasq_restart=true
 192.168.1.2 treetowl $IMPERSONAL_DOMAIN
 192.168.1.3 frodo
 192.168.1.4 htpc
 192.168.1.2 treetowl $IMPERSONAL_DOMAIN
 192.168.1.3 frodo
 192.168.1.4 htpc
-192.168.1.5 x2
+192.168.1.5 x2 faiserver
 192.168.1.6 demohost
 192.168.1.6 demohost
-192.168.1.7 faiserver
+#192.168.1.7 faiserver
 192.168.1.8 tp
 72.14.176.105 li
 45.33.1.160 lj
 192.168.1.8 tp
 72.14.176.105 li
 45.33.1.160 lj