diff --git a/autoport-chroot b/autoport-chroot index b462cf1..a37c6a5 100755 --- a/autoport-chroot +++ b/autoport-chroot @@ -6,6 +6,8 @@ . /etc/sysconfig/autoport CHROOT_TARGET=$1 +shift +CHROOT_COMMAND=$@ function usage() { echo "\ @@ -16,7 +18,7 @@ $0 "$"Enters autoport chroot environment."" "$"Usage"": - $me chroot_target + $me chroot_target [command [args..]] " } @@ -35,11 +37,15 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do 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]} + if [ "$CHROOT_COMMAND" ]; then + $CMD_PREFIX /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} su -l $SU_APPEND ${AUTOPORT_CHROOT_USER[$i]} -c "${CHROOT_COMMAND}" + else + 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 $SU_APPEND ${AUTOPORT_CHROOT_USER[$i]} + fi exit 0 done