Add helper scripts

This commit is contained in:
Filip Gralinski 2019-11-24 14:39:33 +01:00
parent 99560ba42b
commit d4ba5df3e5
5 changed files with 73 additions and 0 deletions

13
helpers/gitolite/fetch_keys.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
for X in /var/keyswap/*.pub
do
if [[ "$X" != "/var/keyswap/filipg.pub" && "$X" != "/var/keyswap/admin.pub" ]]
then
echo "COPYING $X"
cp "$X" /var/lib/gitolite/.gitolite/keydir/
fi
done
gitolite trigger SSH_AUTHKEYS

32
helpers/gitolite/get_keys.pl Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/perl
use strict;
use DBI;
my $dbh = DBI->connect("dbi:Pg:dbname=gonito", "", "");
my $sh = $dbh->prepare(qq{SELECT * FROM "user" U, public_key K WHERE U.id = K.user and U.id >= 40});
$sh->execute();
while (my $key = $sh->fetchrow_hashref()) {
my $local_id = $key->{'local_id'};
my $pkey = $key->{'pubkey'};
if ($pkey =~ /PRIVATE/) {
print STDERR "$local_id has private key!\n";
} elsif (! defined($local_id) && $local_id !~ /\S/) {
print STDERR "not defined local_id\n";
} else {
if ($pkey !~ /^ssh-rsa /) {
$pkey = 'ssh-rsa ' . $pkey;
}
open my $fh, '>', $local_id.".pub";
print $fh $pkey;
close $fh;
}
}

7
helpers/gitolite/get_keys.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
# script dumps public_keys from gonito DB and writes them into /var/keyswap
# the keys are read into gitolite by another script (fetch_keys.sh) run for a gitolie user
cd /var/keyswap
/home/gonito/get_keys.pl

View File

@ -0,0 +1,16 @@
#!/bin/bash
REPODIR="$1"
if [[ ! -d "$REPODIR" ]]
then
echo "NO DIRECTORY!"
exit 1
fi
chgrp -R git "$REPODIR"
chmod -R g+rX "$REPODIR"
find "$REPODIR" -type d -exec chmod g+s '{}' ';'

View File

@ -0,0 +1,5 @@
* gitolite3 under Ubuntu
* install git-daemon-sysvinit (Ubuntu)
* configure git-daemon (`/etc/default/git-daemon`)
* permission rights to `/var/lib/gitolite3/repositories`