mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-03 00:00:24 -04:00
testing: Run commands in chroot in a login shell
Similar to the previous commit, this ensures we have the same environment we do later on the system.
This commit is contained in:
parent
870aa75eed
commit
ddeb3c463e
@ -48,9 +48,23 @@ execute()
|
|||||||
|
|
||||||
# execute command in chroot
|
# execute command in chroot
|
||||||
# $1 - command to execute
|
# $1 - command to execute
|
||||||
|
# $2 - whether or not to log command exit status
|
||||||
|
# (0 -> disable exit status logging)
|
||||||
execute_chroot()
|
execute_chroot()
|
||||||
{
|
{
|
||||||
execute "chroot $LOOPDIR env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin $@"
|
cmd=${1}
|
||||||
|
echo chroot $LOOPDIR $cmd >>$LOGFILE 2>&1
|
||||||
|
chroot $LOOPDIR /bin/bash -l <<-EOF >>$LOGFILE 2>&1
|
||||||
|
$cmd
|
||||||
|
EOF
|
||||||
|
status=$?
|
||||||
|
[ "$2" != 0 ] && log_status $status
|
||||||
|
if [ $status != 0 ]; then
|
||||||
|
echo
|
||||||
|
echo "! Command chroot $LOOPDIR $cmd failed, exiting (status $status)"
|
||||||
|
echo "! Check why here $LOGFILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# write green status message to console
|
# write green status message to console
|
||||||
|
Loading…
x
Reference in New Issue
Block a user