commit:     c34323cac9e58597528c2e754fe3b45fe53ccae7
Author:     NP-Hardass <NP-Hardass <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 20 21:04:47 2016 +0000
Commit:     NP Hardass <np-hardass <AT> gentoo <DOT> org>
CommitDate: Tue Sep 20 21:06:12 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-mate.git/commit/?id=c34323ca

scripts: Add script to initialize hooks and remotes for mirror

 scripts/hooks/post-receive |  3 +++
 scripts/init-repo-mirror   | 51 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/scripts/hooks/post-receive b/scripts/hooks/post-receive
new file mode 100755
index 0000000..0ca209b
--- /dev/null
+++ b/scripts/hooks/post-receive
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+nohup git push github &>/dev/null &

diff --git a/scripts/init-repo-mirror b/scripts/init-repo-mirror
new file mode 100755
index 0000000..d2910d9
--- /dev/null
+++ b/scripts/init-repo-mirror
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+die(){
+       echo "$@"
+       exit 1
+}
+
+help_info(){
+       echo "Initialize repository to allow mirroring."
+       echo "--hooks: installs git hooks for syncronization"
+       echo "--remotes: configures github remotes"
+       echo "--help/-h: display this message"
+       exit 0
+}
+
+[[ -d .git/ ]] || die "Must be run from repository root!"
+
+if [[ $# -eq 0 ]]; then
+       eval set -- "--hooks --remotes"
+fi
+
+OPTS=`getopt -o h --long hooks,remotes,help -n 'parse-options' -- "$@"`
+
+if [[ $? -ne 0 ]]; then
+       die "Invalid arguments"
+fi
+
+eval set -- "${OPTS}"
+
+HOOKS=false
+REMOTES=false
+
+while true; do
+       case "$1" in
+               --hooks ) HOOKS=true; shift ;;
+               --remotes ) REMOTES=true; shift ;;
+               --help | -h ) help-info ;;
+               -- ) shift; break;;
+               * ) break ;;
+       esac
+done
+
+if ${HOOKS}; then
+       echo "Installing Repository Hooks"
+       cp scripts/hooks/post-receive .git/hooks/post-receive || die "Failed to 
install hooks"
+fi
+
+if ${REMOTES}; then
+       echo "Configuring Remotes"
+       git add remote github https://github.com/gentoo/gentoo-mate/ || die 
"Failed to configure remotes"
+fi

Reply via email to