<repo_name>Zverik/ansible-tile<file_sep>/roles/get_veloroad/files/expandjson.py
#!/usr/bin/python
import sys, os, cgi, json
import psycopg2
import cgitb


def query_geometry(osm_type, osm_id, coord, by_coord=False):
    if (not by_coord or not coord) and osm_id and (osm_type == 'way' or osm_type == 'relation'):
        # query db for an enclosing object for way/rel
        cur.execute('SELECT ST_AsGeoJSON(ST_Transform(way, 4326)) FROM planet_osm_polygon WHERE osm_id = %s', (osm_id if osm_type == 'way' else '-{}'.format(osm_id),))
        result = cur.fetchone()
        return json.loads(result[0]) if result else None
    elif len(coord) >= 2:
        # query by smallest building enclosing coord
        cur.execute('SELECT ST_AsGeoJSON(ST_Transform(way, 4326)), ST_Area(way) as area FROM planet_osm_polygon WHERE ST_Transform(ST_SetSRID(ST_Point(%s, %s), 4326), 900913) && way ORDER BY area', (coord[0], coord[1]))
        result = cur.fetchone()
        return json.loads(result[0]) if result else None


cgitb.enable()

conn = psycopg2.connect('dbname=gis user=osm')
cur = conn.cursor()

form = cgi.FieldStorage()
if 'jsont' in form and len(form.getfirst('jsont')):
    data = json.loads(form.getfirst('jsont'))
elif 'json' in form and form['json'].file:
    data = json.load(form['json'].file)
else:
    sys.exit(1)

by_coord = form.getfirst('bycoord') == '1'

if 'type' in data and data['type'] == 'FeatureCollection':
    for f in data['features']:
        osm_type = None
        osm_id = None
        coord = None
        if 'osm_type' in f['properties'] and 'osm_id' in f['properties']:
            osm_type = f['properties']['osm_type']
            osm_id = f['properties']['osm_id']
        if f['geometry']['type'] == 'Point':
            coord = f['geometry']['coordinates']
        geom = query_geometry(osm_type, osm_id, coord, by_coord)
        if geom:
            f['geometry'] = geom

cur.close()
conn.close()

print 'Content-Type: application/json\n'
print json.dumps(data)
<file_sep>/roles/schedules/files/oddmsk20.ini
title = Open Data Day Moscow 2020
slug = oddmsk20
url = https://opendataday.ru/msk
timezone = +03
<file_sep>/roles/stats/files/du_layer
#!/bin/sh
#
# Plugin to monitor the rendering throughput of Renderd
#
# Parameters: 
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#

if [ "$1" = "config" ]; then

	echo 'graph_title Tile disk usage by layer'
	echo 'graph_args --base 1024'
	echo 'graph_vlabel Tile layer disk usage'
	echo 'graph_category renderd'
	echo 'v.label veloroad'
	echo 'v.info Veloroad'
	echo 'r.label veloroad hr'
	echo 'r.info Veloroad HiDPI'

	exit 0
fi

du --max-depth 1 /var/lib/mod_tile > /tmp/du-layers.txt
veloroad=`grep \/veloroad /tmp/du-layers.txt | cut -f1`
veloroadhr=`grep \/veloroadhr /tmp/du-layers.txt | cut -f1`
rm /tmp/du-layers.txt

echo "v.value $veloroad"
echo "r.value $veloroadhr"
<file_sep>/roles/schedules/files/sotmus2019.ini
title = State of the Map US 2019
slug = sotmus2019
url = https://2019.stateofthemap.us/
timezone = -05
<file_sep>/roles/get_veloroad/files/findbuildings.py
#!/usr/bin/python
# Script for converting coordinates to enclosing buildings, for visgeocode.html
import sys, os, cgi, json
import psycopg2

conn = psycopg2.connect('dbname=gis user=osm')
cur = conn.cursor()

form = cgi.FieldStorage()
if 'json' in form and len(form.getfirst('json')):
    data = json.loads(form.getfirst('json'))
else:
    data = []

