From: Ian Kelling Date: Sun, 8 Oct 2017 16:57:31 +0000 (-0700) Subject: small fixes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=836348b3deca3d4544bcf4ece81d8609740da550;p=automated-distro-installer small fixes --- diff --git a/README b/README index 3c9b6d2..f71f643 100644 --- a/README +++ b/README @@ -86,6 +86,6 @@ fresize # resize swap or boot partitions in a host 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. diff --git a/fai-redep b/fai-redep index fabada0..840f2c4 100755 --- a/fai-redep +++ b/fai-redep @@ -38,7 +38,7 @@ host=${1:-faiserver} # 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 \ diff --git a/fai-revm b/fai-revm index 3b05795..f7e45c9 100755 --- a/fai-revm +++ b/fai-revm @@ -17,9 +17,9 @@ -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 "$*"; "$@"; } @@ -66,7 +66,6 @@ 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##*/} "${orig_args[@]}" fi @@ -84,12 +83,12 @@ cleanup() { _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. diff --git a/faiserver-setup b/faiserver-setup index 0bf61ca..3e805df 100755 --- a/faiserver-setup +++ b/faiserver-setup @@ -48,7 +48,7 @@ e() { echo "$@"; "$@"; } # 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 @@ -59,12 +59,7 @@ armhf() { [[ $(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 @@ -87,11 +82,19 @@ Pin: release a=testing 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: @@ -126,15 +129,22 @@ deb $r $base main contrib deb http://security.debian.org/debian-security $base/updates main contrib EOF + +case $base in + jessie|stretch) + cat >>/etc/fai/apt/sources.list <>/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 @@ -211,7 +221,7 @@ if armhf; then 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 diff --git a/myfai-chboot-local b/myfai-chboot-local index 58babc1..6d7e019 100755 --- a/myfai-chboot-local +++ b/myfai-chboot-local @@ -31,36 +31,28 @@ e() { 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 @@ -69,6 +61,7 @@ if modprobe nfsd &>/dev/null; then /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" diff --git a/pxe-server b/pxe-server index 63373e3..c19f6d2 100755 --- a/pxe-server +++ b/pxe-server @@ -122,7 +122,7 @@ EOF fai() { cat <