From 50b3b5ef68f2816a0a71a1228edb2840ee6bc789 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Sat, 8 May 2021 17:12:26 +0200 Subject: [PATCH] feat: add mirror feature --- docker-entrypoint.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 1da2c1d..03186fe 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,6 +1,12 @@ #!/bin/sh set -e +set -u + +GITIT_USER_EMAIL=${GITIT_USER_EMAIL:-} +GITIT_USER_NAME=${GITIT_USER_NAME:-} +GITIT_REMOTE_REPOSITORY=${GITIT_REMOTE_REPOSITORY:-} +GITIT_REMOTE_DOMAIN=${GITIT_REMOTE_DOMAIN:-} if [ ! -f /data/gitit.conf ]; then echo "Building config for gitit" @@ -11,9 +17,11 @@ fi ## Check existing variables if [ -z "$GITIT_USER_EMAIL" ]; then + 2>& echo "ERROR: Environment variable GITIT_USER_EMAIL not defined" exit 1 fi if [ -z "$GITIT_USER_NAME" ]; then + 2>& echo "ERROR: Environment variable GITIT_USER_NAME not defined" exit 1 fi @@ -27,10 +35,27 @@ if [ ! -d /data/wikidata/.git ]; then fi git config diff.renames false - git config --global user.email "$GITIT_USER_EMAIL" git config --global user.name "$GITIT_USER_NAME" +if [ -n "$GITIT_REMOTE_REPOSITORY" ]; then + if [ -z "$GITIT_REMOTE_DOMAIN" ]; then + 2>& echo "ERROR: Environment variable GITIT_REMOTE_DOMAIN not defined" + exit 1 + fi + git remote remove origin + git remote add origin "$GITIT_REMOTE_REPOSITORY" + + mkdir -p /root/.ssh + cat > /root/.ssh/config <<-MARK + Host github.com + User git + IdentityFile /data/ssh/mirror_rsa + MARK + chmod 600 /root/.ssh/config + chmod 700 /root/.ssh +fi + cd "$CUR" if [ "$1" = 'gitit' ]; then