aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/stagit/files/generate-static-git.sh28
-rw-r--r--roles/stagit/files/httpd.conf20
-rw-r--r--roles/stagit/files/style.css155
-rw-r--r--roles/stagit/tasks/main.yml60
4 files changed, 252 insertions, 11 deletions
diff --git a/roles/stagit/files/generate-static-git.sh b/roles/stagit/files/generate-static-git.sh
new file mode 100644
index 0000000..53ec2dd
--- /dev/null
+++ b/roles/stagit/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 " [#] private repository at : ${repo}"
+ continue
+ fi
+
+ repo=$(basename "${repo}")
+ repositories="${repositories} ${GIT_DIR}/${repo}"
+
+ echo " [#] generating ${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/stagit/files/httpd.conf b/roles/stagit/files/httpd.conf
new file mode 100644
index 0000000..ebf1c88
--- /dev/null
+++ b/roles/stagit/files/httpd.conf
@@ -0,0 +1,20 @@
+
+# httpd ~~ /etc/httpd.conf
+# managed by Ansible
+
+server "default" {
+ listen on * port 80
+ root "/htdocs/stagit"
+
+ location match "style.css" {
+ request rewrite "/style.css"
+ }
+
+ location match "logo.png" {
+ request rewrite "/logo.gif"
+ }
+
+ location match "favicon.png" {
+ request rewrite "/logo.gif"
+ }
+}
diff --git a/roles/stagit/files/style.css b/roles/stagit/files/style.css
new file mode 100644
index 0000000..8e24ae9
--- /dev/null
+++ b/roles/stagit/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/stagit/tasks/main.yml b/roles/stagit/tasks/main.yml
index f4d999d..1e7b67f 100644
--- a/roles/stagit/tasks/main.yml
+++ b/roles/stagit/tasks/main.yml
@@ -9,21 +9,59 @@
name: stagit
state: present
-- name: retrieve all public git repository
- find:
- paths: /data/git
- patterns: enable_public
- recurse: true
- register: public_dirs
-
-- name: show public directories
- debug:
- var: public_dirs
-
- name: create stagit static-files directory
file:
path: /var/www/htdocs/stagit
state: directory
owner: www
group: daemon
+ mode: 0755
+
+- name: copy static-page generation script
+ copy:
+ src: generate-static-git.sh
+ dest: /var/www/htdocs/stagit
+ owner: www
+ group: "{{ group_root }}"
+ mode: 0744
+
+- name: copy stagit stylesheet
+ copy:
+ src: style.css
+ dest: /var/www/htdocs/stagit
+ owner: www
+ group: "{{ group_root }}"
+ mode: 0644
+
+- name: copy httpd configuration
+ copy:
+ src: httpd.conf
+ dest: /etc/httpd.conf
+ owner: "{{ user_root }}"
+ group: "{{ group_root }}"
+ mode: 0644
+
+- name: download default website logo
+ get_url:
+ url: https://www.openbsd.org/art/puffy/puf100X86.gif
+ dest: /var/www/htdocs/stagit/logo.gif
+ owner: www
+ group: "{{ group_root }}"
mode: 0644
+
+- name: ensure httpd is enabled and restarted
+ service:
+ name: httpd
+ state: restarted
+ enabled: true
+
+- name: enable cron job for static-page generation
+ cron:
+ name: "Static git-page generation"
+ minute: "5"
+ job: "cd /var/www/htdocs/stagit && ./generate-static-git.sh"
+
+- name: execute static-page generation script once
+ shell: ./generate-static-git.sh
+ args:
+ chdir: /var/www/htdocs/stagit
remember that computers suck.