#!/bin/sh 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} } update_repository(){ if [ ! -d "${GEMINI_GIT_PATH}" ]; then echo "Cloning repository in ${GEMINI_GIT_PATH}" clone_repository else cd ${GEMINI_GIT_PATH} git pull fi } run_agate(){ /app/agate --content ${GEMINI_GIT_PATH}/${GEMINI_CONTENT_FOLDER} \ --key ${GEMINI_CERT_PATH}/key.rsa \ --cert ${GEMINI_CERT_PATH}/cert.pem \ --addr [::]:1965 \ --addr 0.0.0.0:1965 \ --hostname ${GEMINI_DOMAIN} \ --lang ${GEMINI_LANG} } default(){ if [ ! -f "${GEMINI_CERT_PATH}/cert.pem" ]; then echo "No certs found in {GEMINI_CERT_PATH}. Creates new certificate." create_new_cert fi if [ ! -d "${GEMINI_GIT_PATH}" ]; then echo "Cloning repository in ${GEMINI_GIT_PATH}" clone_repository else update_repository fi echo "Starting agate for gemini://${GEMINI_DOMAIN}" 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