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

Some argument parsing in add_mirror.sh (not functional)

parent 612836fe
No related branches found
No related tags found
No related merge requests found
config.sh
*.pyc
...@@ -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
......
#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")"
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