]> git.phdru.name Git - git-scripts.git/blobdiff - copy-scripts/copy-scripts
Add `copy-scripts/`: Copy this repo to a remote host
[git-scripts.git] / copy-scripts / copy-scripts
diff --git a/copy-scripts/copy-scripts b/copy-scripts/copy-scripts
new file mode 100755 (executable)
index 0000000..2201c0f
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Copy git-scripts to an ssh-accessible remote host;
+# setup bare and non-bare repositories and the post-update hook.
+
+if [ $# -ne 3 ]; then
+   echo "Usage: $0 [user@]host directory remote_name" >&2
+   exit 1
+fi
+
+remote_host="$1"
+remote_dir="$2"
+remote_name="$3"
+
+ssh "$remote_host" "cd $remote_dir && exec git init --bare git-scripts.git" &&
+git remote add "$remote_name" "$remote_host:$remote_dir/git-scripts.git" &&
+git push "$remote_name" master &&
+exec ssh "$remote_host" "cd $remote_dir && git clone git-scripts.git &&
+   cd git-scripts.git/hooks &&
+   exec ln -s ../../git-scripts/copy-scripts/post-update"