ids = set()
if data and len(data) > 0:
    for f in data:
        if 'lat' in f and 'lon' in f:
            cur.execute('SELECT osm_id, ST_AsGeoJSON(ST_Transform(way, 4326)), ST_Area(way) as area FROM planet_osm_polygon WHERE building is not null AND ST_Contains(way, ST_Transform(ST_SetSRID(ST_Point(%s, %s), 4326), 900913)) ORDER BY area LIMIT 1', (f['lon'], f['lat']))
            result = cur.fetchone()
            if result and not result[0] in ids:
                ids.add(result[0])
                f['geometry'] = json.loads(result[1])

cur.close()
conn.close()

print 'Content-Type: application/json'
print 'Access-Control-Allow-Origin: *'
print
print json.dumps(data)
<file_sep>/roles/queryat/files/queryat_config.py
PYTHON = 'python3.5'
<file_sep>/roles/schedules/files/sotm2020.ini
title = State of the Map 2020
slug = sotm2020
url = https://2020.stateofthemap.org/
timezone = +00
<file_sep>/roles/mark_spam_bot/templates/backup_mark_spam.j2
#!/bin/bash
set -u -e
BORG=/usr/local/bin/borg
export BORG_REPO={{ borg_repo }}
export BORG_PASSPHRASE='{{ borg_pass }}'
export BORG_REMOTE_PATH=borg1
export BORG_RSH='ssh -i /root/.ssh/borg -oBatchMode=yes'

systemctl stop mark_spam_bot

$BORG create --compression zstd,5 ::'MarkSpam_{now:%Y-%m-%d_%H%M}' \
  /opt/src/mark_spam_bot/markspam.sqlite

$BORG prune --prefix 'MarkSpam_' --keep-daily=3 --keep-weekly=1 --keep-monthly=1

systemctl start mark_spam_bot
<file_sep>/roles/get_veloroad/files/trim_osc.py
#!/usr/bin/python
# Trim osmChange file to a bounding polygon and database contents
# Written by <NAME>, licensed WTFPL

import sys, os, argparse, getpass, gzip
import psycopg2
from lxml import etree
from shapely.geometry import Polygon, Point

def poly_parse(fp):
	result = None
	poly = []
	data = False
	for l in fp:
		l = l.strip()
		if l == 'END' and data:
			if len(poly) > 0:
				if hole and result:
					result = result.difference(Polygon(poly))
				elif not hole and result:
					result = result.union(Polygon(poly))
				elif not hole:
					result = Polygon(poly)
			poly = []
			data = False
		elif l == 'END' and not data:
			break
		elif len(l) > 0 and ' ' not in l and '\t' not in l:
			data = True
			hole = l[0] == '!'
		elif l and data:
			poly.append(map(lambda x: float(x.strip()), l.split()[:2]))
	return result

def box(x1,y1,x2,y2):
	return Polygon([(x1,y1), (x2,y1), (x2,y2), (x1,y2)])

default_user = getpass.getuser()

parser = argparse.ArgumentParser(description='Trim osmChange file to a polygon and a database data')
parser.add_argument('osc', type=argparse.FileType('r'), help='input osc file, "-" for stdin')
parser.add_argument('output', help='output osc file, "-" for stdout')
parser.add_argument('-d', dest='dbname', help='database name')
parser.add_argument('--host', help='database host')
parser.add_argument('--port', type=int, help='database port')
parser.add_argument('--user', help='user name for db (default: {0})'.format(default_user), default=default_user)
parser.add_argument('--password', action='store_true', help='ask for password', default=False)
parser.add_argument('-p', '--poly', type=argparse.FileType('r'), help='osmosis polygon file')
parser.add_argument('-b', '--bbox', nargs=4, type=float, metavar=('Xmin', 'Ymin', 'Xmax', 'Ymax'), help='Bounding box')
parser.add_argument('-z', '--gzip', action='store_true', help='source and output files are gzipped')
parser.add_argument('-v', dest='verbose', action='store_true', help='display debug information')
options = parser.parse_args()

# read poly
poly = None
if options.bbox:
	b = options.bbox
	poly = box(b[0], b[1], b[2], b[3])
if options.poly:
	tpoly = poly_parse(options.poly)
	poly = tpoly if not poly else poly.intersection(tpoly)

