autoport-chroot: allow to specify a chroot command instead of running default shell from command line
This commit is contained in:
parent
d7f48ae5af
commit
1471140bd4
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user