Files
ctf/2025/glacier/web/glacier-todo/deploy.sh
2025-11-28 12:20:39 +01:00

52 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
check() {
echo -e "\e[1;34m[+] Verifying Challenge Integrity\e[0m"
sha256sum -c sha256sum
}
build_container() {
echo -e "\e[1;34m[+] Building Challenge Docker Container\e[0m"
docker build -t localhost/chall-glacier-todo --platform linux/amd64 --pull=true .
}
# Common error on default Ubuntu 24.04:
#
# initCloneNs():391 mount('/', '/', NULL, MS_REC|MS_PRIVATE, NULL): Permission denied
# Change --user 1337:1337 to --user 0:0 in run_container()
# or
# $ sudo sysctl -w kernel.apparmor_restrict_unprivileged_unconfined=0
# $ sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
# and then restore them back when finished
run_container() {
echo -e "\e[1;34m[+] Running Challenge Docker Container on 127.0.0.1:1337\e[0m"
docker run --name chall-glacier-todo --rm -p 1337:80 localhost/chall-glacier-todo
}
kill_container() {
docker ps --filter "name=chall-glacier-todo" --format "{{.ID}}" \
| tr '\n' ' ' \
| xargs docker stop -t 0 \
|| true
}
case "${1}" in
"check")
check
;;
"build")
build_container
;;
"run")
run_container
;;
"kill")
kill_container
;;
*)
check
build_container && run_container
;;
esac