#! /bin/sh [ ! -d "$1" ] && echo "$1 is not a valid directory." && exit 1; trap "umount \"${1}\"/tmp \"${1}\"/dev/null \"${1}\"/dev/pts \"${1}\"/dev/random \"${1}\"/dev/shm \"${1}\"/dev/urandom \"${1}\"/proc" EXIT INT TERM HUP PIPE && mount -o bind /tmp "${1}/tmp" && \ mount -o bind /dev/null "${1}/dev/null" && \ mount -o bind /dev/pts "${1}/dev/pts" && \ mount -o bind /dev/random "${1}/dev/random" && \ mount -o bind /dev/shm "${1}/dev/shm" && \ mount -o bind /dev/urandom "${1}/dev/urandom" && \ mount -o bind /proc "${1}/proc" && \ chroot "$@";