aboutsummaryrefslogtreecommitdiff
path: root/packages/crashbox-config/git
diff options
context:
space:
mode:
Diffstat (limited to 'packages/crashbox-config/git')
-rw-r--r--packages/crashbox-config/git/etc/cgitrc.d/crashbox63
-rw-r--r--packages/crashbox-config/git/etc/gh-mirror4
-rw-r--r--packages/crashbox-config/git/etc/nginx/sites-enabled/git.conf33
-rwxr-xr-xpackages/crashbox-config/git/usr/bin/gh-mirror59
-rwxr-xr-xpackages/crashbox-config/git/usr/bin/gh-mirror-all7
-rw-r--r--packages/crashbox-config/git/var/lib/git/www/about.md5
-rw-r--r--packages/crashbox-config/git/var/lib/git/www/crashbox.pngbin0 -> 666 bytes
-rw-r--r--packages/crashbox-config/git/var/lib/git/www/instagram.pngbin0 -> 44502 bytes
8 files changed, 171 insertions, 0 deletions
diff --git a/packages/crashbox-config/git/etc/cgitrc.d/crashbox b/packages/crashbox-config/git/etc/cgitrc.d/crashbox
new file mode 100644
index 0000000..e95ff11
--- /dev/null
+++ b/packages/crashbox-config/git/etc/cgitrc.d/crashbox
@@ -0,0 +1,63 @@
+#
+# cgit config
+# see cgitrc(5) for details
+#
+# https://git.zx2c4.com/cgit/tree/cgitrc.5.txt
+
+favicon=/crashbox.png
+logo=/crashbox.png
+root-title=git.crashbox.io
+root-desc=Git repositories hosted at crashbox.io
+root-readme=/var/lib/git/www/about.md
+clone-url=https://git.crashbox.io/$CGIT_REPO_URL
+
+## List of common mimetypes
+mimetype.gif=image/gif
+mimetype.html=text/html
+mimetype.jpg=image/jpeg
+mimetype.jpeg=image/jpeg
+mimetype.pdf=application/pdf
+mimetype.png=image/png
+mimetype.svg=image/svg+xml
+mimetype-file=/etc/mime.types
+
+# Don't show owner on index page
+enable-index-owner=0
+
+# Enable blame page and create links to it from tree page
+enable-blame=1
+
+# Enable ASCII art commit history graph on the log pages
+enable-commit-graph=1
+
+# Show extra links for each repository on the index page
+enable-index-links=1
+
+# Show number of affected files per commit on the log pages
+enable-log-filecount=1
+
+# Show number of added/removed lines per commit on the log pages
+enable-log-linecount=1
+
+# Allow download of tar.gz, tar.bz2 and zip-files
+snapshots=tar.gz tar.bz2 zip
+
+# Highlight code
+source-filter=/usr/lib/cgit/filters/syntax-highlighting.py
+
+# Format "about" files such as markdown readmes
+about-filter=/usr/lib/cgit/filters/about-formatting.sh
+readme=master:README.md
+
+# nginx handles negotiating git clones
+enable-http-clone=0
+
+section-from-path=-1
+
+# Remove ".git" suffix in listings
+remove-suffix=1
+
+# Base URL
+virtual-root=/
+
+scan-path=/srv/git
diff --git a/packages/crashbox-config/git/etc/gh-mirror b/packages/crashbox-config/git/etc/gh-mirror
new file mode 100644
index 0000000..4fc987b
--- /dev/null
+++ b/packages/crashbox-config/git/etc/gh-mirror
@@ -0,0 +1,4 @@
+users jodersky /srv/git/mirrors/github/jodersky
+orgs project-condor /srv/git/mirrors/github/project-condor
+orgs driver-oss /srv/git/mirrors/github/driver-oss
+orgs johnandjohn /srv/git/mirrors/github/johnandjohn
diff --git a/packages/crashbox-config/git/etc/nginx/sites-enabled/git.conf b/packages/crashbox-config/git/etc/nginx/sites-enabled/git.conf
new file mode 100644
index 0000000..7210dbc
--- /dev/null
+++ b/packages/crashbox-config/git/etc/nginx/sites-enabled/git.conf
@@ -0,0 +1,33 @@
+server {
+ server_name git.*;
+ listen 80;
+ listen [::]:80;
+ listen 443 ssl;
+ listen [::]:443 ssl;
+
+ root /var/lib/git/www;
+
+ # requests that should to go to git-http-backend
+ location ~ ^.*/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
+ root /srv/git;
+ include fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
+ fastcgi_param GIT_PROJECT_ROOT /srv/git;
+ fastcgi_param GIT_HTTP_EXPORT_ALL "";
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_pass unix:/run/fcgiwrap.socket;
+ }
+
+ location @cgit {
+ include fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
+ fastcgi_param CGIT_CONFIG /etc/cgitrc.d/crashbox;
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_pass unix:/run/fcgiwrap.socket;
+ }
+
+ location / {
+ try_files $uri @cgit;
+ }
+
+}
diff --git a/packages/crashbox-config/git/usr/bin/gh-mirror b/packages/crashbox-config/git/usr/bin/gh-mirror
new file mode 100755
index 0000000..54985cb
--- /dev/null
+++ b/packages/crashbox-config/git/usr/bin/gh-mirror
@@ -0,0 +1,59 @@
+#!/bin/bash
+# Mirror repositories from GitHub
+#
+# Arguments: (users|orgs) <name> <output_directory>
+#
+# Clones (or updates) all repositories of a GitHub user or
+# organization. Repositories are created as children of the given
+# output directory.
+#
+# Example:
+# gh-mirror users jodersky mirrors/github/jodersky
+#
+# This script uses GitHub's API, version 3
+# https://developer.github.com/v3/repos/#list-user-repositories
+set -o errexit
+
+account_type="$1"
+account_name="$2"
+out_dir="${3:-.}"
+mkdir -p "$out_dir"
+
+if [[ -z $account_type ]] || [[ -z $account_name ]]; then
+ echo "Usage: (users|orgs) <name> <output_directory>" >&2
+ exit 1
+fi
+
+tmp="$(mktemp /tmp/mirror-XXXXXXXXXXXX)"
+url="https://api.github.com/$account_type/$account_name/repos?per_page=100"
+
+function finish {
+ echo "An error was encountered." >&2
+ echo "curl headers are saved in $tmp" >&2
+}
+trap finish ERR
+
+while [[ ! -z "$url" ]]; do
+ echo "Fetching $url..." >&2
+
+ mapfile -t repo_data < <(curl --dump-header "$tmp" "$url" | jq --compact-output '.[]')
+ url="$(< "$tmp" grep Link | grep -oE "[a-zA-Z0-9:/?=.&_]*>; rel=.next" | cut -d'>' -f1)"
+
+ for repo in "${repo_data[@]}"; do
+ clone_url="$(echo "$repo" | jq -r .clone_url)"
+ project="$(basename "$clone_url")"
+ description=$(echo "$repo" | jq -r .description)
+
+ git_dir="$out_dir/$project"
+
+ if [ -d "$git_dir" ]; then
+ echo "updating $project" >&2
+ git -C "$git_dir" fetch --prune
+ else
+ echo "mirroring new $project" >&2
+ git clone --mirror "$clone_url" "$git_dir"
+ fi
+ echo "$description" > "$git_dir/description"
+ done
+done
+rm "$tmp"
diff --git a/packages/crashbox-config/git/usr/bin/gh-mirror-all b/packages/crashbox-config/git/usr/bin/gh-mirror-all
new file mode 100755
index 0000000..fa9054f
--- /dev/null
+++ b/packages/crashbox-config/git/usr/bin/gh-mirror-all
@@ -0,0 +1,7 @@
+#!/bin/bash
+mapfile -t lines < /etc/gh-mirror
+
+for line in "${lines[@]}"; do
+ read -r type name dir <<< "$line"
+ gh-mirror "$type" "$name" "$dir"
+done
diff --git a/packages/crashbox-config/git/var/lib/git/www/about.md b/packages/crashbox-config/git/var/lib/git/www/about.md
new file mode 100644
index 0000000..55e68fa
--- /dev/null
+++ b/packages/crashbox-config/git/var/lib/git/www/about.md
@@ -0,0 +1,5 @@
+Tracking of various git repositories.
+
+![instagram](instagram.png)
+
+<https://xkcd.com/1150/>
diff --git a/packages/crashbox-config/git/var/lib/git/www/crashbox.png b/packages/crashbox-config/git/var/lib/git/www/crashbox.png
new file mode 100644
index 0000000..632118e
--- /dev/null
+++ b/packages/crashbox-config/git/var/lib/git/www/crashbox.png
Binary files differ
diff --git a/packages/crashbox-config/git/var/lib/git/www/instagram.png b/packages/crashbox-config/git/var/lib/git/www/instagram.png
new file mode 100644
index 0000000..dcaff14
--- /dev/null
+++ b/packages/crashbox-config/git/var/lib/git/www/instagram.png
Binary files differ