License stuff:
The license for the project is GPLv2 or later, mostly because fai is and
-I periodically rebase off their example config, which contains small
+I periodically merge the upstream example config, which contains small
scripts. Also, there is a modified encrypt.upstream, which is from the
cryptsetup package in arch, which is under the same license.
# use it, so look it up just to avoid the warning spam.
faiserver_host=$(chost $host) || faiserver_host=$host
-rsync -rl --delete --relative --exclude /fai/config/basefiles/ fai/config root@$faiserver_host:/srv
+rsync -rlp --delete --relative --exclude /fai/config/basefiles/ fai/config root@$faiserver_host:/srv
scp -q ~/.ssh/id_rsa.pub \
-x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
-
-script_dir="$(readlink -f "$BASH_SOURCE")"
+x="$(readlink -f "$BASH_SOURCE")"
+script_dir="${x%/*}"
+source "${script_dir}/bash-trace"
e() { echo "$*"; "$@"; }
# 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##*/} "${orig_args[@]}"
fi
_errcatch_cleanup=cleanup
if is_arch_revm; then
- ./pxe-server demohost arch
+ e ./pxe-server demohost arch
sleep 2
# via osinfo-query os. guessing arch is closest to latest fedora.
variant=fedora22
else
- ./pxe-server demohost fai
+ e ./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.
# the automatic basefile getting will be for stretch
# instead of jessie, so if you install jessie, you need
# to setup the basefile and it\'s corresponding class.
-base=jessie
+base=stretch
sed="sed -ri --follow-symlinks"
if ! type -p wget &>/dev/null; then
[[ $(dpkg --print-architecture) == armhf ]]
}
-if grep -xFq 'VERSION="9 (stretch)"' /etc/os-release; then
- # if we use stretch, no need for fai-project repo.
- # this will need to be updated when there is a codename
- # for stretch+1
- rm -f /etc/apt/sources.list.d/fai.list
-elif armhf; then
+if armhf; then
if apt-cache policy | grep o=Debian,a=testing,n=stretch &>/dev/null; then
cat >/etc/apt/sources.list.d/testing.list <<'EOF'
deb http://http.us.debian.org/debian testing main contrib non-free
Pin-Priority: -10
EOF
fi
-else
- wget -O - http://fai-project.org/download/074BCDE4.asc | apt-key add -
- cat >/etc/apt/sources.list.d/fai.list <<'EOF'
+elif grep -xFq 'VERSION="8 (jessie)"' /etc/os-release; then
+ gpg -a --recv-keys 2BF8D9FE074BCDE4; gpg -a --export 2BF8D9FE074BCDE4 | apt-key add -
+ cat >/etc/apt/sources.list.d/fai.list <<'EOF'
deb http://fai-project.org/download jessie koeln
EOF
+elif grep -xFq 'VERSION="9 (stretch)"' /etc/os-release; then
+ gpg -a --recv-keys 2BF8D9FE074BCDE4; gpg -a --export 2BF8D9FE074BCDE4 | apt-key add -
+
+ cat >/etc/apt/sources.list.d/fai.list <<'EOF'
+deb http://fai-project.org/download stretch koeln
+EOF
+else
+ rm -f /etc/apt/sources.list.d/fai.list
fi
# for ubuntu:
deb http://security.debian.org/debian-security $base/updates main contrib
EOF
+
+case $base in
+ jessie|stretch)
+ cat >>/etc/fai/apt/sources.list <<EOF
+# use fai repo. it's commented in the defaults. it's got bug fixes.
+# and may contain newer packages.
+deb http://fai-project.org/download $base koeln
+EOF
+ ;;
+esac
+
if [[ $base == jessie ]]; then
cat >>/etc/fai/apt/sources.list <<'EOF'
-# uncommenting this from the defaults. it's got bug fixes.
-# repository that may contain newer fai packages for jessie
-deb http://fai-project.org/download jessie koeln
# fix tar https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=819978
deb http://ftp.debian.org/debian jessie-backports main
EOF
-
# note, fai doesn\'t look at /etc/fai/apt/preferences.d
cat >/etc/fai/apt/preferences <<'EOF'
Package: tar
diff -u <(type setup_tftp) <(cat <(sed -n '/^setup_tftp(){/,/^}/p' $(which fai-make-nfsroot) ) - <<'EOF' |bash
type setup_tftp
EOF
-)
+ )
setup_tftp
# -g causes skipping set_root_pw() in fai-make-nfsroot, -ag
host=$1
-type -t host &>/dev/null || apt-get -y install dnsutils
-gateway_if=$(ip route | sed -rn 's/^default via \S+ dev (\S+) .*/\1/p')
-if [[ ! $gateway_if ]]; then
- echo "$0: failed to find gateway interface"
- exit 1
-fi
# assuming ipv4, or else we might need to deal with multiple addresses
# in an ipv4 + ipv6 network.
-network=$(ip -4 -o a show dev $gateway_if | sed -rn '/scope.*global/s/^(\S+\s+){3}(\S+)\s.*/\2/p')
-if [[ ! $network ]]; then
- echo "$0: failed to find network"
+my_ip=$(ip -4 route get 8.8.8.8 | sed -nr 's,^.*src\s+(\S+).*,\1,p')
+if [[ $x =~ [[:space:]] ]]; then
+ echo "$0: error: failed to get \$my_ip, got: $my_ip"
exit 1
fi
-my_ip=${network%/*}
+
if [[ $host == default ]]; then
ip=$network
elif [[ $host == [0-9]*.[0-9]*.[0-9]*.[0-9]* ]]; then
ip=$host
else
+ type -t host &>/dev/null || apt-get -y install dnsutils
ip=$(host $host | sed -rn 's/^\S+ has address //p;T;q')/32
fi
-
-# alternate way of getting my ip
-#gateway_ip=$(ip route | sed -rn 's/^default via (\S+) .*/\1/p')
-#my_ip=$(host faiserver $gateway_ip | sed -rn 's/^\S+ has address //p;T;q')
-
if modprobe nfsd &>/dev/null; then
std_arg="-u nfs://faiserver/srv/fai/config"
- root_arg="$my_ip:/srv/fai/nfsroot"
+ # nfsv4 wont do rw with overlayfs yet
+ # https://lists.uni-koeln.de/pipermail/linux-fai/2017-March/011641.html
+ root_arg="$my_ip:/srv/fai/nfsroot:vers=3"
# fai-setup without -e sets the ip to the local_ip/local_network, eg 192.168.1.3/24
# I restrict it to one ip as simple but imperfect access control.
sed -ri --follow-symlinks '\%^/srv/fai/%d' /etc/exports
/srv/fai/nfsroot $ip(async,ro,no_subtree_check,no_root_squash)
EOF
exportfs -ra
+ systemctl start nfs-server # assumes recent os
else
std_arg="-u http://faiserver:8080/config.tar.gz"
root_arg="live:http://faiserver:8080/squash.img"
fai() {
cat <<EOF
-dhcp-boot=${host_tag}pxelinux.0,faiserver.lan,faiserver.lan
+dhcp-boot=${host_tag}pxelinux.0,faiserver.b8.nz,faiserver.b8.nz
EOF
}
}
set-pxe() {
+ echo "$0: updating dnsmasq.conf:"
+ $type
${type:-:}|ssh wrt "cedit pxe /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
$([[ $type == arch ]] && echo arch-pxe-mount)"
}