#!/usr/bin/sh
set -ex

# Temporarily skip the AutoYaST XML validation
export YAST_SKIP_XML_VALIDATION=1

if [ -z "$1" ]
then
  url=$(awk -F 'agama.auto=' '{sub(/ .*$/, "", $2); print $2}' < /proc/cmdline)
else
  url="$1"
fi

if [ -z "$url" ]
then
  echo "no autoinstallation profile"
  exit 0
fi

echo "Using the profile at $url"

case "$url" in
* )
    /usr/bin/agama profile import "$url"
    /usr/bin/agama install;;
esac
