-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.sh
executable file
·39 lines (35 loc) · 1.23 KB
/
helper.sh
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
#!/bin/bash
# Set $DOCKER to installed docker runtime binary, preferring podman
DOCKER=$(which podman || which docker || echo "not found")
if [ "$DOCKER" = "not found" ]; then
echo "Error: Either Podman or Docker must be installed."
exit 1
fi
function help_msg() {
echo "Usage:"
echo " helper.sh build"
echo " Build the quadletron container. Must cd into the repo first."
echo " helper.sh run <quadletron-dir>"
echo " Create iso file from a given config. Output goes to ./out/"
echo " helper.sh -h/--help"
echo " Show this message."
}
case $1 in
'build') sudo "$DOCKER" build -t quadletron . || echo "Note: Must cd to the root of the repo first.";;
'run') mkdir -p ./out;
# Run mkarchiso
sudo "$DOCKER" run \
--privileged \
-v "$(realpath "$2"):/config" \
-v ./out:/out \
localhost/quadletron:latest;
# Find the newest iso in ./out
# shellcheck disable=SC2012
iso_file=$(ls -t ./out | head -n 1)
# Change owner to the current user
if [ -f "./out/$iso_file" ]; then
sudo chown -R "$USER" "out/$iso_file"
fi
;;
'-h'|'--help'|'help'|'') help_msg;;
esac