#!/bin/bash # # autoport-chroot # (c) 2012-2013 by Silvan Calarco # . /etc/sysconfig/autoport CHROOT_TARGET=$1 function usage() { echo "\ $0 "$"Copyright (C) 2012 Silvan Calarco "" "$"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" [ -e /var/autoport/${AUTOPORT_CHROOT[$i]}/etc/profile.d/autoport.sh ] || { echo "PS1='[\u@${AUTOPORT_CHROOT[$i]} \W]\$ '" > /var/autoport/${AUTOPORT_CHROOT[$i]}/etc/profile.d/autoport.sh } $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