2018-05-24 19:07:19 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
set -o errtrace
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
2018-05-24 19:35:09 +00:00
|
|
|
[ "$(uname)" == "Darwin" ] && alias readlink="greadlink" || :
|
|
|
|
|
2018-05-24 19:07:19 +00:00
|
|
|
pushd() { command pushd "$@" > /dev/null; }
|
|
|
|
popd() { command popd "$@" > /dev/null; }
|
|
|
|
|
|
|
|
here="$(pwd)"
|
|
|
|
script_dir="$(dirname "$(readlink -f "$0")")"
|
|
|
|
|
|
|
|
|
|
|
|
run() {
|
2018-05-24 19:18:03 +00:00
|
|
|
if [[ ! -z "${BUILD:-}" ]];then
|
2018-05-24 19:07:19 +00:00
|
|
|
pushd "$script_dir"
|
|
|
|
docker build -t debian-here .
|
|
|
|
popd
|
2018-05-24 19:18:03 +00:00
|
|
|
exit
|
2018-05-24 19:07:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
mount_point="/mnt/$(basename "$here")"
|
2018-05-24 19:51:51 +00:00
|
|
|
docker run --rm -ti -v "$here":"$mount_point" -w "$mount_point" debian-here "$@"
|
2018-05-24 19:07:19 +00:00
|
|
|
}
|
|
|
|
|
2018-05-24 19:51:51 +00:00
|
|
|
run "$@"
|