2024-08-22 21:03:07 +05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
LIST_FILE="/data/gitea-init/repos.list"
|
|
|
|
ENV_FILE="/data/gitea-init/install.env"
|
|
|
|
|
2024-08-22 23:50:33 +05:00
|
|
|
trap 'echo -e "\033[31mpush-all.sh: Something went wrong\033[0m"; exit 1' ERR
|
2024-08-22 21:03:07 +05:00
|
|
|
set -e
|
|
|
|
|
|
|
|
echo "Checking for a repos.list file..."
|
|
|
|
if [ ! -f "$LIST_FILE" ]; then
|
|
|
|
echo "File $LIST_FILE not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Including a file with environment variables..."
|
|
|
|
if [ -f $ENV_FILE ]; then
|
|
|
|
source $ENV_FILE
|
|
|
|
else
|
|
|
|
echo "File install.env not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Reading a CSV file and creating repositories..."
|
|
|
|
OLDIFS=$IFS
|
|
|
|
IFS=' | '
|
|
|
|
while read -r NAME_REPO DESCRIPTION_REPO; do
|
|
|
|
if [ "$NAME_REPO" != "NAME_REPO" ]; then # Skip title
|
|
|
|
cd /data/$NAME_REPO
|
|
|
|
git remote remove ${PREFIX}$NAME_REPO
|
|
|
|
git remote add ${PREFIX}$NAME_REPO git@$GITEA_API_HOST:$GITEA_USER_NAME/$NAME_REPO.git
|
|
|
|
git push ${PREFIX}$NAME_REPO $GIT_BRANCH
|
|
|
|
fi
|
|
|
|
done < "$LIST_FILE"
|
|
|
|
IFS=$OLDIFS
|
|
|
|
|
|
|
|
trap - ERR
|
|
|
|
echo "Create all complete"
|