Skip to content
Snippets Groups Projects
Commit d1745c5d authored by Sam Gleske's avatar Sam Gleske
Browse files

Config update and output update.

Adding comments to config.sh.
Renamed a few config.sh variables to be more intuitive.

add_mirror.sh has better user output.  Updated to reflect
new config.sh.

git-mirrors.sh now outputs proper error codes.

create_gitlab_project.py updated to reflect new config.sh
parent 291d8f11
No related branches found
No related tags found
No related merge requests found
......@@ -8,12 +8,15 @@
. "$(dirname $0)/config.sh"
cd $(dirname $0)
export token_secret gitlab_url gitlab_namespace gitlab_user
#export env vars for python script
export gitlab_user_token_secret gitlab_url gitlab_namespace gitlab_user
#Get the remote gitlab url for the specified project.
#If the project doesn't already exist in gitlab then create it.
if python lib/create_gitlab_project.py $1 &> /dev/null;then
echo "Resolving gitlab remote."
if python lib/create_gitlab_project.py $1 1> /dev/null;then
gitlab_remote=$(python lib/create_gitlab_project.py $1)
echo "gitlab remote ${gitlab_remote}"
else
echo "There was an unknown issue with create_gitlab_project.py" 1>&2
exit 1
......@@ -22,14 +25,18 @@ fi
mkdir -p "${repo_dir}/${gitlab_namespace}"
#create a mirror
echo "Creating mirror from $2"
cd "${repo_dir}/${gitlab_namespace}"
git clone --mirror $2 "$1"
cd "$1"
#add the gitlab remote
echo "Adding gitlab remote to project."
git remote add gitlab ${gitlab_remote}
git config --add remote.gitlab.push '+refs/heads/*:refs/heads/*'
git config --add remote.gitlab.push '+refs/heads/*:refs/heads/*'
#Check the initial repository into gitlab
echo "Checking the mirror into gitlab."
git fetch
git remote prune origin
git push gitlab
echo "All done!"
#Environment file
#
# gitlab-mirror settings
#
repo_dir="/home/gitmirror/repositories"
mirror_list=("gitlabhq")
token_secret="$(head -n1 /home/gitmirror/private_token)"
#This group will contain all code mirrors
#
# Gitlab settings
#
#This is the Gitlab group where all project mirrors will be grouped.
gitlab_namespace="Mirrors"
#This is the web url of your Gitlab server. no trailing slash, just the protocol and server name.
gitlab_url="https://comet.irt.drexel.edu"
#Special user you created in Gitlab whose only purpose is to update mirror sites and admin the $gitlab_namespace group.
gitlab_user="gitmirror"
#Generate a token for your $gitlab_user and set it here.
gitlab_user_token_secret="$(head -n1 /home/gitmirror/private_token)"
......@@ -5,8 +5,12 @@
. "$(dirname $0)/config.sh"
cd $(dirname $0)
STATUS=0
ls -1 "${repo_dir}/${gitlab_namespace}" | while read mirror;do
if ! ./update_mirror.sh "${mirror}" &> /dev/null;then
echo "Error: ./update_mirror.sh ${mirror}" 1>&2
STATUS=1
fi
done
exit ${STATUS}
......@@ -7,7 +7,7 @@ import gitlab
try:
project_name=argv[1]
token_secret=os.environ['token_secret']
token_secret=os.environ['gitlab_user_token_secret']
gitlab_url=os.environ['gitlab_url']
gitlab_namespace=os.environ['gitlab_namespace']
gitlab_user=os.environ['gitlab_user']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment