diff --git a/gitea/cpapache.sls b/gitea/cpapache.sls index 1804805..210b5b6 100644 --- a/gitea/cpapache.sls +++ b/gitea/cpapache.sls @@ -1,7 +1,35 @@ -{# -vim /etc/apache2/conf.d/userdata/std/2/keiran5/git.keiran.us/git.keiran.us.conf -/scripts/verify_vhost_includes --commit /scripts/ensure_vhost_includes --all-users -/scripts/rebuildhttpdconf -/usr/local/cpanel/scripts/restartsrv_httpd --graceful -go to http://git.keiran.us/install -#} + +{{ salt.pillar.get('gitea:cpapache_include') }}: + file.managed: + - source: 'salt://gitea/files/vhost_include.jinja' + - template: jinja + - user: root + - group: root + - mode: 644 + +verify_vhost_includes: + cmd.wait: + - name: /usr/local/cpanel/scripts/verify_vhost_includes --commit /scripts/ensure_vhost_includes --all-users + - watch: + - file: {{ salt.pillar.get('gitea:cpapache_include') }} + +rebuildhttpdconf: + cmd.wait: + - name: /usr/local/cpanel/scripts/rebuildhttpdconf + - watch: + - cmd: verify_vhost_includes + +queue_httpd_graceful: + cmd.wait: + - name: /usr/local/cpanel/scripts/restartsrv_httpd --graceful + - watch: + - cmd: rebuildhttpdconf + +/home/{{ salt.pillar.get('gitea:user') }}/public_html/.htaccess: + file.managed: + - source: 'salt://gitea/files/htaccess.jinja' + - template: jinja + - user: {{ salt.pillar.get('gitea:user') }} + - group: {{ salt.pillar.get('gitea:user') }} + - mode: 644 + diff --git a/gitea/files/htaccess.jinja b/gitea/files/htaccess.jinja new file mode 100644 index 0000000..ec3c870 --- /dev/null +++ b/gitea/files/htaccess.jinja @@ -0,0 +1,3 @@ +RewriteEngine On +RewriteCond %{SERVER_PORT} 80 +RewriteRule ^(.*)$ https://{{ pillar['gitea']['domain'] }}/$1 [R,L] diff --git a/gitea/files/vhost_include.jinja b/gitea/files/vhost_include.jinja new file mode 100644 index 0000000..3a5303f --- /dev/null +++ b/gitea/files/vhost_include.jinja @@ -0,0 +1,6 @@ +SecRuleEngine Off +ProxyRequests Off +ProxyFCGISetEnvIf "true" PATH_INFO "%{reqenv:SCRIPT_NAME}" +ProxyFCGISetEnvIf "true" !SCRIPT_NAME +ProxyPass /.well-known ! +ProxyPass / "http://localhost:3000/" enablereuse=on diff --git a/gitea/init.sls b/gitea/init.sls index 6be2136..59a1cd8 100644 --- a/gitea/init.sls +++ b/gitea/init.sls @@ -3,3 +3,11 @@ include: - gitea.install - gitea.systemd - gitea.cpapache + +{# += Manual steps needed afterwards = +1. set INSTALL_LOCK to false in /home/USER/gitea/etc/app.ini +2. go to http://git.keiran.us/install, setup DBs +3. run salt again +#} +