#!/bin/sh -e

policy=$(readlink /usr/lib/s6-rc/policy/current)
if test x"$policy" = x"exclusive" ; then
  top="top"
elif test x"$policy" = x"shared" ; then
  top="runlevel_2"
else
  echo "svctl-apply: fatal: /usr/lib/s6-rc/policy/current should be a relative symlink to either shared or exclusive" 1>&2
  exit 100
fi

/usr/lib/s6-policy-common/bin/svctl-update
exec s6-rc -p change "$top"
