Debian Codegraph @

contrib/gitolite/get-grok-manifest.command

raw
1 #!/bin/bash
2 # This is a command to install in gitolite's local-code.
3 # Don't forget to enable it via .gitolite.rc
4 #
5 # Change this to where grok-manifest is writing manifest.js
6 MANIFILE="/var/www/html/grokmirror/manifest.js.gz"
7
8 if [[ -z "$GL_USER" ]]; then
9 echo "ERROR: GL_USER is unset. Run me via ssh, please."
10 exit 1
11 fi
12
13 # Make sure we only accept credential replication from the mirrors
14 for MIRROR in $(GL_USER='' gitolite mirror list slaves gitolite-admin); do
15 if [[ $GL_USER == "server-${MIRROR}" ]]; then
16 AOK="yes"
17 break
18 fi
19 done
20
21 if [[ -z "$AOK" ]]; then
22 echo "You are not allowed to do this"
23 exit 1
24 fi
25
26 if [[ ! -s $MANIFILE ]]; then
27 echo "Manifest file not found"
28 exit 1
29 fi
30
31 R_LASTMOD=$1
32 if [[ -z "$R_LASTMOD" ]]; then
33 R_LASTMOD=0
34 fi
35
36 L_LASTMOD=$(stat --printf='%Y' $MANIFILE)
37 if [[ $L_LASTMOD -le $R_LASTMOD ]]; then
38 exit 127
39 fi
40
41 if [[ $MANIFILE == *.gz ]]; then
42 zcat $MANIFILE
43 else
44 cat $MANIFILE
45 fi
46
47 exit 0