summaryrefslogtreecommitdiff
path: root/mkgit
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2013-05-10 20:46:04 +0200
committerJonas Smedegaard <dr@jones.dk>2013-05-10 20:46:04 +0200
commit27d338dec0428bc22e2838eb8641c6e0d1681e22 (patch)
tree18eeb76e189ce03838dd9b23194f1c707b1eabbb /mkgit
Include mk* scripts
Diffstat (limited to 'mkgit')
-rwxr-xr-xmkgit43
1 files changed, 43 insertions, 0 deletions
diff --git a/mkgit b/mkgit
new file mode 100755
index 0000000..99449a6
--- /dev/null
+++ b/mkgit
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# create local git, and create and push to remote git
+
+set -e
+
+login=debian@source.jones.dk
+path="/srv/git/source.jones.dk/epfsug/diff"
+
+# resolve options
+eval set -- "$(getopt -s sh -o f -- "$@")"
+while true; do case "$1" in -f) force=-f; shift;; --) shift; break;; esac; done
+
+. /lib/lsb/init-functions
+
+# add suffix unless already included
+gitpath="$(dirname "$path")/$(basename "$path" .git).git"
+
+log_action_begin_msg "Publish git"
+
+# initialize local git
+log_action_cont_msg "init"
+if [ -d .git ]; then
+ if [ -n "$force" ]; then
+ log_warning_msg "purging"
+ rm -rf .git
+ else
+ log_failure_msg "local git already exist (force with -f)"
+ exit 1
+ fi
+fi
+git init
+
+# add scripts
+log_action_cont_msg "add"
+git add mk*; git commit -m "Include mk* scripts"
+
+# create and populate remote git
+log_action_cont_msg "push"
+ssh "$login" git init --bare "$gitpath" \&\& cd "$gitpath" \&\& mv hooks/post-update{.sample,} \&\& touch git-daemon-export-ok
+git push $force --all -u "$login:$gitpath" || { log_failure_msg "remote git already exist (force with -f)"; exit 1; }
+
+log_action_end_msg $?