feat: add mirror feature

This commit is contained in:
Glenn Y. Rolland 2021-05-08 17:12:26 +02:00
parent 2fef356268
commit 50b3b5ef68

View file

@ -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