various minor fixes and improvements
[automated-distro-installer] / faiserver-setup
index b9fe68f037cf7c6f5e8821e3d61e0106289de7a3..cf0da93e24d49b00eadba6e267ee7b1cce4c6d18 100755 (executable)
@@ -17,7 +17,7 @@
 
 x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
 
 
 x="$(readlink -f "$BASH_SOURCE")"; source "${x%/*}/bash-trace"
 
-[[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@"
+[[ $EUID == 0 ]] || exec sudo -i "${BASH_SOURCE}" "$@"
 
 usage() {
   cat <<EOF
 
 usage() {
   cat <<EOF
@@ -30,7 +30,9 @@ that using a hostname does not work.
 Separate from running this, faiserver needs to be setup in dns
 to point to whatever host this is run on.
 
 Separate from running this, faiserver needs to be setup in dns
 to point to whatever host this is run on.
 
-It expects $BASEFILE_DIR/STRETCH64.tar.gz to exist.
+It expects $BASEFILE_DIR/STRETCH64.tar.gz to exist, and it
+must have been generated around the same time as the nfsroot,
+at least so it has the same kernel version.
 
 EOF
   exit $1
 
 EOF
   exit $1
@@ -48,6 +50,12 @@ e() { echo "$@"; "$@"; }
 base=stretch
 sed="sed -ri --follow-symlinks"
 
 base=stretch
 sed="sed -ri --follow-symlinks"
 
+if [[ ! -e $BASEFILE_DIR/STRETCH64.tar.gz ]]; then
+  printf "%s\n" "$0: error BASEFILE_DIR=$BASEFILE_DIR \$BASEFILE_DIR/STRETCH64.tar.gz does not exist"
+  exit 1
+fi
+
+
 if ! type -p wget &>/dev/null; then
   apt-get install -y wget
 fi
 if ! type -p wget &>/dev/null; then
   apt-get install -y wget
 fi
@@ -82,7 +90,7 @@ 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'
 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
+deb https://fai-project.org/download jessie koeln
 EOF
 elif grep -xFq 'VERSION="9 (stretch)"' /etc/os-release || grep -iE 'flidas|xenail' /etc/os-release ; then
   # fai on ubuntu only has official support using the universe repo, but newer
 EOF
 elif grep -xFq 'VERSION="9 (stretch)"' /etc/os-release || grep -iE 'flidas|xenail' /etc/os-release ; then
   # fai on ubuntu only has official support using the universe repo, but newer
@@ -90,7 +98,7 @@ elif grep -xFq 'VERSION="9 (stretch)"' /etc/os-release || grep -iE 'flidas|xenai
   gpg --keyserver hkp://pool.sks-keyservers.net -a --recv-keys 2BF8D9FE074BCDE4; gpg -a --export 2BF8D9FE074BCDE4 | apt-key add -
 
   cat >/etc/apt/sources.list.d/fai.list <<'EOF'
   gpg --keyserver hkp://pool.sks-keyservers.net -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
+deb https://fai-project.org/download stretch koeln
 EOF
 else
   rm -f /etc/apt/sources.list.d/fai.list
 EOF
 else
   rm -f /etc/apt/sources.list.d/fai.list