Commit 86fc81da authored by Carlo Landmeter's avatar Carlo Landmeter

admin: multiarch add enable/disable with warning

parent 01864fcb
......@@ -4,6 +4,24 @@ set -eu
readonly cmd=${1:-help}
die() {
echo "$@" >&2
exit 1
}
ask() {
local question="$1"
while true; do
# SC2039 -p is non posix but widely available
read -rp "$question" yn
case $yn in
[Yy]) return 0;;
[Nn]) exit;;
*) echo "Please answer y/n.";;
esac
done
}
manage_config() {
docker run --user 1000:1000 --rm -it --workdir /mnt/abuild \
-v dabuild-config:/mnt/abuild alpine sh
......@@ -13,9 +31,27 @@ list_volumes() {
docker volume ls --quiet --filter name="^dabuild"
}
enable_multiarch() {
docker run --rm --privileged multiarch/qemu-user-static \
--reset --persistent yes --credential yes
multiarch() {
case "${2:-help}" in
enable) ask "Are you sure you want to enable multi-arch system wide? (y/n): "
docker run --rm --privileged multiarch/qemu-user-static \
--reset --persistent yes --credential yes ;;
disable) sudo --prompt="Sudo password:" find /proc/sys/fs/binfmt_misc \
-type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \; ;;
help) multiarch_usage ;;
*) die "Unknown subcommand \"$2\"" ;;
esac
}
multiarch_usage() {
cat <<- EOF
dabuild: version (unknown)
Available subcommands:
enable: enable multi-arch support via binfmt_misc
disable: disable mutli-arch support
help: this help screen
EOF
}
usage() {
......@@ -30,11 +66,10 @@ usage() {
EOF
}
case $cmd in
config) manage_config;;
volumes) list_volumes;;
multiarch) enable_multiarch;;
multiarch) multiarch "$@";;
help) usage;;
*) usage; exit 1;;
esac
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment