cryptonas/cbox-tree.d/usr/lib/cryptobox/chroot-start.sh

46 lines
1 KiB
Bash
Raw Normal View History

#!/bin/sh
2005-07-21 21:53:49 +02:00
#
# FOR DEVELOPMENT ONLY!
#
2005-07-23 21:52:52 +02:00
# this script is used to prepare a chroot session for testing or configuring
2005-07-21 21:53:49 +02:00
#
# called by:
# - cbox-build.sh
#
2005-07-23 21:52:52 +02:00
# parameter: [commandline]
#
# if "commandline" is empty, "bash" will be used
set -eu
MNT_SRC=/opt/dfsruntime/runtimerd
MNT_DST=/opt/dfsruntime/runtimemnt
# the directory /tmp/ can not be used, as it is still a broken link, too
TMP_DIR="/tmp-`basename $0`-$$"
cp -a "$MNT_SRC/." "$TMP_DIR"
2005-07-23 21:52:52 +02:00
mount -n --bind "$TMP_DIR" "$MNT_DST"
[ ! -e /dev/null ] && mknod "/dev/null" c 1 3 && chmod 666 "/dev/null"
[ ! -e /dev/urandom ] && mknod "/dev/urandom" c 1 9 && chmod 444 "/dev/urandom"
[ ! -e /dev/console ] && mknod "/dev/console" c 1 5 && chmod 660 "/dev/console"
2005-07-23 21:52:52 +02:00
[ ! -e /proc/mounts ] && mount -n -t proc proc /proc
# default language setting - prevents dpkg error messages
export LANG=C
# set default terminal (good if you are running in a screen session)
export TERM=linux
# execute parameters as commandline
2005-07-23 21:52:52 +02:00
if [ $# -gt 0 ]
then "$@"
else bash
fi
2005-07-23 21:52:52 +02:00
umount -n "$MNT_DST"
umount -n proc
rm -r "$TMP_DIR"