Permalink
Browse files

new program for emergency addkey; run without args for usage

  • Loading branch information...
1 parent c4069dd commit 4d9c064a7a4569df18fb04bdcf278acac923817a Sitaram Chamarty committed Nov 7, 2009
Showing with 40 additions and 0 deletions.
  1. +40 −0 src/99-emergency-addkey.sh
View
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# what/why: re-establish gitolite admin access when admin key(s) lost
+# where: on server (NOT client!)
+
+# pre-req: shell access to the server (even with password is fine)
+# pre-work: - make yourself a new keypair on your workstation
+# - copy the pubkey and this script to the server
+
+# usage: $0 admin_name client_host_shortname pubkeyfile
+# notes: - admin_name should already have RW or RW+ access to the
+# gitolite-admin repo
+# - client_host_shortname is any simple word; see example below
+
+# WARNING: ABSOLUTELY NO ARGUMENT CHECKING DONE
+# WARNING: NEWER GITS ONLY ON SERVER SIDE (for now)
+
+# example: $0 sitaram laptop /tmp/sitaram.pub
+# result: a new keyfile named sitaram@laptop.pub would be added
+
+# ENDHELP
+
+[[ -z $1 ]] && { perl -pe "s(\\\$0)($0); last if /ENDHELP/" < $0; exit 1; }
+
+set -e
+
+cd
+REPO_BASE=$( perl -e 'do ".gitolite.rc"; print $REPO_BASE' )
+GL_ADMINDIR=$(perl -e 'do ".gitolite.rc"; print $GL_ADMINDIR')
+
+cd; cd $GL_ADMINDIR/keydir; pwd
+cp -v $3 $1@$2.pub
+
+cd; cd $REPO_BASE/gitolite-admin.git; pwd
+# XXX FIXME TODO -- fix this to work with older gits also
+GIT_WORK_TREE=$GL_ADMINDIR git add keydir
+GIT_WORK_TREE=$GL_ADMINDIR git commit -m "emergency add $1@$2.pub"
+
+cd $GL_ADMINDIR
+src/gl-compile-conf

0 comments on commit 4d9c064

Please sign in to comment.