#!/bin/bash
# Filename:      ${GRML_FAI_CONFIG}/media-scripts/GRMLBASE/50-addons
# Purpose:       Install "addons" files
# Authors:       grml-team (grml.org)
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2 or any later version.
################################################################################

set -u
set -e

# FAI sets $target, but shellcheck does not know that.
target=${target:?}
# shellcheck source=/dev/null
. "$GRML_LIVE_CONFIG"

if [ -n "$NO_ADDONS" ] ; then
  echo "I: skipping addons installation as \$NO_ADDONS is set."
  exit 0
fi

echo "I: installing addons."

# copy files and report which ones get installed
if grml-live-command copy-media-files media -r "/arch/${ARCH}/boot/addons" && $ROOTCMD test -d "${GRML_LIVE_MEDIADIR}/arch" ; then
  $ROOTCMD cp -rv "${GRML_LIVE_MEDIADIR}/arch/${ARCH}/boot/addons" "${GRML_LIVE_MEDIADIR}/boot/"
  $ROOTCMD rm -rf "${GRML_LIVE_MEDIADIR}/arch"
else
  # legacy path (before https://github.com/grml/grml-live-grml/pull/11):
  echo "I: trying to install legacy path /boot/addons"
  grml-live-command copy-media-files media -r -i "/boot/addons"
fi

## END OF FILE #################################################################
# vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2
