docker-init 787 Bytes
#!/bin/bash

set -e

onexit() {
	export PREVLEVEL=$RUNLEVEL RUNLEVEL=1
	/etc/init.d/rc 1
	# Turn services back off
	echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d
	rm -f /etc/init.d/.legacy-bootordering
}
trap onexit EXIT

rm -f /usr/sbin/policy-rc.d

if [[ -e /etc/docker-init/runtime/settings.sh ]]; then
	. /etc/docker-init/runtime/settings.sh
fi

if [[ $UID && $GID ]]; then
	addgroup --gid $GID hostuser
	adduser --disabled-password --uid $UID --gid $GID --gecos "" hostuser
fi

for pre_config_service in /etc/docker-init/runtime/pre-config/*.sh; do
	[[ -r $pre_config_service ]] || continue
	(
		. "$pre_config_service"
	)
done
touch /etc/init.d/.legacy-bootordering
export RUNLEVEL=2 PREVLEVEL=
/etc/init.d/rc 2

if [[ $# -gt 0 ]]; then
	"$@"
else
	tail -f /var/log/syslog
fi