-
Notifications
You must be signed in to change notification settings - Fork 1
/
ubuntu-remaster-bbb.docker
executable file
·82 lines (61 loc) · 1.46 KB
/
ubuntu-remaster-bbb.docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
if [[ -t 2 ]]; then
t_red=$'\e[31m'
t_reset=$'\e(B\e[m'
else
t_red=
t_reset=
fi
bye() {
echo "[wrapper] ${t_red}error:${t_reset} $1"
exit 1
}
usage() {
cat <<EOF
Pass --help option to the script:
ubuntu-remaster-bbb.docker --script-help
Run the script:
ubuntu-remaster-bbb.docker options -- input output
Error messages produced by this wrapper are prefixed with '[wrapper]'
EOF
exit
}
docker_opts=(
-it --rm --init
-u "${SUDO_UID:-$(id -u)}:${SUDO_GID:-$(id -g)}"
)
docker_mounts=()
script_opts=()
run_it() {
exec docker run "${docker_opts[@]}" "${docker_mounts[@]}" \
ubuntu-remaster-bbb "${script_opts[@]}"
}
(( $# )) || usage
split=n
while (( $# )); do
case $1 in
--)
split=y
shift
break ;;
-h|--help)
usage ;;
--script-help)
script_opts=(--help)
run_it ;;
*)
script_opts+=("$1")
shift ;;
esac
done
[[ $split == y ]] || bye '"--" not found among args'
(( $# > 1 )) || bye 'You should provide input and output files'
readonly iso=$1
readonly iso_out=$2
test -e "$iso" || bye "'$_' does not exist"
out_dir=$(dirname "$iso_out")
test -e "$out_dir" || bye "'$_' does no exist"
test -d "$out_dir" || bye "'$_' is not a directory"
docker_mounts=( -v "$iso":/input.iso:ro -v "$out_dir":/output )
script_opts+=( /input.iso /output/"$(basename "$iso_out")" )
run_it