diff options
| author | Richard Mortier <mort@cantab.net> | 2020-01-30 21:03:29 +0000 |
|---|---|---|
| committer | Richard Mortier <mort@cantab.net> | 2020-01-30 21:03:29 +0000 |
| commit | 1b5161717c41d3130c20a62dcc6ade76fb0e8e21 (patch) | |
| tree | f333760ec5ef96493b906cfbadaa3b68e01089f8 /dabuild-admin | |
| parent | f0862dd4808dd4594250cd1d34ae09acdedff919 (diff) | |
| parent | 8ff016b9a6a8f131cef589ffb4a2eb35d7ad79e4 (diff) | |
| download | docker-abuild-1b5161717c41d3130c20a62dcc6ade76fb0e8e21.tar.bz2 docker-abuild-1b5161717c41d3130c20a62dcc6ade76fb0e8e21.tar.xz | |
Merge branch 'multiple_fixes' into 'master'
Multiple fixes and features
See merge request alpine/docker-abuild!60
Diffstat (limited to 'dabuild-admin')
| -rwxr-xr-x | dabuild-admin | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/dabuild-admin b/dabuild-admin new file mode 100755 index 0000000..299cb6a --- /dev/null +++ b/dabuild-admin @@ -0,0 +1,77 @@ +#!/bin/sh + +set -eu + +readonly CMD=${1:-help} +readonly VERSION=unknown +readonly PROGRAM=${0##*/} + +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 +} + +list_volumes() { + docker volume ls --quiet --filter name="^dabuild" +} + +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 + $PROGRAM ($VERSION) + + Available subcommands: + enable: enable multi-arch support via binfmt_misc + disable: disable mutli-arch support + help: this help screen + EOF +} + +usage() { + cat <<- EOF + $PROGRAM ($VERSION) + + Available commands: + config: access abuild configuration + volumes: list created dabuild volumes + multiarch: enable docker multi-arch support + help: this help screen + EOF +} + +case $CMD in + config) manage_config;; + volumes) list_volumes;; + multiarch) multiarch "$@";; + help) usage;; + *) usage; exit 1;; +esac |
