services-garbaye/podman-gitea/10_install.sh
2022-08-07 19:12:45 +02:00

75 lines
4.1 KiB
Bash
Executable file

#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
ensure_pod_not_exists ${pod_name}
ensure_variables_are_defined "$envvars"
if ! podman volume exists ${dbvolume} ; then
echo "Error : DB volume ${dbvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
if ! podman volume exists ${datavolume} ; then
echo "Error : DATA volume ${datavolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
cat <<EOT >> .env
APP_NAME=${GARBAYE_GITEA_APPNAME}
GITEA__database__DB_TYPE=postgres
GITEA__database__HOST=db:5432
GITEA__database__NAME=gitea
GITEA__database__PASSWD=${GARBAYE_GITEA_POSTGRES_PASSWORD}
GITEA__database__USER=gitea
GITEA__mailer__ENABLED=true
GITEA__mailer__FROM=${GARBAYE_GITEA_SMTP_FROM}
GITEA__mailer__HOST="${GARBAYE_GITEA_SMTP_SERVER}:25"
GITEA__security__INSTALL_LOCK=true
GITEA__server__DOMAIN=${GARBAYE_GITEA_DOMAIN}
GITEA__server__SSH_DOMAIN=${GARBAYE_GITEA_DOMAIN}
GITEA__server__ROOT_URL="https://${GARBAYE_GITEA_DOMAIN}"
GITEA__server__SSH_PORT=${sshlisten_port}
GITEA__service__DISABLE_REGISTRATION=true
POSTGRES_DB=gitea
POSTGRES_PASSWORD=${GARBAYE_GITEA_POSTGRES_PASSWORD}
POSTGRES_USER=gitea
EOT
export gitea_image
export gitea_version
export postgres_image
export postgres_version
export weblisten_if
export weblisten_port
export sshlisten_if
export sshlisten_port
source ${ABSDIR}/zz_build-images.sh
podman image exists ${gitea_image}:${gitea_version} &&
podman pull ${postgres_image}:${postgres_version} &&
# force refresh of app.ini
podman unshare rm -f `get_podman_volume_path ${datavolume}`/gitea/conf/app.ini
podman-compose --podman-run-args "--env-file .env" up -d &&
echo -n "Waiting for gitea to finish starting " &&
( podman logs -f ${container_name} 2>&1 & ) | grep -q 'NewServer()' &&
echo "OK" &&
podman exec --user 1000:1000 gitea gitea embedded extract --overwrite --destination /data/gitea/ 'templates/home.tmpl'
podman unshare sed -i '/{{.i18n.Tr \"startpage.app_desc\"}}/,${s//Plateforme collaborative de projets libres./;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman unshare sed -i '/{{.i18n.Tr \"startpage.install\"}}/,${s//Qui peut avoir un compte ?/;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman unshare sed -i '/{{.i18n.Tr \"startpage.install_desc\" | Str2html}}/,${s//Pour des raisons de capacité et de gestion, cette instance n\x27est pas ouverte au public./;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman unshare sed -i '/{{.i18n.Tr \"startpage.lightweight\"}}/,${s//Comment créer un compte ?/;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman unshare sed -i '/{{.i18n.Tr \"startpage.lightweight_desc\" | Str2html}}/,${s//Si vous souhaitez avoir un compte, <a href="https:\/\/garbaye.fr\/contact\/">contactez nous<\/a> pour parler de vos besoins./;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman unshare sed -i '/{{.i18n.Tr \"startpage.platform\"}}/,${s//Quels contenus sont acceptés ?/;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman unshare sed -i '/{{.i18n.Tr \"startpage.platform_desc\" | Str2html}}/,${s//La forge accueille tout type de contenu tel que code source, documentation, artistique, littéraire, etc. Un usage raisonnable en espace disque est attendu de nos utilisateurs./;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman unshare sed -i '/{{.i18n.Tr \"startpage.license\"}}/,${s//Licences libres/;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman unshare sed -i '/{{.i18n.Tr \"startpage.license_desc\" | Str2html}}/,${s//Tous les projets présents sur cette forge sont publiés sous licences libres, <a href="https:\/\/www.gnu.org\/licenses\/license-list.fr.html">au sens de la Free Software Foundation<\/a>./;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl &&
podman pod stop ${pod_name} &&
echo Pod built and stopped. &&
shred -u .env