Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gitlab-mirrors
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wonko
gitlab-mirrors
Commits
cbf51276
Commit
cbf51276
authored
11 years ago
by
Sam Gleske
Browse files
Options
Downloads
Patches
Plain Diff
Some argument parsing in add_mirror.sh (not functional)
parent
612836fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
add_mirror.sh
+102
-3
102 additions, 3 deletions
add_mirror.sh
config.sh
+0
-22
0 additions, 22 deletions
config.sh
with
104 additions
and
25 deletions
.gitignore
0 → 100644
+
2
−
0
View file @
cbf51276
config.sh
*.pyc
This diff is collapsed.
Click to expand it.
add_mirror.sh
+
102
−
3
View file @
cbf51276
...
@@ -3,15 +3,114 @@
...
@@ -3,15 +3,114 @@
#USAGE
#USAGE
# ./add_mirror.sh project_name http://example.com/project.git
# ./add_mirror.sh project_name http://example.com/project.git
#Include all user options
.
"
$(
dirname
$0
)
/config.sh"
cd
$(
dirname
$0
)
PROGNAME
=
"
${
0
##*/
}
"
PROGVERSION
=
"v0.2"
#Default script options
svn
=
false
git
=
false
project_name
=
""
mirror
=
""
#Short options are one letter. If an argument follows a short opt then put a colon (:) after it
SHORTOPTS
=
"hvm:p:"
LONGOPTS
=
"help,version,git,svn,mirror:,project:"
usage
()
{
cat
<<
EOF
${
PROGNAME
}
${
PROGVERSION
}
- MIT License by Sam Gleske
DESCRIPTION:
This will add a git or SVN repository to be mirrored by GitLab. It
first checks to see if the project exists in gitlab. If it does
not exist then it creates it. It will then clone and check in the
first copy into GitLab. From there you must use the update_mirror.sh
script or git git-mirrors.sh script.
-h,--help Show help
-v,--version Show program version
--git Mirror a git repository (must be explicitly set)
--svn Mirror a SVN repository (must be explicitly set)
--project NAME Set a GitLab project name to NAME.
--mirror URL Repository URL to be mirrored.
EOF
}
ARGS
=
$(
getopt
-s
bash
--options
"
${
SHORTOPTS
}
"
--longoptions
"
${
LONGOPTS
}
"
--name
"
${
PROGNAME
}
"
--
"
$@
"
)
eval set
--
"
$ARGS
"
echo
"
$ARGS
"
while
true
;
do
case
$1
in
-h
|
--help
)
usage
exit
1
;;
-v
|
--version
)
echo
"
${
PROGNAME
}
${
PROGVERSION
}
"
exit
1
;;
--git
)
git
=
true
shift
;;
--svn
)
svn
=
true
shift
;;
-p
|
--project
)
project_name
=
"
${
2
}
"
shift
2
;;
-m
|
--mirror
)
mirror
=
"
${
2
}
"
shift
2
;;
--
)
shift
break
;;
*
)
shift
break
;;
esac
done
echo
"svn=
${
svn
}
"
echo
"git=
${
git
}
"
echo
"project_name=
${
project_name
}
"
echo
"mirror=
${
mirror
}
"
exit
if
[
"
${#}
"
-lt
"2"
]
;
then
if
[
"
${#}
"
-lt
"2"
]
;
then
echo
"Not enough arguments."
1>&2
echo
"Not enough arguments."
1>&2
echo
"e.g. ./add_mirror.sh project_name http://example.com/project.git"
1>&2
echo
"e.g. ./add_mirror.sh project_name http://example.com/project.git"
1>&2
exit
1
exit
1
fi
fi
#Include all user options
.
"
$(
dirname
$0
)
/config.sh"
cd
$(
dirname
$0
)
#export env vars for python script
#export env vars for python script
export
gitlab_user_token_secret gitlab_url gitlab_namespace gitlab_user
export
gitlab_user_token_secret gitlab_url gitlab_namespace gitlab_user
...
...
This diff is collapsed.
Click to expand it.
config.sh
deleted
100644 → 0
+
0
−
22
View file @
612836fe
#Environment file
#
# gitlab-mirror settings
#
system_user
=
"gitmirror"
user_home
=
"/home/
${
system_user
}
"
repo_dir
=
"
${
user_home
}
/repositories"
#
# 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
"
${
user_home
}
/private_token"
)
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment