xrforge/manyfold/cli/manyfold.sh

58 lines
1.5 KiB
Bash
Raw Normal View History

2025-07-22 13:16:53 +02:00
#!/bin/sh
oci=$(which podman || which docker)
create_config(){
test -d ./config || mkdir config
test -d ./experiences || mkdir experiences
}
colorize(){ printf "\033[96m%s\033[0m \033[95m%s\033[0m %s\n" "$1" "$2" "$3"; }
debug(){ set -x; "$@"; set +x; }
run(){
test -x ${oci} || { echo "warning: not running manyfold OCI container [install podman/docker/etc]"; exit; }
colorize "[manyfold.sh]" "$(basename ${oci}) detected..starting OCI container"
${oci} rm -f manyfold
debug ${oci} run "$@" -d -p 8790:3214 --name manyfold \
-v ./config:/config \
-v ./experiences:/experiences \
-v ./:/root \
$(template_overrides) \
-e SECRET_KEY_BASE=lkjwljlkwejrlkjek34k234l \
-e DATABASE_ADAPTER=sqlite3 \
-e SUDO_RUN_UNSAFELY=enabled \
-e MULTIUSER=enabled \
-e FEDERATION=enabled \
-e PUBLIC_HOSTNAME=localhost \
-e PUBLIC_PORT=80 \
ghcr.io/manyfold3d/manyfold-solo:latest
sleep 1
patch_manyfold
}
template_overrides(){
cd manyfold > /dev/null && find * -type f | awk '/.*/ { printf "-v ./manyfold/"$0":/"$0" " }';
}
patch_manyfold(){
colorize "[manyfold.sh]" "patching.."
${oci} exec manyfold id
}
is_inside_container(){
test -d /package/admin && return 0 || return 1
}
usage(){
colorize "Usage:" manyfold.sh "<cmd>"
colorize "Cmds:"
colorize " " "run [-d] " "# runs a OCI container (needs podman/docker)"
exit 0
}
is_inside_container || {
test -n "$1" && "$@"
test -n "$1" || usage
}