src.nth.io/

summaryrefslogtreecommitdiff
path: root/mercurial
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2020-06-29 18:38:49 -0500
committerLuke Hoersten <[email protected]>2020-06-29 18:38:49 -0500
commit993697be3753be25f3d05617c53d66c64b0e97b5 (patch)
tree41cb6f26f121f0659be66269110624bd21a3cf63 /mercurial
parentb4c42a383953a34d6ff8091caf6e6bd34776b0c6 (diff)
Added mercurial web hosting
Diffstat (limited to 'mercurial')
-rw-r--r--mercurial/aws-s3-backup/files/mercurial-s3-backup.sh (renamed from mercurial/files/mercurial-s3-backup.sh)0
-rw-r--r--mercurial/aws-s3-backup/handlers/main.yaml (renamed from mercurial/handlers/main.yaml)0
-rw-r--r--mercurial/aws-s3-backup/tasks/main.yaml (renamed from mercurial/tasks/main.yaml)4
-rw-r--r--mercurial/aws-s3-backup/templates/[email protected] (renamed from mercurial/templates/[email protected])0
-rw-r--r--mercurial/web/handlers/main.yaml5
-rw-r--r--mercurial/web/tasks/main.yaml38
-rw-r--r--mercurial/web/templates/hgweb.config.j26
-rw-r--r--mercurial/web/templates/hgweb.ini.j28
-rw-r--r--mercurial/web/templates/hgweb.nginx.conf.j233
-rw-r--r--mercurial/web/templates/hgweb.wsgi.j218
10 files changed, 108 insertions, 4 deletions
diff --git a/mercurial/files/mercurial-s3-backup.sh b/mercurial/aws-s3-backup/files/mercurial-s3-backup.sh
index b5ba305..b5ba305 100644
--- a/mercurial/files/mercurial-s3-backup.sh
+++ b/mercurial/aws-s3-backup/files/mercurial-s3-backup.sh
diff --git a/mercurial/handlers/main.yaml b/mercurial/aws-s3-backup/handlers/main.yaml
index 8c3315b..8c3315b 100644
--- a/mercurial/handlers/main.yaml
+++ b/mercurial/aws-s3-backup/handlers/main.yaml
diff --git a/mercurial/tasks/main.yaml b/mercurial/aws-s3-backup/tasks/main.yaml
index e766752..45a3457 100644
--- a/mercurial/tasks/main.yaml
+++ b/mercurial/aws-s3-backup/tasks/main.yaml
@@ -1,9 +1,5 @@
---
-- name: install mercurial
- become: yes
- apt: name="mercurial"
-
- name: create mercurial s3 backup shell script
become: yes
copy:
diff --git a/mercurial/templates/[email protected] b/mercurial/aws-s3-backup/templates/[email protected]
index ba6ca80..ba6ca80 100644
--- a/mercurial/templates/[email protected]
+++ b/mercurial/aws-s3-backup/templates/[email protected]
diff --git a/mercurial/web/handlers/main.yaml b/mercurial/web/handlers/main.yaml
new file mode 100644
index 0000000..9efe84d
--- /dev/null
+++ b/mercurial/web/handlers/main.yaml
@@ -0,0 +1,5 @@
+---
+
+- name: restart uwsgi
+ systemd: name="uwsgi.service" enabled="yes" daemon_reload="yes" state="restarted"
+ become: yes
diff --git a/mercurial/web/tasks/main.yaml b/mercurial/web/tasks/main.yaml
new file mode 100644
index 0000000..088a8fb
--- /dev/null
+++ b/mercurial/web/tasks/main.yaml
@@ -0,0 +1,38 @@
+---
+
+- name: pip install mercurial
+ become: yes
+ pip: name="mercurial" executable="pip3"
+
+- name: apt install uwsgi
+ become: yes
+ apt: name="{{item}}"
+ loop:
+ - "uwsgi"
+ - "uwsgi-plugin-python3"
+ notify: restart uwsgi
+
+- name: configure hgweb
+ become: yes
+ template: src="{{item}}.j2" dest="{{mercurial_uwsgi_root}}/{{item}}"
+ loop:
+ - "hgweb.config"
+ - "hgweb.wsgi"
+ notify: restart uwsgi
+
+- name: install uwsgi site
+ become: yes
+ template: src="hgweb.ini.j2" dest="/etc/uwsgi/apps-available/hgweb.ini"
+ notify: restart uwsgi
+
+- name: enable uwsgi site
+ become: yes
+ file:
+ src: "/etc/uwsgi/apps-available/hgweb.ini"
+ dest: "/etc/uwsgi/apps-enabled/hgweb.ini"
+ state: "link"
+ notify: restart uwsgi
+
+- name: ensure uwsgi service is started
+ become: yes
+ systemd: name="uwsgi.service" enabled="yes"
diff --git a/mercurial/web/templates/hgweb.config.j2 b/mercurial/web/templates/hgweb.config.j2
new file mode 100644
index 0000000..881f8e4
--- /dev/null
+++ b/mercurial/web/templates/hgweb.config.j2
@@ -0,0 +1,6 @@
+[paths]
+/ = {{mercurial_uwsgi_repos}}
+
+[web]
+deny_push = *
+allow_archive = gz bz2 zip
diff --git a/mercurial/web/templates/hgweb.ini.j2 b/mercurial/web/templates/hgweb.ini.j2
new file mode 100644
index 0000000..f65d440
--- /dev/null
+++ b/mercurial/web/templates/hgweb.ini.j2
@@ -0,0 +1,8 @@
+[uwsgi]
+processes = 2
+socket = unix:/run/uwsgi/app/hgweb/socket
+chdir = {{mercurial_uwsgi_root}}
+wsgi-file = hgweb.wsgi
+uid = www-data
+gid = www-data
+plugins = python3
diff --git a/mercurial/web/templates/hgweb.nginx.conf.j2 b/mercurial/web/templates/hgweb.nginx.conf.j2
new file mode 100644
index 0000000..fbe6d21
--- /dev/null
+++ b/mercurial/web/templates/hgweb.nginx.conf.j2
@@ -0,0 +1,33 @@
+server {
+ listen 80;
+ listen [::]:80;
+ server_name {{nginx_server_name}};
+ return 301 https://$host$request_uri;
+}
+
+server {
+ listen 443 ssl http2;
+# listen [::]:443 ssl ipv6only=on;
+ server_name {{nginx_server_name}};
+
+ ssl_certificate {{nginx_ssl_cert}};
+ ssl_certificate_key {{nginx_ssl_privkey}};
+ include /etc/letsencrypt/options-ssl-nginx.conf;
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
+
+ ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
+ ssl_stapling on;
+ ssl_stapling_verify on;
+
+ location / {
+ include uwsgi_params;
+ uwsgi_param REMOTE_PORT $remote_port;
+ uwsgi_param SERVER_PORT $server_port;
+ uwsgi_param SERVER_PROTOCOL $server_protocol;
+ uwsgi_param UWSGI_SCHEME $scheme;
+ uwsgi_param SCRIPT_NAME /;
+ uwsgi_param AUTH_USER $remote_user;
+ uwsgi_param REMOTE_USER $remote_user;
+ uwsgi_pass unix:/run/uwsgi/app/hgweb/socket;
+ }
+}
diff --git a/mercurial/web/templates/hgweb.wsgi.j2 b/mercurial/web/templates/hgweb.wsgi.j2
new file mode 100644
index 0000000..16cc9fa
--- /dev/null
+++ b/mercurial/web/templates/hgweb.wsgi.j2
@@ -0,0 +1,18 @@
+# An example WSGI for use with mod_wsgi, edit as necessary
+# See https://mercurial-scm.org/wiki/modwsgi for more information
+
+# Path to repo or hgweb config to serve (see 'hg help hgweb')
+config = "{{mercurial_uwsgi_root}}/hgweb.config"
+
+# Uncomment and adjust if Mercurial is not installed system-wide
+# (consult "installed modules" path from 'hg debuginstall'):
+#import sys; sys.path.insert(0, "/path/to/python/lib")
+
+# Uncomment to send python tracebacks to the browser if an error occurs:
+import cgitb; cgitb.enable()
+
+# enable demandloading to reduce startup time
+from mercurial import demandimport; demandimport.enable()
+
+from mercurial.hgweb import hgweb
+application = hgweb(config.encode())