#!/bin/bash

### BEGIN SUBROUTINE INFO
# Provides-Var:
# Requires-Var:    $FAI_CONFIG_SRC $FAI
# Suggests-Var:    $romountopt
# Short-Description: get $FAI by mounting it via nfs
### END SUBROUTINE INFO

server=$(expr match "$FAI_CONFIG_SRC" '.*://\([^/]*\)/.*')
if [ -z "$server" ]; then
  server=$(awk '{if($2 == "/run/rootfsbase") print $1;}' /proc/mounts | grep :/ | cut -d ':' -f 1)
fi
nfspath=$(expr match "$FAI_CONFIG_SRC" '.*://[^/]*\(/.*\)')

mount $romountopt $server:$nfspath $FAI &&
  echo "Configuration space $server:$nfspath mounted to $FAI"
task_error 881 $?
