#!/bin/bash
#=============================================================================#
#		Run script in aptbox
#=============================================================================#
# Requires:
#	hasher by Dmitry V. Levin (ldv)
#=============================================================================#
# (C) Denis Smirnov <mithraen@freesource.info>					  12.06.2006  #
#=============================================================================#
set +e

WORKDIR=`realpath $1`; shift
SCRIPT="$1"; shift
chroot="$WORKDIR/chroot/"

if [ -d "$SCRIPT" ]; then
	echo "$SCRIPT is directory, not script"
	exit -1
fi
cp -a $SCRIPT $chroot/.host/script-for-run

echo "Running $SCRIPT in $WORKDIR" | csed '/.*/ p green' >&2
hsh-run "$WORKDIR"  --rooter -- /.host/script-for-run "$@"

