Allow command args

This commit is contained in:
DarkCat09 2024-04-09 17:49:52 +04:00
parent cb250e4feb
commit 2931330ad4
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

11
run.sh
View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
help () {
echo 'dchr-run <chroot-dir> <command>'
echo 'dchr-run <chroot-dir> [command]'
echo 'https://dchr.dc09.ru'
}
@ -28,19 +28,22 @@ setup () {
runcmd () {
echo -e '-- \e[1;32mOK\e[0m -- running chroot'
chroot "$1" "$2"
chrdir="$1"
shift
chrcmd=("$@")
chroot "$chrdir" "${chrcmd[@]}"
}
main () {
[[ "$1" == "--help" || "$1" == "" ]] && help && exit 0
chrdir=$(readlink -f "$1")
chrcmd="${2:-/bin/bash}"
shift
trap "clean \"$chrdir\"" EXIT
setup "$chrdir"
runcmd "$chrdir" "$chrcmd"
runcmd "$chrdir" "$@"
exit $?
}