#!/bin/bash # # (c) 2006 Henning Glawe # (c) 2009-2025 Thomas Lange ### BEGIN SUBROUTINE INFO # Provides-Var: # Requires-Var: $FAI_CONFIG_SRC $FAI # Suggests-Var: # Short-Description: get $FAI directory from $FAI_CONFIG_SRC ### END SUBROUTINE INFO if [ -z "$FAI_CONFIG_SRC" ]; then sendmon "TASKERROR get_fai_dir 21" echo "ERROR: No URL defined for the config space." >&2 echo "ERROR: Set \$FAI_CONFIG_SRC by using fai-chboot -u or use option -s when calling fai directly." >&2 exit 21 fi echo "FAI_CONFIG_SRC is set to $FAI_CONFIG_SRC" # extract method to get the config dir # matched string: "cvs[+ssh]://user@host/path/to/cvsroot module[=tag]" # ^^^ # "nfs://host/path/to/exported/config" # ^^^ # the "major" protocol name is the one up to the first "+", if it exists method=$(expr match "$FAI_CONFIG_SRC" '\([^+]*\).*://') if [ -z "$method" ]; then sendmon "TASKERROR get_fai_dir 22" echo "Error in get-config-dir: scheme undefined." >&2 exit 24 echo fi [ -z "$FAI" -a $method != "file" ] && echo "WARNING: \$FAI is undefined. Let's see if it still works." mkdir -m 0750 -p $FAI # run get-config-dir-$method script if it exists if command -v get-config-dir-$method &>/dev/null ; then get-config-dir-$method # check for errors lerror=$(< $LOGDIR/task_local_error) if [ "$lerror" -ne 0 ]; then exit 25 fi else sendmon "TASKERROR get_fai_dir 22" echo "Error: get-config-dir-"$method "not found" >&2 exit 22 fi if [ $method = "file" ]; then localpath=$(expr match "$FAI_CONFIG_SRC" '.*://\(/.*\)') export FAI=$localpath fi ln -snf $FAI /var/run/fai/current_config if [ ! -d $FAI/class ]; then echo "WARNING: directory $FAI/class not found." >&2 sendmon "TASKERROR get_fai_dir 23" exit 23 fi exit 0