autodist/autoport-chroot

45 lines
961 B
Bash
Executable File

#!/bin/bash
#
# autoport-chroot
# (c) 2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
. /etc/sysconfig/autoport
CHROOT_TARGET=$1
function usage() {
echo "\
$0
"$"Copyright (C) 2012 Silvan Calarco <silvan.calarco@mambasoft.it>""
"$"Released under the terms of the GNU GPL v3 license"
echo "
"$"Enters autoport chroot environment.""
"$"Usage"":
$me chroot_target
"
}
[ "$CHROOT_TARGET" ] || {
usage
exit 1
}
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
[ "${AUTOPORT_CHROOT[$i]}" = "$CHROOT_TARGET" ] || continue
if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then
CMD_PREFIX=linux32
else
CMD_PREFIX=
fi
echo "Entering ${AUTOPORT_CHROOT[$i]} autoport chroot environment"
$CMD_PREFIX /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} su -l ${AUTOPORT_CHROOT_USER[$i]}
exit 0
done
echo "$CHROOT_TARGET: undefined chroot target"
exit 1