Allow command args
This commit is contained in:
parent
cb250e4feb
commit
2931330ad4
1 changed files with 7 additions and 4 deletions
11
run.sh
11
run.sh
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
help () {
|
help () {
|
||||||
echo 'dchr-run <chroot-dir> <command>'
|
echo 'dchr-run <chroot-dir> [command]'
|
||||||
echo 'https://dchr.dc09.ru'
|
echo 'https://dchr.dc09.ru'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,19 +28,22 @@ setup () {
|
||||||
|
|
||||||
runcmd () {
|
runcmd () {
|
||||||
echo -e '-- \e[1;32mOK\e[0m -- running chroot'
|
echo -e '-- \e[1;32mOK\e[0m -- running chroot'
|
||||||
chroot "$1" "$2"
|
chrdir="$1"
|
||||||
|
shift
|
||||||
|
chrcmd=("$@")
|
||||||
|
chroot "$chrdir" "${chrcmd[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main () {
|
main () {
|
||||||
[[ "$1" == "--help" || "$1" == "" ]] && help && exit 0
|
[[ "$1" == "--help" || "$1" == "" ]] && help && exit 0
|
||||||
|
|
||||||
chrdir=$(readlink -f "$1")
|
chrdir=$(readlink -f "$1")
|
||||||
chrcmd="${2:-/bin/bash}"
|
shift
|
||||||
|
|
||||||
trap "clean \"$chrdir\"" EXIT
|
trap "clean \"$chrdir\"" EXIT
|
||||||
|
|
||||||
setup "$chrdir"
|
setup "$chrdir"
|
||||||
runcmd "$chrdir" "$chrcmd"
|
runcmd "$chrdir" "$@"
|
||||||
exit $?
|
exit $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue