mirror/base: Convert everything to run on Apache

This commit is contained in:
Timo Makinen 2021-02-24 04:49:08 +00:00
parent 80fe81cf83
commit 9afdda987e
6 changed files with 108 additions and 409 deletions

View file

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:str="http://exslt.org/strings">
<xsl:strip-space elements="*" />
<xsl:template name="size">
<!-- transform a size in bytes into a human readable representation -->
<xsl:param name="bytes"/>
<xsl:choose>
<xsl:when test="$bytes &lt; 1000"><xsl:value-of select="$bytes" />B</xsl:when>
<xsl:when test="$bytes &lt; 1048576"><xsl:value-of select="format-number($bytes div 1024, '0.0')" />K</xsl:when>
<xsl:when test="$bytes &lt; 1073741824"><xsl:value-of select="format-number($bytes div 1048576, '0.0')" />M</xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(($bytes div 1073741824), '0.00')" />G</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="timestamp">
<!-- transform an ISO 8601 timestamp into a human readable representation -->
<xsl:param name="iso-timestamp" />
<xsl:value-of select="concat(substring($iso-timestamp, 0, 11), ' ', substring($iso-timestamp, 12, 5))" />
</xsl:template>
<xsl:template match="directory">
<tr>
<td><a href="{str:encode-uri(current(),true())}/"><xsl:value-of select="."/></a>/</td>
<td><xsl:call-template name="timestamp"><xsl:with-param name="iso-timestamp" select="@mtime" /></xsl:call-template></td>
<td>-</td>
<td>Directory</td>
</tr>
</xsl:template>
<xsl:template match="file">
<tr>
<td><a href="{str:encode-uri(current(),true())}"><xsl:value-of select="." /></a></td>
<td><xsl:call-template name="timestamp"><xsl:with-param name="iso-timestamp" select="@mtime" /></xsl:call-template></td>
<td><xsl:call-template name="size"><xsl:with-param name="bytes" select="@size" /></xsl:call-template></td>
<td>File</td>
</tr>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<title>mirrors.foo.sh - <xsl:value-of select="$path" /></title>
<link rel="stylesheet" type="text/css" href="/static/mirror.css" />
<link rel="stylesheet" type="text/css" href="/static/icons.css" />
</head>
<body>
<div id="navbar">
<div id="logo">
<a href="https://www.foo.sh/"><img src="/static/logo.png" alt="foo.sh" /></a>
</div>
<div class="mirrorlist">
<button class="mirrorlist-button">Select mirror</button>
<div class="mirrorlist-content">
<a href="/fedora/">Fedora</a><span class="hide"> - </span>
<a href="/fedora-epel/">Fedora EPEL</a><span class="hide"> - </span>
<a href="/openbsd/">OpenBSD</a>
</div>
</div>
</div>
<div id="content">
<h1>Index of <xsl:value-of select="$path" /></h1>
<table>
<tr>
<th>Name</th>
<th>Last Modified</th>
<th>Size</th>
<th>Type</th>
</tr>
<tr>
<td colspan="4"><a href="../">Parent Directory</a></td>
</tr>
<xsl:apply-templates />
</table>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,13 @@
<div id="navbar">
<div id="logo">
<a href="https://www.foo.sh/"><img src="/static/logo.png" alt="foo.sh" /></a>
</div>
<div class="mirrorlist">
<button class="mirrorlist-button">Select mirror</button>
<div class="mirrorlist-content">
<a href="/fedora/">Fedora</a><span class="hide"> - </span>
<a href="/fedora-epel/">Fedora EPEL</a><span class="hide"> - </span>
<a href="/openbsd/">OpenBSD</a>
</div>
</div>
</div>

View file