if poly == None or not options.dbname:
	parser.print_help()
	sys.exit()

# connect to database
passwd = ""
if options.password:
	passwd = getpass.getpass("Please enter your password: ")

try:
	db = psycopg2.connect(database=options.dbname, user=options.user, password=passwd, host=options.host, port=options.port)
except Exception, e:
	print "Error connecting to database: ", e
	sys.exit(1)
cur = db.cursor()

# read the entire osc into memory
tree = etree.parse(options.osc if not options.gzip else gzip.GzipFile(fileobj=options.osc))
options.osc.close()
root = tree.getroot()

# NODES

nodes = {} # True for nodes inside poly or referenced by good ways
nodesM = [] # List of modified nodes outside poly (temporary)
for node in root.iter('node'):
	if node.getparent().tag not in ['modify', 'create']:
		continue
	if 'lat' in node.keys() and 'lon' in node.keys():
		inside = poly.intersects(Point(float(node.get('lon')), float(node.get('lat'))))
		nodes[node.get('id')] = inside
		if node.getparent().tag == 'modify' and not inside:
			nodesM.append(long(node.get('id')))

# Save modified nodes that are already in the database
cur.execute('select id from planet_osm_nodes where id = ANY(%s);', (nodesM,))
for row in cur:
	nodes[str(row[0])] = True

# WAYS

ways = [] # List of ways (int id) with nodes inside poly or no known nodes
waysM = [] # List of modified ways with no nodes inside poly (temporary)
for way in root.iter('way'):
	if way.getparent().tag not in ['modify', 'create']:
		continue
	foundInside = False
	foundKnown = False
	for nd in way.iterchildren('nd'):
		if nd.get('ref') in nodes:
			foundKnown = True
			if nodes[nd.get('ref')] == True:
				foundInside = True
				break
	if foundInside:
		for nd in way.iterchildren('nd'):
			nodes[nd.get('ref')] = True
	else:
		wayId = int(way.get('id'))
		if foundKnown:
			ways.append(wayId)
			if way.getparent().tag == 'modify':
				waysM.append(wayId)

cur.execute('select id from planet_osm_ways where id = ANY(%s);', (waysM,))
for row in cur:
	ways.remove(row[0])
	# iterate over osmChange/<mode>/way[id=<id>]/nd and set nodes[ref] to True
	for nd in root.xpath('//way[@id={}]/nd'.format(row[0])):
		nodes[nd.get('ref')] = True

# RELATIONS

relations = [] # List of modified relations that are not in the database
for rel in root.iter('relation'):
	if rel.getparent().tag == 'modify':
		relations.append(int(rel.get('id')))

cur.execute('select id from planet_osm_rels where id = ANY(%s);', (relations,))
for row in cur:
	relations.remove(row[0])

cur.close()
db.close()

# filter tree
# 1. remove objects out of bounds
cnt = [0, 0, 0]
total = [0, 0, 0]
types = ['node', 'way', 'relation']
for obj in root.iter('node', 'way', 'relation'):
	idx = types.index(obj.tag)
	ident = obj.get('id')
	if obj.getparent().tag in ['modify', 'create']:
		total[idx] = total[idx] + 1
	if (obj.tag == 'node' and ident in nodes and not nodes[ident]) or (obj.tag == 'way' and int(ident) in ways) or (obj.tag == 'relation' and int(ident) in relations):
		obj.getparent().remove(obj)
	else:
		cnt[idx] = cnt[idx] + 1
	
if options.verbose:
	print '{} -> {}'.format('+'.join(map(str, total)), '+'.join(map(str, cnt)))

# 2. remove empty sections
for sec in root:
	if len(sec) == 0:
		root.remove(sec)

# save modified osc
of = sys.stdout if options.output == '-' else open(options.output, 'wb')
if options.gzip:
	of = gzip.GzipFile(fileobj=of)
of.write(etree.tostring(tree))
<file_sep>/roles/stats/files/du_zoom
#!/bin/sh
#
# Plugin to monitor the rendering throughput of Renderd
#
# Parameters: 
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#

