gemini-agate-image/entrypoint.sh

83 lines
1.9 KiB
Bash
Raw Normal View History

2021-02-20 20:47:59 +00:00
#!/bin/sh
2022-09-18 12:54:50 +00:00
set -e
2021-02-20 20:47:59 +00:00
create_new_cert(){
if [ ! -d "${GEMINI_CERT_PATH}" ]; then
mkdir ${GEMINI_CERT_PATH}
fi
openssl req -x509 -newkey rsa:4096 -keyout ${GEMINI_CERT_PATH}/key.rsa -out ${GEMINI_CERT_PATH}/cert.pem \
-days 3650 -nodes -subj "/CN=${GEMINI_DOMAIN}"
}
clone_repository(){
git clone ${GEMINI_GIT_REPO} ${GEMINI_GIT_PATH}
2022-09-18 12:54:50 +00:00
prepare_content
2021-02-20 20:47:59 +00:00
}
update_repository(){
if [ ! -d "${GEMINI_GIT_PATH}" ]; then
echo "Cloning repository in ${GEMINI_GIT_PATH}"
clone_repository
else
cd ${GEMINI_GIT_PATH}
git pull
2022-09-18 19:29:28 +00:00
prepare_content
2022-09-18 12:54:50 +00:00
fi
}
prepare_content(){
if [ "${GEMINI_KILN_BUILD}" == "yes" ]; then
2022-09-18 18:41:49 +00:00
if [ "${GEMINI_KILN_SRC}" != "." ]; then
echo "Building content in ${GEMINI_GIT_PATH}/${GEMINI_KILN_SRC} with kiln build"
cd ${GEMINI_GIT_PATH}/${GEMINI_KILN_SRC}
else
echo "Building content in ${GEMINI_GIT_PATH} with kiln build"
cd ${GEMINI_GIT_PATH}
fi
kiln build
2021-02-20 20:47:59 +00:00
fi
}
run_agate(){
2022-09-18 18:41:49 +00:00
echo "---"
echo "* content: ${GEMINI_GTI_PATH}/${GEMINI_CONTENT_FOLDER}"
echo "* content build with kiln: ${GEMINI_KILN_BUILD}"
2022-09-18 18:41:49 +00:00
echo "* content langage: ${GEMINI_LANG}"
echo "* domain: gemini://${GEMINI_DOMAIN}:${GEMINI_PORT} "
echo "---"
2021-02-20 20:47:59 +00:00
/app/agate --content ${GEMINI_GIT_PATH}/${GEMINI_CONTENT_FOLDER} \
2022-09-18 12:54:50 +00:00
--certs ${GEMINI_CERT_PATH} \
--addr [::]:${GEMINI_PORT} \
--addr 0.0.0.0:${GEMINI_PORT} \
2021-02-20 20:47:59 +00:00
--hostname ${GEMINI_DOMAIN} \
--lang ${GEMINI_LANG}
}
default(){
if [ ! -f "${GEMINI_CERT_PATH}/cert.pem" ]; then
2022-09-18 18:41:49 +00:00
echo "No certs found in ${GEMINI_CERT_PATH}. Creates new certificate."
2021-02-20 20:47:59 +00:00
create_new_cert
fi
if [ ! -d "${GEMINI_GIT_PATH}" ]; then
echo "Cloning repository in ${GEMINI_GIT_PATH}"
clone_repository
else
update_repository
fi
run_agate
}
if [ "$#" -eq "1" ]; then
if [ "$1" = "run" ]; then
default
elif [ "$1" = "update" ]; then
update_repository
fi
else
echo "unknown command. launching default"
default
fi