@ -1,307 +0,0 @@
#content a[href]:before {
content: url(icons/none.png);
}
#content a[href$="/"]:before {
content: url(icons/folder.png);
}
/** Checksums **/
#content a[href~="MD5"]:before,
#content a[href~="SHA1"]:before,
#content a[href~="SHA256"]:before {
content: url(icons/lock.png);
}
#content a[href$=".md5"]:before,
#content a[href$=".sha1"]:before,
#content a[href$=".sha256"]:before {
content: url(icons/lock2.png);
}
#content a[href$=".pgp"]:before,
#content a[href$=".asc"]:before,
#content a[href$=".sig"]:before {
content: url(icons/lock3.png);
}
/** Compressed **/
#content a[href$=".7z"]:before {
content: url(icons/7z.png);
}
#content a[href$=".bin"]:before,
#content a[href$=".cue"]:before {
content: url(icons/bin.png);
}
#content a[href$=".deb"]:before {
content: url(icons/deb.png);
}
#content a[href$=".iso"]:before {
content: url(icons/iso.png);
}
#content a[href$=".rar"]:before {
content: url(icons/rar.png);
}
#content a[href$=".rpm"]:before {
content: url(icons/rpm.png);
}
#content a[href$=".tar"]:before,
#content a[href$=".tar.gz"]:before {
content: url(icons/tar.png);
}
#content a[href$=".tgz"]:before {
content: url(icons/tgz.png);
}
#content a[href$=".zip"]:before {
content: url(icons/zip.png);
}
#content a[href$=".bz2"]:before {
content: url(icons/bz2.png);
}
/** Data Storage **/
#content a[href$=".csv"]:before {
content: url(icons/csv.png);
}
#content a[href$=".ini"]:before {
content: url(icons/ini.png);
}
#content a[href$=".json"]:before {
content: url(icons/json.png);
}
#content a[href$=".sql"]:before {
content: url(icons/sql.png);
}
#content a[href$=".sqlite"]:before {
content: url(icons/sqlite.png);
}
#content a[href$=".reg"]:before {
content: url(icons/reg.png);
}
#content a[href$=".xml"]:before {
content: url(icons/xml.png);
}
#content a[href$=".yaml"]:before,
#content a[href$=".yml"]:before {
content: url(icons/yaml.png);
}
/** Documents **/
#content a[href$=".chm"]:before {
content: url(icons/chm.png);
}
#content a[href$=".djvu"]:before {
content: url(icons/djvu.png);
}
#content a[href$=".mobi"]:before {
content: url(icons/mobi.png);
}
#content a[href$=".pdf"]:before {
content: url(icons/pdf.png);
}
#content a[href$=".txt"]:before {
content: url(icons/text.png);
}
#content a[href$=".rtf"]:before {
content: url(icons/rtf.png);
}
#content a[href$=".doc"]:before {
content: url(icons/doc.png);
}
#content a[href$=".epub"]:before {
content: url(icons/epub.png);
}
/** Information **/
#content a[href~="README"]:before {
content: url(icons/readme.png);
}
#content a[href~="CHANGELOG"]:before {
content: url(icons/changelog.png);
}
#content a[href~="INSTALL"]:before {
content: url(icons/install.png);
}
#content a[href~="LICENSE"]:before {
content: url(icons/license.png);
}
#content a[href~="COPYING"]:before {
content: url(icons/copying.png);
}
#content a[href$=".nfo"]:before,
#content a[href$=".diz"]:before {
content: url(icons/nfo.png);
}
/** Media Files **/
#content a[href$=".flac"]:before {
content: url(icons/flac.png);
}
#content a[href$=".mp3"]:before {
content: url(icons/mp3.png);
}
#content a[href$=".wav"]:before {
content: url(icons/wav.png);
}
#content a[href$=".bmp"]:before {
content: url(icons/bmp.png);
}
#content a[href$=".gif"]:before {
content: url(icons/gif.png);
}
#content a[href$=".jpg"]:before,
#content a[href$=".jpeg"]:before {
content: url(icons/jpg.png);
}
#content a[href$=".png"]:before {
content: url(icons/png.png);
}
#content a[href$=".psd"]:before {
content: url(icons/psd.png);
}
#content a[href$=".ra"]:before,
#content a[href$=".rv"]:before {
content: url(icons/rp.png);
}
#content a[href$=".avi"]:before {
content: url(icons/avi.png);
}
#content a[href$=".flv"]:before {
content: url(icons/flv.png);
}
#content a[href$=".mkv"]:before {
content: url(icons/mkv.png);
}
#content a[href$=".mov"]:before {
content: url(icons/mov.png);
}
#content a[href$=".mp4"]:before {
content: url(icons/mp4.png);
}
/** Source Code **/
#content a[href$=".sh"]:before {
content: url(icons/bash.png);
}
#content a[href$=".cpp"]:before {
content: url(icons/cpp.png);
}
#content a[href$=".h"]:before {
content: url(icons/header.png);
}
#content a[href$=".c"]:before {
content: url(icons/c-lang.png);
}
#content a[href$=".go"]:before {
content: url(icons/go-lang.png);
}
#content a[href$=".html"]:before,
#content a[href$=".htm"]:before {
content: url(icons/html.png);
}
#content a[href$=".java"]:before,
#content a[href$=".class"]:before {
content: url(icons/java.png);
}
#content a[href$=".lua"]:before {
content: url(icons/lua.png);
}
#content a[href$=".nim"]:before {
content: url(icons/nim.png);
}
#content a[href$=".js"]:before {
content: url(icons/javascript.png);
}
#content a[href$=".php"]:before {
content: url(icons/php.png);
}
#content a[href$=".pl"]:before {
content: url(icons/perl.png);
}
#content a[href$=".py"]:before {
content: url(icons/python.png);
}
#content a[href$=".rb"]:before {
content: url(icons/ruby.png);
}
#content a[href$=".rs"]:before,
#content a[href$=".rlib"]:before {
content: url(icons/rust.png);
}
#content a[href$=".css"]:before {
content: url(icons/css.png);
}
#content a[href$=".less"]:before {
content: url(icons/less.png);
}