if [ "$1" = "config" ]; then

	echo 'graph_title Tile disk usage by zoom'
	echo 'graph_args --base 1024 -l 0'
	echo 'graph_vlabel Tile disk usage'
	echo 'graph_category renderd'
	echo 'z1.label zoom 6-8'
	echo 'z1.draw AREASTACK'
	echo 'z1.info Disk usage for z6-z8'
	echo 'z2.label zoom 9'
	echo 'z2.draw AREASTACK'
	echo 'z2.info Disk usage for z9'
	echo 'z3.label zoom 10'
	echo 'z3.draw AREASTACK'
	echo 'z3.info Disk usage for z10'
	echo 'z4.label zoom 11'
	echo 'z4.draw AREASTACK'
	echo 'z4.info Disk usage for z11'
	echo 'z5.label zoom 12'
	echo 'z5.draw AREASTACK'
	echo 'z5.info Disk usage for z12'
	echo 'z6.label zoom 13-15'
	echo 'z6.draw AREASTACK'
	echo 'z6.info Disk usage for z13-15'

	exit 0
fi

du --max-depth 1 /var/lib/mod_tile/veloroad > /tmp/du-veloroad.txt
zoom6=`(grep \/6 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom7=`(grep \/7 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom8=`(grep \/8 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom9=`(grep \/9 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom10=`(grep \/10 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom11=`(grep \/11 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom12=`(grep \/12 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom13=`(grep \/13 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom14=`(grep \/14 /tmp/du-veloroad.txt || echo 0) | cut -f1`
zoom15=`(grep \/15 /tmp/du-veloroad.txt || echo 0) | cut -f1`
rm /tmp/du-veloroad.txt

echo "z1.value" `expr $zoom6 + $zoom7 + $zoom8`
echo "z2.value $zoom9"
echo "z3.value $zoom10"
echo "z4.value $zoom11"
echo "z5.value $zoom12"
echo "z6.value" `expr $zoom13 + $zoom14 + $zoom15`
<file_sep>/roles/schedules/files/balticgit20.ini
title = Baltic GIT 2020
slug = balticgit2020
url = https://www.balticgitconf.eu/
timezone = +02
<file_sep>/roles/schedules/files/sotm2021.ini
title = State of the Map 2021
slug = sotm2021
url = https://2021.stateofthemap.org/
timezone = +00
<file_sep>/roles/mayak_nav_bot/templates/backup_mayak.j2
#!/bin/bash
set -u -e
BORG=/usr/local/bin/borg
export BORG_REPO={{ borg_repo }}
export BORG_PASSPHRASE='{{ borg_pass }}'
export BORG_REMOTE_PATH=borg1
export BORG_RSH='ssh -i /root/.ssh/borg -oBatchMode=yes'

systemctl stop mayak_nav_bot

$BORG create --compression zstd,5 ::'Mayak_{now:%Y-%m-%d_%H%M}' \
  /opt/src/mayak_nav/config/photo \
  /opt/src/mayak_nav/config/raybot.sqlite

$BORG prune --prefix 'Mayak_' --keep-daily=7 --keep-weekly=2 --keep-monthly=3

systemctl start mayak_nav_bot
<file_sep>/roles/teleput/templates/backup_teleput.j2
#!/bin/bash
set -u -e
BORG=/usr/local/bin/borg
export BORG_REPO={{ borg_repo }}
export BORG_PASSPHRASE='{{ borg_pass }}'
export BORG_REMOTE_PATH=borg1
export BORG_RSH='ssh -i /root/.ssh/borg -oBatchMode=yes'

systemctl stop teleput

$BORG create --compression zstd,5 ::'Teleput_{now:%Y-%m-%d_%H%M}' \
  /opt/src/teleput/teleput.sqlite

$BORG prune --prefix 'Teleput_' --keep-daily=3 --keep-weekly=1 --keep-monthly=1

systemctl start teleput
<file_sep>/roles/stats/files/make_stat.sh
#!/bin/sh
df -h /
echo
du --max-depth 1 -h /var/lib/mod_tile | grep 'lonely\|dhr\|smoot\|sur\|osm\|old'
du --max-depth 1 -h /var/lib/mod_tile/veloroad/ | sort -k 2
echo
top -n 1 -b |head -n 15
<file_sep>/roles/tile_server/files/openstreetmap-tiles-update-expire
#!/bin/sh

set -e

#*************************************************************************
#*************************************************************************
OSMOSIS_BIN=osmosis
OSM2PGSQL_BIN=osm2pgsql
OSM2PGSQL_OPTIONS="-S /opt/styles/veloroad/veloroad.style"
#OSM2PGSQL_OPTIONS="--flat-nodes /path/to/flatnodes --hstore"

REPLAG=/opt/src/mod_tile/osmosis-db_replag
TRIM_OSC=/opt/src/regional/trim_osc.py
BOUNDS_POLY=/opt/styles/bounds.json

BASE_DIR=/var/lib/mod_tile
LOG_DIR=/var/log/tiles
WORKOSM_DIR=$BASE_DIR/.osmosis

LOCK_FILE=/tmp/openstreetmap-update-expire-lock.txt
CHANGE_FILE=$BASE_DIR/changes.osc.gz
EXPIRY_FILE=$BASE_DIR/dirty_tiles
STOP_FILE=$BASE_DIR/stop.txt

OSMOSISLOG=$LOG_DIR/osmosis.log
PGSQLLOG=$LOG_DIR/osm2pgsql.log
EXPIRYLOG=$LOG_DIR/expiry.log
RUNLOG=$LOG_DIR/run.log

EXPIRY_MINZOOM=10
EXPIRY_MAXZOOM=15

MIN_DISK_SPACE_MB=500

#*************************************************************************
#*************************************************************************

m_info()
{
        echo "[`date +"%Y-%m-%d %H:%M:%S"`] $$ $1" >> "$RUNLOG"
}

m_error()
{
    echo "[`date +"%Y-%m-%d %H:%M:%S"`] $$ [error] $1" >> "$RUNLOG"
    
    m_info "resetting state"
    /bin/cp $WORKOSM_DIR/last.state.txt $WORKOSM_DIR/state.txt || true
    
    rm "$CHANGE_FILE" || true
    rm "$EXPIRY_FILE.$$" || true
    rm "$LOCK_FILE"
    exit
}

m_ok()
{
    echo "[`date +"%Y-%m-%d %H:%M:%S"`] $$ $1" >> "$RUNLOG"
}

getlock()
{
    if [ -s $1 ]; then
        if [ "$(ps -p `cat $1` | wc -l)" -gt 1 ]; then
            return 1 #false
        fi
    fi
    
    echo $$ >"$1"
    return 0 #true
}

freelock()
{
    rm "$1"
    rm "$CHANGE_FILE"
}


if [ $# -eq 1 ] ; then
    m_info "Initialising Osmosis replication system to $1"
    mkdir $WORKOSM_DIR
    $OSMOSIS_BIN --read-replication-interval-init workingDirectory=$WORKOSM_DIR 1>&2 2> "$OSMOSISLOG"
    wget "http://osm.personalwerk.de/replicate-sequences/?"$1"T00:00:00Z" -O $WORKOSM_DIR/state.txt
else
# make sure the lockfile is removed when we exit and then claim it

    if ! getlock "$LOCK_FILE"; then
        m_info "pid `cat $LOCK_FILE` still running"
        exit 3
    fi

    if [ -e $STOP_FILE ]; then
        m_info "stopped"
        exit 2
    fi

    #if (( `stat -f --format="%a*%S" $BASE_DIR` < 1024*1024*$MIN_DISK_SPACE_MB )); then
    if which python > /dev/null; then
    if python -c "import os, sys; st=os.statvfs('$BASE_DIR'); sys.exit(1 if st.f_bavail*st.f_frsize/1024/1024 > $MIN_DISK_SPACE_MB else 0)"; then
        m_info "there is less than $MIN_DISK_SPACE_MB MB left"
        exit 4
    fi
    fi

    seq=`cat $WORKOSM_DIR/state.txt | grep sequenceNumber | cut -d= -f2`

    m_ok "start import from seq-nr $seq, replag is `$REPLAG -h`"

    /bin/cp $WORKOSM_DIR/state.txt $WORKOSM_DIR/last.state.txt
    m_ok "downloading diff"
    
    if ! $OSMOSIS_BIN --read-replication-interval workingDirectory=$WORKOSM_DIR --simplify-change --write-xml-change $CHANGE_FILE 1>&2 2> "$OSMOSISLOG"; then
        m_error "Osmosis error"
    fi
    
    if [ -e "$BOUNDS_POLY" ]; then
      m_ok "filtering diff"
      if ! python3 "$TRIM_OSC" -v -d gis -p "$BOUNDS_POLY" -z $CHANGE_FILE $CHANGE_FILE 1>&2 2>> "$RUNLOG"; then
          m_error "Trim_osc error"
      fi
    fi

    m_ok "importing diff"
    EXPIRY_METAZOOM=`expr $EXPIRY_MAXZOOM - 3`
    if ! $OSM2PGSQL_BIN -a --slim -e$EXPIRY_METAZOOM:$EXPIRY_METAZOOM $OSM2PGSQL_OPTIONS -o "$EXPIRY_FILE.$$" $CHANGE_FILE 1>&2 2> "$PGSQLLOG"; then
        m_error "osm2pgsql error"
    fi

    freelock "$LOCK_FILE"

    m_ok "expiring tiles"
    if ! render_expired --min-zoom=$EXPIRY_MINZOOM --max-zoom=$EXPIRY_MAXZOOM --touch-from=$EXPIRY_MINZOOM -s /var/run/renderd.sock < "$EXPIRY_FILE.$$" 2>&1 | tail -8 >> "$EXPIRYLOG"; then
        m_info "Expiry failed"
    fi

    rm "$EXPIRY_FILE.$$"
    
    m_ok "Done with import"
fi
<file_sep>/roles/schedules/files/sotm2019.ini
title = State of the Map 2019
slug = sotm2019
url = https://2019.stateofthemap.org/
timezone = +02
<file_sep>/roles/schedules/files/update_schedules.sh
#!/bin/bash
set -e -u -x

WWW=/var/www/sotm
HERE="$(cd "$(dirname "$0")"; pwd)"
DATA="$HERE/sotm_schedules"
VENV="$HERE/sc_venv"
BASEURL="https://sotm.osmz.ru"

mkdir -p "$DATA"
wget -q -r -O "$DATA/f2022.xml" "https://talks.osgeo.org/foss4g-2022/schedule/export/schedule.xml"
wget -q -r -O "$DATA/f2022-at.xml" "https://talks.osgeo.org/foss4g-2022-academic-track/schedule/export/schedule.xml"
# wget -q -r -O "$DATA/sotm2020-add.csv" 'https://docs.google.com/spreadsheets/d/1EO3aC3vF9dvb1wopT_cUHaDXqdGIrid_Kj59PZyzR_g/export?format=csv&id=0'
#sed -i -e 's/Academic Track | Track 2 - Sunday, July 5/Track 2/' "$DATA/sotm2020-at.xml"

SC="$VENV/bin/schedule_convert"
$SC $DATA/foss4g2022.ini $DATA/f2022.xml $DATA/f2022-at.xml -l "$WWW" "$BASEURL/f2022"
<file_sep>/roles/sotm_intro_bot/templates/config.py
import os

DATABASE = os.path.join(os.path.dirname(__file__), 'intros.sqlite')
API_TOKEN = '{{ sotm_intro_bot_token }}'
ADMIN_ID = {{ sotm_intro_admin_id }}
<file_sep>/roles/sotm_intro_bot/templates/backup_intros.j2
#!/bin/bash
set -u -e
BORG=/usr/local/bin/borg
export BORG_REPO={{ borg_repo }}
export BORG_PASSPHRASE='{{ borg_pass }}'
export BORG_REMOTE_PATH=borg1
export BORG_RSH='ssh -i /root/.ssh/borg -oBatchMode=yes'

systemctl stop sotm_intro_bot

$BORG create --compression zstd,5 ::'SotmIntro_{now:%Y-%m-%d_%H%M}' \
  /opt/src/sotm_intro_bot/intros.sqlite

$BORG prune --prefix 'SotmIntro_' --keep-daily=7 --keep-weekly=2 --keep-monthly=3

systemctl start sotm_intro_bot
<file_sep>/roles/schedules/files/hot2019.ini
title = HOT Summit 2019
slug = hotosm2019
url = https://summit2019.hotosm.org/
timezone = +02
<file_sep>/roles/hitrye/templates/backup_hitrye.j2
#!/bin/bash
set -u -e
BORG=/usr/local/bin/borg
export BORG_REPO={{ borg_repo }}
export BORG_PASSPHRASE='{{ borg_pass }}'
export BORG_REMOTE_PATH=borg1
export BORG_RSH='ssh -i /root/.ssh/borg -oBatchMode=yes'

DBDUMP=/var/tmp/hitrye.sql
pg_dump -U phpbb --format=c --file=$DBDUMP hitrye

$BORG create --compression zstd,5 ::'Hitrye_{now:%Y-%m-%d_%H%M}' \
  $DBDUMP \
  /var/www/hitrye/files \
  /var/www/hitrye/images/avatars/upload

$BORG prune --prefix 'Hitrye_' --keep-daily=7 --keep-weekly=2 --keep-monthly=3

rm $DBDUMP
<file_sep>/roles/schedules/files/foss4g2022.ini
title = FOSS4G 2022
slug = f2022
url = https://2022.foss4g.org/schedule_general.php
timezone = +02
<file_sep>/Vagrantfile
Vagrant.configure(2) do |config|
  # config.vm.box = "ubuntu/xenial64"
  config.vm.box = "nrclark/xenial64-minimal-libvirt"
  config.vm.host_name = "tile"
  config.vm.network "forwarded_port", guest: 80, host: 8080

  config.ssh.insert_key = false

  config.vm.provision "ansible" do |ansible|
    ansible.force_remote_user = false
    ansible.verbose = "v"
    ansible.playbook = "playbook.yml"
  end
end
<file_sep>/roles/schedules/files/index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>State of the Map XML Schedules</title>
<style>
html { margin: 0; }
body { font-family: sans-serif; font-size: 16px; background: #ddd; margin: 0; }
#content { max-width: 700px; background: #f1f1f1; color: #111; margin: 0 auto; padding: 1em 1em 2em; }
.link { margin: 1em 0; font-size: 20px; }
</style>
</head>
<body>
<div id="content">
    <h1>Schedules</h1>
    <p>Please head on to the conference you're planning to visit:</p>
    <div class="link"><a href="f2022.html">FOSS4G 2022</a></div>
</div>
</body>
</html>
<file_sep>/roles/get_veloroad/files/nik4wsgi_config.py
PYTHON = 'python3.5'
NIK4 = '/opt/src/Nik4/nik4.py'

STYLES = [
    ['veloroad', 'Veloroad Ru', '/opt/styles/veloroad/veloroad-r.xml', True],
    ['veloroaden', 'Veloroad', '/opt/styles/veloroad/veloroad-en.xml', True],
    ['osm', 'OSM-Carto', '/opt/styles/osm-carto/osm-r.xml', False],
]
TILES = {
    'veloroad': ['http://tile.osmz.ru/veloroad/{z}/{x}/{y}.png',
                 'Map &copy; OpenStreetMap | Tiles &copy <NAME>'],
    'veloroaden': ['http://tile.osmz.ru/veloroad/{z}/{x}/{y}.png',
                   'Map &copy; OpenStreetMap | Tiles &copy <NAME>'],
    'osm': ['https://tile.openstreetmap.org/{z}/{x}/{y}.png',
            'Map &copy; OpenStreetMap'],
}
<file_sep>/upload_pbf.sh
#!/bin/bash
[ $# -lt 1 ] && echo "Usage: $0 <planet.pbf> [<bounds.json>]" && exit 1
#ansible-playbook upload_pbf.yml -i hosts -e "pbf=$1" ${2+-e "bounds=$2"}
ansible-playbook upload_pbf.yml -i hosts -e "pbf=$1" ${2+-e "bounds=$2"} --skip-tags osm2pgsql
<file_sep>/roles/schedules/files/sotm2022.ini
title = State of the Map 2022
slug = sotm2022
url = https://2022.stateofthemap.org/
timezone = +02
