#!/bin/sh
# Enable resource pools, commit config if present, apply global-zone
# resource controls. Skip pieces whose binaries aren't installed
# (resource pools is optional in zyginit deployments).
set -e

if [ -x /usr/sbin/pooladm ]; then
    /usr/sbin/pooladm -e
    if [ -f /etc/pooladm.conf ]; then
        /usr/sbin/pooladm -c || {
            /usr/sbin/pooladm -d
            /bin/echo "pooladm -c failed; pools subsystem disabled" >&2
            exit 1
        }
    fi
fi

# Apply global-zone resource controls (was the resource-mgmt oneshot).
if [ -x /usr/sbin/zoneadm ] && [ -f /etc/zones/global.xml ]; then
    /usr/sbin/zoneadm -z global apply
fi

exit 0
