aboutsummaryrefslogtreecommitdiffstats
path: root/roles/cgit
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-12-25 22:14:46 +0100
committerbinary <me@rgoncalves.se>2020-12-25 22:14:46 +0100
commit035cd8f8dc2a1d7a6717849a7d01d2aba5b16f3c (patch)
treec81ac90a72e59f9584319ce703c553d40b010f41 /roles/cgit
parentdb2c815292401e7beaac16fcdc48c342aa59a6f9 (diff)
downloadinfrastructure-035cd8f8dc2a1d7a6717849a7d01d2aba5b16f3c.tar.gz
Add experimental role for cgit. Not prod ready
Diffstat (limited to 'roles/cgit')
-rw-r--r--roles/cgit/files/generate-static-git.sh28
-rw-r--r--roles/cgit/files/httpd.conf20
-rw-r--r--roles/cgit/files/style.css155
-rw-r--r--roles/cgit/tasks/main.yml26
-rw-r--r--roles/cgit/vars/main.yml9
5 files changed, 238 insertions, 0 deletions
diff --git a/roles/cgit/files/generate-static-git.sh b/roles/cgit/files/generate-static-git.sh
new file mode 100644
index 0000000..dd0db32
--- /dev/null
+++ b/roles/cgit/files/generate-static-git.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+GIT_DIR="/data/git"
+
+repositories=""
+repo=""
+
+for repo in "${GIT_DIR}"/*; do
+
+ if [ ! -f "${repo}/git-daemon-export-ok" ]; then
+ echo " [ERR] $(basename ${repo})"
+ continue
+ fi
+
+ repo=$(basename "${repo}")
+ repositories="${repositories} ${GIT_DIR}/${repo}"
+
+ echo " [OK ] ${repo}"
+ mkdir "${repo}" 2>/dev/null
+ (cd "${repo}" && /usr/local/bin/stagit "${GIT_DIR}/${repo}")
+done
+
+if [ -z "$repositories" ]; then
+ exit 1
+fi
+
+echo " [#] ${repositories}"
+/usr/local/bin/stagit-index ${repositories} > index.html
diff --git a/roles/cgit/files/httpd.conf b/roles/cgit/files/httpd.conf
new file mode 100644
index 0000000..238acf0
--- /dev/null
+++ b/roles/cgit/files/httpd.conf
@@ -0,0 +1,20 @@
+
+# httpd ~~ /etc/httpd.conf
+# managed by Ansible
+
+server "default" {
+ listen on * port 1234
+ root "/htdocs/stagit"
+
+ location match "style.css" {
+ request rewrite "/style.css"
+ }
+
+ location match "logo.png" {
+ request rewrite "/logo.png"
+ }
+
+ location match "favicon.png" {
+ request rewrite "/logo.png"
+ }
+}
diff --git a/roles/cgit/files/style.css b/roles/cgit/files/style.css
new file mode 100644
index 0000000..8e24ae9
--- /dev/null
+++ b/roles/cgit/files/style.css
@@ -0,0 +1,155 @@
+body {
+ font-family: monospace;
+ color: #000;
+ background-color: #fff;
+}
+img {
+ border: 0;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ font-size: 1em;
+ margin: 0;
+}
+
+img, h1, h2 {
+ vertical-align: middle;
+}
+
+a:target {
+ background-color: #ccc;
+}
+
+a.d,
+a.h,
+a.i,
+a.line {
+ text-decoration: none;
+}
+
+#blob a {
+ color: #555;
+ border-right: 3px solid #aaa;
+ padding: 0 5px 0 0;
+}
+
+#blob a:hover {
+ color: blue;
+ text-decoration: none;
+}
+
+table thead td {
+ font-weight: bold;
+}
+
+table td {
+ padding: 0 0.4em;
+}
+
+#content table td {
+ white-space: nowrap;
+ vertical-align: top;
+}
+
+#branches tr:hover td,
+#tags tr:hover td,
+#index tr:hover td,
+#log tr:hover td,
+#files tr:hover td {
+ background-color: #eee;
+}
+
+#index tr td:nth-child(2),
+#tags tr td:nth-child(3),
+#branches tr td:nth-child(3),
+#log tr td:nth-child(2) {
+ white-space: normal;
+}
+
+td.num {
+ text-align: right;
+}
+
+.desc {
+ color: #555;
+}
+
+hr {
+ border: 0;
+ border-top: 3px solid #aaa;
+ height: 3px;
+}
+
+#content hr {
+ display: none;
+}
+
+pre {
+ font-family: monospace;
+}
+
+pre a.h {
+ color: #00a;
+}
+
+.A,
+span.i,
+pre a.i {
+ color: #070;
+}
+
+.D,
+span.d,
+pre a.d {
+ color: #e00;
+}
+
+pre a.h:hover,
+pre a.i:hover,
+pre a.d:hover {
+ text-decoration: none;
+}
+/*
+@media (prefers-color-scheme: dark) {
+ body {
+ background-color: #000;
+ color: #eee;
+ }
+ hr {
+ border-color: #222;
+ }
+ a {
+ color: #00abff;
+ }
+ a:target {
+ background-color: #222;
+ }
+ #blob a {
+ color: #555;
+ border-color: #222;
+ }
+ #blob a:hover {
+ color: #00abff;
+ }
+ pre a.h {
+ color: #00abff;
+ }
+ .A,
+ span.i,
+ pre a.i {
+ color: #0e0;
+ }
+ .D,
+ span.d,
+ pre a.d {
+ color: #e00;
+ }
+ #branches tr:hover td,
+ #tags tr:hover td,
+ #index tr:hover td,
+ #log tr:hover td,
+ #files tr:hover td {
+ background-color: #111;
+ }
+}
+*/
diff --git a/roles/cgit/tasks/main.yml b/roles/cgit/tasks/main.yml
new file mode 100644
index 0000000..c5b2420
--- /dev/null
+++ b/roles/cgit/tasks/main.yml
@@ -0,0 +1,26 @@
+
+# cgit ~~ roles/cgit/tasks/main.yml
+# cgit web interface
+
+---
+
+- name: ensure cgit is installed
+ package:
+ name: cgit
+ state: present
+
+- name: ensure httpd.d directory exists
+ file: path=/etc/httpd.d state=directory
+
+- name: copy httpd configuration
+ copy:
+ src: httpd.conf
+ dest: /etc/httpd.d/stagit.conf
+ owner: "{{ user_root }}"
+ group: "{{ group_root }}"
+ mode: 0644
+
+- name: execute static-page generation script once
+ shell: ./generate-static-git.sh
+ args:
+ chdir: "{{ stagit_htmldir }}"
diff --git a/roles/cgit/vars/main.yml b/roles/cgit/vars/main.yml
new file mode 100644
index 0000000..70ab89a
--- /dev/null
+++ b/roles/cgit/vars/main.yml
@@ -0,0 +1,9 @@
+
+# cgit ~~ roles/cgit/tasks/vars.yml
+# default vars for cgit role
+
+---
+
+cgit_user: "git"
+cgit_group: "git"
+cgit_dir: "/data/git/"
remember that computers suck.