#!/bin/sh

set -eu

mode=${1:---manual}

puavo_hosttype=$(puavo-conf puavo.hosttype)

if [ "$puavo_hosttype" != 'bootserver' ]; then
  echo "$(basename $0) is only supported on bootservers!" >&2
  exit 1
fi

status=0

{
  /etc/puavo-conf/scripts/setup_bootserver_network_interfaces \
    && puavo-sysmerge-onedir "$mode" /etc/network/interfaces.d.rofs
} || status=1

{
  /etc/puavo-conf/scripts/setup_bootserver_shorewall_conf \
    && puavo-sysmerge-onedir "$mode" /etc/shorewall.rofs
} || status=1

if [ "$status" -ne 0 ]; then
  echo 'There were errors!' >&2
fi

exit $status