View file

@ -1,4 +1,4 @@
--- ---
dependencies: dependencies:
- {role: nginx/server} - {role: apache}

View file

@ -99,20 +99,11 @@
recursive: true recursive: true
src: static src: static
- name: install nginx xslt config - name: create apache mirror config
copy:
dest: /etc/nginx/mirror.xslt
src: mirror.xslt
mode: 0644
owner: root
group: root
notify: restart nginx
- name: create nginx mirror config
template: template:
dest: "/etc/nginx/conf.d/{{ inventory_hostname }}/mirror.conf"
src: mirror.conf.j2 src: mirror.conf.j2
dest: /etc/httpd/conf.local.d/mirror.conf
mode: 0644 mode: 0644
owner: root owner: root
group: root group: "{{ ansible_wheel }}"
notify: restart nginx notify: restart apache

View file

@ -1,6 +1,91 @@
<Directory "/srv/web/{{ inventory_hostname }}/*">
Options +Indexes
location / { IndexOptions FancyIndexing HTMLTable VersionSort XHTML
autoindex on; IndexStyleSheet /static/mirror.css
autoindex_format xml; HeaderName /static/head.html
xslt_stylesheet /etc/nginx/mirror.xslt path="$uri"; ReadmeName /static/foot.html
}
DefaultIcon /static/icons/none.png
AddIcon /static/icons/folder.png ^^DIRECTORY^^
# Checksums
AddIcon /static/icons/lock.png MD5 SHA1 SHA256
AddIcon /static/icons/lock2.png .md5 .sha1 .sha256
AddIcon /static/icons/lock3.png .pgp .asc .sig
# Compressed
AddIcon /static/icons/7z.png .7z
AddIcon /static/icons/bin.png .bin .cue
AddIcon /static/icons/deb.png .deb
AddIcon /static/icons/iso.png .iso
AddIcon /static/icons/rar.png .rar
AddIcon /static/icons/rpm.png .rpm
AddIcon /static/icons/tar.png .tar .tar.gz
AddIcon /static/icons/tgz.png .tgz
AddIcon /static/icons/zip.png .zip
AddIcon /static/icons/bz2.png .bz2
# Data storage
AddIcon /static/icons/csv.png .csv
AddIcon /static/icons/ini.png .ini
AddIcon /static/icons/json.png .json
AddIcon /static/icons/sql.png .sql
AddIcon /static/icons/sqlite.png .sqlite
AddIcon /static/icons/reg.png .reg
AddIcon /static/icons/xml.png .xml
AddIcon /static/icons/yaml.png .yaml .yml
# Documents
AddIcon /static/icons/chm.png .chm
AddIcon /static/icons/djvu.png .djvu
AddIcon /static/icons/mobi.png .mobi
AddIcon /static/icons/pdf.png .pdf
AddIcon /static/icons/text.png .txt
AddIcon /static/icons/rtf.png .rtf
AddIcon /static/icons/doc.png .doc
AddIcon /static/icons/epub.png .epub
# Information
AddIcon /static/icons/readme.png README
AddIcon /static/icons/changelog.png CHANGELOG
AddIcon /static/icons/install.png INSTALL
AddIcon /static/icons/license.png LICENSE
AddIcon /static/icons/copying.png COPYING
AddIcon /static/icons/info.png .nfo .diz
# Media files
AddIcon /static/icons/flac.png .flac
AddIcon /static/icons/mp3.png .mp3
AddIcon /static/icons/wav.png .wav
AddIcon /static/icons/bmp.png .bmp
AddIcon /static/icons/gif.png .gif
AddIcon /static/icons/jpg.png .jpg .jpeg
AddIcon /static/icons/png.png .png
AddIcon /static/icons/psd.png .psd
AddIcon /static/icons/rp.png .ra .rv
AddIcon /static/icons/avi.png .avi
AddIcon /static/icons/flv.png .flv
AddIcon /static/icons/mkv.png .mkv
AddIcon /static/icons/mov.png .mov
AddIcon /static/icons/mp4.png .mp4
# Source code
AddIcon /static/icons/bash.png .sh .bash
AddIcon /static/icons/cpp.png .cpp
AddIcon /static/icons/header.png .h
AddIcon /static/icons/c-lang.png .c
AddIcon /static/icons/go-lang.png .go
AddIcon /static/icons/html.png .html .htm
AddIcon /static/icons/java.png .java .class
AddIcon /static/icons/lua.png .lua
AddIcon /static/icons/nim.png .nim
AddIcon /static/icons/javascript.png .js
AddIcon /static/icons/php.png .php
AddIcon /static/icons/perl.png .pl
AddIcon /static/icons/python.png .py .pyc
AddIcon /static/icons/ruby.png .rb
AddIcon /static/icons/rust.png .rs .rlib
AddIcon /static/icons/css.png .css
AddIcon /static/icons/less.png .less
</Directory>