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
|
||||
|
||||
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 $?
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue