mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 19:52:06 +00:00
Merge branch 'mitra' into distweb - make my distweb bramch match the proposed PR (unlike George's distweb branch)
This commit is contained in:
commit
21836270ad
29 changed files with 961 additions and 31 deletions
|
@ -10,7 +10,7 @@ CWD=`pwd`
|
|||
OS=`grep ^ID= /etc/*release|cut -d= -f2`
|
||||
OS=${OS//\"/}
|
||||
MIN_RPI_KERN=4.9.59-v7+
|
||||
MIN_ANSIBLE_VER=2.6.15
|
||||
MIN_ANSIBLE_VER=2.6.16
|
||||
|
||||
if [ ! -f /etc/iiab/local_vars.yml ]; then
|
||||
|
||||
|
|
|
@ -95,6 +95,12 @@
|
|||
dest: /etc/chrony.conf
|
||||
backup: no
|
||||
|
||||
# Debian 10 "Buster" is apparently enabling AppArmor in 2019:
|
||||
# https://wiki.debian.org/AppArmor/Progress
|
||||
# https://wiki.debian.org/AppArmor/HowToUse
|
||||
# https://packages.debian.org/buster/apparmor
|
||||
# Curiously this has NOT stopped IIAB 7.0/master from working on Debian 10
|
||||
# pre-releases, during @floydianslips' March 2019 testing anyway!
|
||||
- name: Disable AppArmor -- override OS default (ubuntu)
|
||||
service:
|
||||
name: apparmor
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
when: moodle_install
|
||||
tags: olpc, moodle
|
||||
|
||||
- name: OSM_VECTOR
|
||||
include_role:
|
||||
name: osm-vector
|
||||
when: osm_vector_install is defined and osm_vector_install
|
||||
tags: osm
|
||||
|
||||
# UNMAINTAINED
|
||||
- name: OSM
|
||||
include_role:
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
|
||||
|
||||
elgg_xx: elgg
|
||||
elgg_version: "2.3.10"
|
||||
elgg_version: 2.3.12
|
||||
|
||||
# elgg_mysql_password: defined in default_vars
|
||||
elgg_url: /elgg
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=============
|
||||
============
|
||||
Gitea README
|
||||
=============
|
||||
============
|
||||
|
||||
This Ansible role installs Gitea - a self-hosted Git service written in Go.
|
||||
|
||||
|
@ -9,16 +9,41 @@ Using It
|
|||
|
||||
Gitea should be accessible at: http://box/gitea
|
||||
|
||||
Gitea repositories can be cloned using either HTTP or SSH. When cloning with
|
||||
HTTP, the clone URL will start with ``http://box.lan/gitea/``. SSH clone URLs
|
||||
start with ``gitea@box.lan``.
|
||||
|
||||
Installation and Setup
|
||||
----------------------
|
||||
|
||||
Simply run ``cd /opt/iiab/iiab`` then ``sudo ./runrole gitea`` to install
|
||||
Gitea. After installing, Gitea will be live at http://box/gitea
|
||||
|
||||
The first time you access the Gitea web interface, the home page will appear.
|
||||
Clicking on "Register" or "Sign In" in the upper right corner will take you to
|
||||
the setup page. The recommended settings have been configured for you, but you
|
||||
can change them if you want. For example, you may want to change the site title
|
||||
to match the name of your organization.
|
||||
|
||||
After finishing the setup process, you will be directed to a page where you can
|
||||
create a user account. The first account created after setting up Gitea will be
|
||||
an admin account. You can also create an admin account from the setup page
|
||||
under "Administrator Account Settings."
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Gitea has been configured to work with MySQL; it can also be used with SQLite or
|
||||
Gitea has been configured to work with SQLite; it can also be used with MySQL or
|
||||
PostgreSQL. If you want to use it with a different database, change the
|
||||
``DB_TYPE`` property in ``/etc/gitea/app.ini`` [1] and change the line ``After=mysqld.service``
|
||||
in ``/etc/systemd/system/gitea.service`` [2] to one of the following:
|
||||
``DB_TYPE`` property in ``/etc/gitea/app.ini`` [1] and add one of the following
|
||||
lines to the ``[Unit]`` section of ``/etc/systemd/system/gitea.service`` [2]:
|
||||
|
||||
* SQLite: comment it out.
|
||||
* Postgres: ``After=postgresql.service``
|
||||
* MySQL: ``After=mysqld.service``
|
||||
* PostgreSQL: ``After=postgresql.service``
|
||||
|
||||
For MySQL and PostgreSQL, you need to specify the server address, the database
|
||||
name, and the user credentials that Gitea will use to access the database.
|
||||
**Make sure the user exists on the database server first.**
|
||||
|
||||
[1] Prior to installing Gitea, instead edit: ``/opt/iiab/iiab/roles/gitea/templates/app.ini.j2``
|
||||
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
# https://git.coolaj86.com/coolaj86/gitea-installer.sh
|
||||
|
||||
# Information needed to install Gitea
|
||||
gitea_version: "1.7.4"
|
||||
gitea_version: 1.8.0
|
||||
iset_suffixes:
|
||||
i386: "386"
|
||||
x86_64: "amd64"
|
||||
armv6l: "arm-6"
|
||||
armv7l: "arm-7"
|
||||
i386: 386
|
||||
x86_64: amd64
|
||||
armv6l: arm-6
|
||||
armv7l: arm-7
|
||||
|
||||
gitea_iset_suffix: "{{ iset_suffixes[ansible_architecture] | default('unknown') }}"
|
||||
|
||||
gitea_download_url: "https://dl.gitea.io/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-{{ gitea_iset_suffix }}"
|
||||
gitea_integrity_url: "{{ gitea_download_url }}.asc"
|
||||
|
||||
gitea_root_directory: "/library/gitea"
|
||||
gitea_root_directory: /library/gitea
|
||||
gitea_subdirectories:
|
||||
- bin
|
||||
- custom
|
||||
|
@ -38,11 +38,11 @@ gitea_gpg_key: 7C9E68152594688862D62AF62D9AE806EC1592E2
|
|||
|
||||
# Information needed to run Gitea
|
||||
gitea_user: gitea
|
||||
gitea_home: "/home/{{ gitea_user }}" # SSH credentials stored here
|
||||
gitea_home: "/home/{{ gitea_user }}" # SSH credentials stored here
|
||||
gitea_run_directory: "{{ gitea_root_directory }}"
|
||||
|
||||
gitea_url: /gitea
|
||||
gitea_port: 61734 # leet for GITEA
|
||||
gitea_port: 61734 # leet for GITEA
|
||||
|
||||
# Data locations
|
||||
gitea_db_path: "{{ gitea_root_directory }}/data/gitea.db"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
Description=Gitea (Git with a cup of tea)
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
After=mysqld.service
|
||||
|
||||
[Service]
|
||||
# Modify these two values and uncomment them if you have
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
# Which kiwix-tools to download from http://download.iiab.io/packages/
|
||||
# As obtained from http://download.kiwix.org/release/kiwix-tools/ or http://download.kiwix.org/nightly/
|
||||
|
||||
kiwix_version_armhf: "kiwix-tools_linux-armhf-1.1.0"
|
||||
kiwix_version_linux64: "kiwix-tools_linux-x86_64-1.1.0"
|
||||
kiwix_version_i686: "kiwix-tools_linux-i586-1.1.0"
|
||||
kiwix_version_armhf: "kiwix-tools_linux-armhf-1.2.0"
|
||||
kiwix_version_linux64: "kiwix-tools_linux-x86_64-1.2.0"
|
||||
kiwix_version_i686: "kiwix-tools_linux-i586-1.2.0"
|
||||
# kiwix_src_file_i686: "kiwix-linux-i686.tar.bz2"
|
||||
# v0.9 for i686 published May 2014 ("use it to test legacy ZIM content")
|
||||
# v0.10 for i686 published Oct 2016 ("experimental") REPLACED IN EARLY 2018, thx to Matthieu Gautier:
|
||||
|
|
|
@ -49,11 +49,11 @@
|
|||
src: network/rpi.j2
|
||||
when: is_rpi and iiab_lan_iface == "br0"
|
||||
|
||||
- name: Workaround auto issue (debian-9)
|
||||
- name: Workaround auto issue - ifupdown compatibility mode (debian-9 or debian-10)
|
||||
template:
|
||||
dest: /etc/network/interfaces.d/patch_auto
|
||||
src: network/debian-auto.j2
|
||||
when: iiab_wan_iface != "none" and is_debian_9
|
||||
when: iiab_wan_iface != "none" and (is_debian_9 or is_debian_10)
|
||||
|
||||
- name: Clearing out /etc/network/interfaces for static addresses (debian-9)
|
||||
lineinfile:
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
nextcloud_install: True
|
||||
nextcloud_enabled: False
|
||||
# nextcloud_install: False
|
||||
# nextcloud_enabled: False
|
||||
|
||||
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
|
||||
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
|
||||
|
||||
# REMOVE /opt/nextcloud/version.php TO FORCE AN INSTALL OR REINSTALL OR UPGRADE
|
||||
nextcloud_force_install: False
|
||||
|
@ -8,7 +11,7 @@ nextcloud_url: /nextcloud
|
|||
nextcloud_prefix: /opt
|
||||
nextcloud_data_dir: "{{ content_base }}/nextcloud/data"
|
||||
nextcloud_dl_url: https://download.nextcloud.com/server/releases
|
||||
nextcloud_orig_src_file: latest-15.tar.bz2
|
||||
nextcloud_orig_src_file: nextcloud-15.tar.bz2 # 2019-04-25: latest-16.0.0.tar.bz2 requires PHP 7.1+ and so fails on current Raspbian and Debian 9 "Stretch". Aside: latest-16.tar.bz2 oddly not yet published at https://download.nextcloud.com/server/releases/
|
||||
nextcloud_src_file: nextcloud_{{ nextcloud_orig_src_file }}
|
||||
|
||||
# we install on mysql with these setting or those from default_vars, etc.
|
||||
|
|
|
@ -71,6 +71,10 @@
|
|||
# NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/<OS>.yml
|
||||
# DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!)
|
||||
|
||||
# 2019-03-29: Above works on Debian 10 Buster pre-releases, but fails on Ubuntu
|
||||
# 19.04 Beta. Comment it out for now, and manually run: "apt install npm" then
|
||||
# "npm install -g npm@latest" (all *SHOULD* be magically fixed by 2019-04-18 ?)
|
||||
|
||||
- name: Install latest Node.js {{ nodejs_version }} which includes /usr/bin/npm (debuntu)
|
||||
package:
|
||||
# name: nodejs={{ nodejs_version }}
|
||||
|
@ -127,3 +131,6 @@
|
|||
# This May Change: thanks all for running "apt -a list nodejs" on Buster's
|
||||
# daily builds @ www.debian.org/devel/debian-installer/ and Disco Dingo (Ubuntu
|
||||
# 19.04) https://launchpad.net/ubuntu/+source/nodejs to keep us informed!
|
||||
|
||||
# 2019-03-29: Debian 10 Buster & Ubuntu 19.04 pre-releases made the jump
|
||||
# thankfully; currently both offer Node.js 10.15.2
|
||||
|
|
9
roles/osm-vector/defaults/main.yml
Normal file
9
roles/osm-vector/defaults/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
osm_vector_install: True
|
||||
osm_vector_enabled: True
|
||||
osm_vector_path: '{{ content_base }}/www/osm-vector'
|
||||
|
||||
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
|
||||
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
|
||||
|
||||
menu_def_dir: '{{ doc_root }}/js-menu/menu-files/menu-defs'
|
||||
iiab_osm_url : http://download.iiab.io/content/OSM/vector-tiles/maplist/hidden
|
182
roles/osm-vector/files/countries.json
Normal file
182
roles/osm-vector/files/countries.json
Normal file
File diff suppressed because one or more lines are too long
12
roles/osm-vector/files/en-map_test.json
Normal file
12
roles/osm-vector/files/en-map_test.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"lang": "en",
|
||||
"intended_use": "map",
|
||||
"automatically_generated": "true",
|
||||
"title": "OpenStreetMap Test Page",
|
||||
"extra_html": "",
|
||||
"start_url": "maplist",
|
||||
"menu_item_name": "en-map_test.json",
|
||||
"map_name": "en-map_test",
|
||||
"logo_url": "osm.jpg",
|
||||
"description": "<p>This page is installed by default during the initial installation of Internet In A Box>"
|
||||
}
|
216
roles/osm-vector/files/osm_functions.js
Normal file
216
roles/osm-vector/files/osm_functions.js
Normal file
|
@ -0,0 +1,216 @@
|
|||
// osm_functions.js -- (non authoritative see below) src = iiab/roles/files/
|
||||
// copyright 2019 George Hunt
|
||||
// CAUTION -- this file is duplicate to admin-console/console/files/js/osm_fuctions.js -- please think of admin-console as authoritative
|
||||
// Placed here in duplicate to ease debugging, and simplify dependences
|
||||
|
||||
var regionGeojson = {};
|
||||
var regionList = [];
|
||||
var regionInstalled = [];
|
||||
var commonAssetsDir = '/common/assets/';
|
||||
var mapAssetsDir = '/osm-vector/maplist/assets/';
|
||||
var iiab_config_dir = '/etc/iiab/';
|
||||
var onChangeFunc = "setSize";
|
||||
var osmCatalog = {};
|
||||
|
||||
// following 2 lines an experiment to see if test page and console can be common
|
||||
//var jquery = require("./assets/jquery.min");
|
||||
//window.$ = window.jQuery = jquery;
|
||||
|
||||
function getOsmStat(){
|
||||
// called during the init
|
||||
console.log('in getOsmStat');
|
||||
readOsmCatalog( true ); // we want checkboxes
|
||||
readOsmIdx();
|
||||
}
|
||||
|
||||
function readOsmIdx(){
|
||||
//consoleLog ("in readOsmIdx");
|
||||
var resp = $.ajax({
|
||||
type: 'GET',
|
||||
url: consoleJsonDir + 'osm-vector-idx.json',
|
||||
dataType: 'json'
|
||||
})
|
||||
.done(function( data ) {
|
||||
osmInstalled = data['regions'];
|
||||
regionInstalled = [];
|
||||
for (region in data['regions']) {
|
||||
if (data['regions'].hasOwnProperty(region)) {
|
||||
regionInstalled.push(region);
|
||||
}
|
||||
}
|
||||
//consoleLog(osmInstalled + '');
|
||||
})
|
||||
.fail(jsonErrhandler);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
function readOsmCatalog(checkbox){
|
||||
checkbox = checkbox || true;
|
||||
console.log ("in readOsmCalalog");
|
||||
regionList = [];
|
||||
var resp = $.ajax({
|
||||
type: 'GET',
|
||||
url: mapAssetsDir + 'regions.json',
|
||||
dataType: 'json'
|
||||
})
|
||||
.done(function( data ) {
|
||||
regionJson = data;
|
||||
osmCatalog = regionJson['regions'];
|
||||
for(var key in osmCatalog){
|
||||
//console.log(key + ' ' + osmCatalog[key]['title']);
|
||||
osmCatalog[key]['name'] = key;
|
||||
regionList.push(osmCatalog[key]);
|
||||
}
|
||||
})
|
||||
.fail(jsonErrhandler);
|
||||
return resp;
|
||||
}
|
||||
|
||||
function renderRegionList(checkbox) { // generic
|
||||
var html = "";
|
||||
// order the regionList by seq number
|
||||
var regions = regionList;
|
||||
console.log ("in renderRegionList");
|
||||
|
||||
// sort on basis of seq
|
||||
regions = regions.sort(function(a,b){
|
||||
if (a.seq < b.seq) return -1;
|
||||
else return 1;
|
||||
});
|
||||
//console.log(regions);
|
||||
// render each region
|
||||
html += '<form>';
|
||||
regions.forEach((region, index) => { // now render the html
|
||||
//console.log(region.title + " " +region.seq);
|
||||
html += genRegionItem(region,checkbox);
|
||||
});
|
||||
html += '</form>';
|
||||
//console.log(html);
|
||||
$( "#regionlist" ).html(html);
|
||||
}
|
||||
|
||||
|
||||
function genRegionItem(region,checkbox) {
|
||||
var html = "";
|
||||
console.log("in genRegionItem: " + region.name);
|
||||
var itemId = region.title;
|
||||
var ksize = region.size / 1000;
|
||||
//console.log(html);
|
||||
html += '<div class="extract" data-region={"name":"' + region.name + '"}>';
|
||||
html += ' <label>';
|
||||
if ( checkbox ) {
|
||||
if (selectedOsmItems.indexOf(region.name) != -1)
|
||||
checked = 'checked';
|
||||
else
|
||||
checked = '';
|
||||
html += '<input type="checkbox" name="' + region.name + '"';
|
||||
html += ' onChange="updateOsmSpace(this)" ' + checked + '>';
|
||||
}
|
||||
html += itemId;
|
||||
if ( checkbox ) { html += '</input>';};
|
||||
html += '</label>'; // end input
|
||||
html += ' Size: ' + readableSize(ksize);
|
||||
html += '</div>';
|
||||
//console.log(html);
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function instOsmItem(name) {
|
||||
var command = "INST-OSM-VECT-SET";
|
||||
var cmd_args = {};
|
||||
cmd_args['osm_vect_id'] = name;
|
||||
cmd = command + " " + JSON.stringify(cmd_args);
|
||||
sendCmdSrvCmd(cmd, genericCmdHandler);
|
||||
osmDownloading.push(name);
|
||||
if ( osmWip.indexOf(name) != -1 )
|
||||
osmWip.push(osmCatalog[name]);
|
||||
console.log('osmWip: ' + osmWip);
|
||||
return true;
|
||||
}
|
||||
|
||||
function jsonErrhandler (jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
// only handle json parse errors here, others in ajaxErrHandler
|
||||
if (textStatus == "parserror") {
|
||||
//alert ("Json Errhandler: " + textStatus + ", " + errorThrown);
|
||||
displayServerCommandStatus("Json Errhandler: " + textStatus + ", " + errorThrown);
|
||||
}
|
||||
//consoleLog("In Error Handler logging jqXHR");
|
||||
console.log(textStatus);
|
||||
console.log(errorThrown);
|
||||
console.log(jqXHR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function readableSize(kbytes) {
|
||||
if (kbytes == 0)
|
||||
return "0";
|
||||
var bytes = 1024 * kbytes;
|
||||
var s = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'];
|
||||
var e = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
return (bytes / Math.pow(1024, e)).toFixed(2) + " " + s[e];
|
||||
}
|
||||
|
||||
function updateOsmSpace(cb){
|
||||
console.log("in updateOsmSpace" + cb);
|
||||
var region = cb.name;
|
||||
updateOsmSpaceUtil(region, cb.checked);
|
||||
}
|
||||
|
||||
function updateOsmSpaceUtil(region, checked){
|
||||
var size = parseInt(osmCatalog[region].size);
|
||||
|
||||
var modIdx = selectedOsmItems.indexOf(region);
|
||||
|
||||
if (checked){
|
||||
if (regionInstalled.indexOf(region) == -1){ // only update if not already installed mods
|
||||
sysStorage.osm_selected_size += size;
|
||||
selectedOsmItems.push(region);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (modIdx != -1){
|
||||
sysStorage.osm_selected_size -= size;
|
||||
selectedOsmItems.splice(modIdx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
displaySpaceAvail();
|
||||
}
|
||||
|
||||
/*
|
||||
function totalSpace(){
|
||||
// obsolete but perhaps useful in debugging since it worked
|
||||
var sum = 0;
|
||||
$( ".extract" ).each(function(ind,elem){
|
||||
var data = JSON.parse($(this).attr('data-region'));
|
||||
var region = data.name;
|
||||
var size = parseInt(osmCatalog[region]['size']);
|
||||
var chk = $( this ).find(':checkbox').prop("checked") == true;
|
||||
if (chk && typeof size !== 'undefined')
|
||||
sum += size;
|
||||
});
|
||||
var ksize = sum / 1000;
|
||||
$( "#osmDiskSpace" ).html(readableSize(ksize));
|
||||
}
|
||||
|
||||
$( '#instOsmRegion').on('click', function(evnt){
|
||||
readOsmCatalog();
|
||||
osm.render();
|
||||
});
|
||||
*/
|
||||
function renderOsm(){
|
||||
console.log('in renderOsm');
|
||||
window.map.setTarget($("#osm-container")[0]);
|
||||
window.map.render();
|
||||
renderRegionList(true);
|
||||
}
|
||||
function initOsm(){
|
||||
var dummy = 0;
|
||||
sysStorage.osm_selected_size = 0;
|
||||
$.when(readOsmCatalog(true)).then(renderRegionList);
|
||||
}
|
||||
|
4
roles/osm-vector/files/test-index.redirect
Normal file
4
roles/osm-vector/files/test-index.redirect
Normal file
|
@ -0,0 +1,4 @@
|
|||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=/osm-vector/maplist/" />
|
||||
</head>
|
||||
|
100
roles/osm-vector/tasks/main.yml
Normal file
100
roles/osm-vector/tasks/main.yml
Normal file
|
@ -0,0 +1,100 @@
|
|||
- name: Make sure the osm-vector directory exists
|
||||
file:
|
||||
path: '{{ osm_vector_path }}/maplist/assets'
|
||||
state: directory
|
||||
owner: '{{ apache_user }}'
|
||||
group: '{{ apache_user }}'
|
||||
mode: '0755'
|
||||
|
||||
- name: Fetch the catalog for osm maps
|
||||
get_url:
|
||||
url: "{{ iiab_osm_url }}/assets/regions.json"
|
||||
dest: '{{ osm_vector_path }}/maplist/assets/'
|
||||
|
||||
- name: Create a link to osm catalog in /common/assets
|
||||
file:
|
||||
src: "{{ osm_vector_path }}/maplist/assets/regions.json"
|
||||
dest: "{{ doc_root }}/common/assets/regions.json"
|
||||
state: link
|
||||
|
||||
- name: Fetch the javascript bundle with openlayers for test page
|
||||
get_url:
|
||||
url: "{{ iiab_osm_url }}/../main.js"
|
||||
dest: '{{ osm_vector_path }}/maplist/'
|
||||
|
||||
- name: Fetch the index.html for test page
|
||||
template:
|
||||
src: "index.html"
|
||||
dest: '{{ osm_vector_path }}/maplist/index.html'
|
||||
|
||||
# Bboxes (bounding boxes) are currently square. But geofabrik has non-rectangular bboxes.
|
||||
# So bring the bounding box definition from cloud (bboxes.geojson is big)
|
||||
- name: Fetch the bounding box description for osm maps
|
||||
get_url:
|
||||
url: "{{ iiab_osm_url }}/assets/bboxes.geojson"
|
||||
dest: '{{ osm_vector_path }}/maplist/assets/'
|
||||
|
||||
- name: Install python-geojson package, that helps with geojson
|
||||
package:
|
||||
name: python-geojson
|
||||
state: present
|
||||
|
||||
- name: Install the script to update osm catalog
|
||||
template:
|
||||
src: iiab-update-osm
|
||||
dest: /usr/bin/iiab-update-osm
|
||||
mode: "0755"
|
||||
|
||||
- name: Run the script that does osm-vector housekeeping
|
||||
shell: /usr/bin/iiab-update-osm
|
||||
|
||||
- name: Copy the Countries geojson to assets
|
||||
copy:
|
||||
src: countries.json
|
||||
dest: '{{ osm_vector_path }}/maplist/assets'
|
||||
|
||||
# It is too complicated to use a single file for both iiab and admin-console
|
||||
- name: Copy the duplicated javascript to assets
|
||||
copy:
|
||||
src: osm_functions.js
|
||||
dest: '{{ osm_vector_path }}/maplist/assets'
|
||||
|
||||
- name: Install /etc/{{ apache_config_dir }}/osm-vect.conf from template
|
||||
template:
|
||||
src: osm-vector.conf
|
||||
dest: "/etc/{{ apache_config_dir }}/osm-vector.conf"
|
||||
|
||||
- name: Create symlink osm-vector.conf from sites-enabled to sites-available (debuntu, not nec for redhat)
|
||||
file:
|
||||
src: /etc/apache2/sites-available/osm-vector.conf
|
||||
path: /etc/apache2/sites-enabled/osm-vector.conf
|
||||
state: link
|
||||
when: osm_vector_enabled and is_debuntu
|
||||
|
||||
- name: Remove symlink /etc/apache2/sites-enabled/osm-vector.conf (debuntu)
|
||||
file:
|
||||
path: /etc/apache2/sites-enabled/osm-vector.conf
|
||||
state: absent
|
||||
when: not osm_vector_enabled and is_debuntu
|
||||
|
||||
- name: Copy the redirect to the test page -- delete this if more than one map
|
||||
copy:
|
||||
src: test-index.redirect
|
||||
dest: "{{ osm_vector_path }}/index.html"
|
||||
|
||||
- name: Create a directory for map menu-def
|
||||
file:
|
||||
path: '{{ menu_def_dir }}'
|
||||
state: directory
|
||||
|
||||
- name: Determine status of splash menu def
|
||||
stat:
|
||||
path: '{{ menu_def_dir }}/en-map_test.json'
|
||||
ignore_errors: True
|
||||
register: menu_def
|
||||
|
||||
- name: Do not overwrite if it already exists
|
||||
copy:
|
||||
src: en-map_test.json
|
||||
dest: '{{ menu_def_dir }}/en-map_test.json'
|
||||
when: menu_def.stat.exists is defined and not menu_def.stat.exists
|
189
roles/osm-vector/templates/iiab-update-osm
Executable file
189
roles/osm-vector/templates/iiab-update-osm
Executable file
|
@ -0,0 +1,189 @@
|
|||
#!/usr/bin/env python
|
||||
# Scan the osm-vector directory, update the osm-vector-idx.json, add menu-defs
|
||||
|
||||
from geojson import Feature, Point, FeatureCollection, Polygon
|
||||
import geojson
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
IIAB_PATH='/etc/iiab'
|
||||
if not IIAB_PATH in sys.path:
|
||||
sys.path.append(IIAB_PATH)
|
||||
from iiab_env import get_iiab_env
|
||||
|
||||
SCRIPT_DIR = '/opt/admin/cmdsrv/scripts'
|
||||
if not SCRIPT_DIR in sys.path:
|
||||
sys.path.append(SCRIPT_DIR)
|
||||
if os.path.exists(os.path.join(SCRIPT_DIR,'iiab_update_menus.py')):
|
||||
import iiab_update_menus as menus
|
||||
console_installed = True
|
||||
else:
|
||||
console_installed = False
|
||||
|
||||
doc_root = get_iiab_env('WWWROOT')
|
||||
menuDefs = doc_root + "/js-menu/menu-files/menu-defs/"
|
||||
osm_vector_idx_dir = doc_root + "/common/assets"
|
||||
#map_doc_root = '{{ osm_vector_path }}'
|
||||
map_doc_root = '/library/www/osm-vector'
|
||||
# map_catalog will be global, assumed always available
|
||||
map_catalog = {}
|
||||
map_menu_def_list = []
|
||||
|
||||
def main():
|
||||
global map_menu_def_list
|
||||
get_map_catalog()
|
||||
#print(json.dumps(map_catalog,indent=2))
|
||||
|
||||
map_menu_def_list = get_menu_def_names()
|
||||
print(json.dumps(map_menu_def_list,indent=2))
|
||||
|
||||
installed_maps = get_installed_regions()
|
||||
print(installed_maps)
|
||||
|
||||
write_osm_vector_idx(installed_maps)
|
||||
|
||||
# For installed regions, check that a menu def exists, and it's on home page
|
||||
for fname in installed_maps:
|
||||
region = extract_region_from_filename(fname)
|
||||
print('checking for %s region'%region)
|
||||
if region == 'maplist': # it is the splash page, display only if no others
|
||||
menu_ref = 'en-map_test'
|
||||
item = { "perma_ref" : "en-map_test" }
|
||||
if len(installed_maps) == 1:
|
||||
menus.update_menu_json(menu_ref)
|
||||
return
|
||||
else:
|
||||
item = map_catalog['regions'][region]
|
||||
menu_ref = item['perma_ref']
|
||||
if not (region in map_menu_def_list):
|
||||
print('creating menu def for %s'%item['perma_ref'])
|
||||
create_menu_def(region,item['perma_ref'] + '.json')
|
||||
if fetch_menu_json_value('autoupdate_menu'):
|
||||
print('autoudate of menu items is enabled:%s. Adding %s'%(\
|
||||
fetch_menu_json_value('autoupdate_menu'),region,))
|
||||
# verify this menu def is on home page
|
||||
menus.update_menu_json(menu_ref)
|
||||
|
||||
def get_map_catalog():
|
||||
global map_catalog
|
||||
input_json = map_doc_root + '/maplist/assets/regions.json'
|
||||
with open(input_json,'r') as regions:
|
||||
reg_str = regions.read()
|
||||
map_catalog = json.loads(reg_str)
|
||||
#print(json.dumps(map_catalog,indent=2))
|
||||
|
||||
def get_menu_def_names(intended_use='map'):
|
||||
menu_def_list =[]
|
||||
os.chdir(menuDefs)
|
||||
for filename in os.listdir('.'):
|
||||
if fnmatch.fnmatch(filename, '*.json'):
|
||||
try:
|
||||
with open(filename,'r') as json_file:
|
||||
readstr = json_file.read()
|
||||
data = json.loads(readstr)
|
||||
except:
|
||||
print("failed to parse %s"%filename)
|
||||
print(readstr)
|
||||
if data.get('intended_use','') != intended_use:
|
||||
continue
|
||||
map_name = data.get('name','')
|
||||
if map_name != '':
|
||||
menu_def_list.append(data['name'])
|
||||
return menu_def_list
|
||||
|
||||
def get_installed_regions():
|
||||
installed = []
|
||||
os.chdir(map_doc_root)
|
||||
for filename in os.listdir('.'):
|
||||
if fnmatch.fnmatch(filename, '??-osm-omt*'):
|
||||
region = re.sub(r'^..-osm-omt_(.*)',r'\1',filename)
|
||||
installed.append(region)
|
||||
# add the splash page if no other maps are present
|
||||
if len(installed) == 0:
|
||||
installed.append('maplist')
|
||||
return installed
|
||||
|
||||
def write_osm_vector_idx(installed_maps):
|
||||
map_dict ={}
|
||||
idx_dict = {}
|
||||
for fname in installed_maps:
|
||||
region = extract_region_from_filename(fname)
|
||||
if map == 'maplist': continue # not a real region
|
||||
map_dict = map_catalog['regions'].get(region,'')
|
||||
if map_dict == '': continue
|
||||
|
||||
# Create the idx file in format required bo js-menu system
|
||||
item = map_dict['perma_ref']
|
||||
idx_dict[item] = {}
|
||||
idx_dict[item]['file_name'] = os.path.basename(map_dict['url'][:-4])
|
||||
idx_dict[item]['menu_item'] = map_dict['perma_ref']
|
||||
idx_dict[item]['size'] = map_dict['size']
|
||||
idx_dict[item]['date'] = map_dict['date']
|
||||
idx_dict[item]['region'] = region
|
||||
idx_dict[item]['language'] = map_dict['perma_ref'][:2]
|
||||
|
||||
with open(osm_vector_idx_dir + '/osm_version_idx.json','w') as idx:
|
||||
idx.write(json.dumps(idx_dict,indent=2))
|
||||
|
||||
def create_menu_def(region,default_name,intended_use='map'):
|
||||
item = map_catalog['regions'][region]
|
||||
if len(item.get('language','')) > 2:
|
||||
lang = item['language'][:2]
|
||||
else: # default to english
|
||||
lang = 'en'
|
||||
filename = lang + '-' + item['perma_ref'] + '.json'
|
||||
# create a stub for this zim
|
||||
menuDef = {}
|
||||
default_logo = 'osm.jpg'
|
||||
menuDef["intended_use"] = "map"
|
||||
menuDef["lang"] = lang
|
||||
menuDef["logo_url"] = default_logo
|
||||
menuitem = lang + '-' + item['perma_ref']
|
||||
menuDef["menu_item_name"] = default_name
|
||||
menuDef["title"] = "OpenStreetMap: 18 Levels of Zoom for <b> " + item.get('title','ERROR') + '</b>'
|
||||
menuDef["map_name"] = item['perma_ref']
|
||||
menuDef["file_name"] = lang + '-osm-omt_' + region + '_' + \
|
||||
os.path.basename(item['url'])[:-4]
|
||||
menuDef["description"] = '<p>Resolution of the Whole World to 5 KM. OpenStreetMap data for <b>' + item.get('title','') + '</b> with details down to 5 Meters</p>'
|
||||
menuDef["extra_html"] = ""
|
||||
menuDef["automatically_generated"] = "true"
|
||||
if not os.path.isfile(menuDefs + default_name): # logic to here can still overwrite existing menu def
|
||||
print("creating %s"%menuDefs + default_name)
|
||||
with open(menuDefs + default_name,'w') as menufile:
|
||||
menufile.write(json.dumps(menuDef,indent=2))
|
||||
return default_name[:-5]
|
||||
|
||||
def human_readable(num):
|
||||
# return 3 significant digits and unit specifier
|
||||
num = float(num)
|
||||
units = [ '','K','M','G']
|
||||
for i in range(4):
|
||||
if num<10.0:
|
||||
return "%.2f%s"%(num,units[i])
|
||||
if num<100.0:
|
||||
return "%.1f%s"%(num,units[i])
|
||||
if num < 1000.0:
|
||||
return "%.0f%s"%(num,units[i])
|
||||
num /= 1000.0
|
||||
|
||||
def fetch_menu_json_value(key):
|
||||
with open( doc_root + '/home/menu.json','r') as menudef:
|
||||
data = json.loads(menudef.read())
|
||||
return data.get(key,'')
|
||||
|
||||
def extract_region_from_filename(fname):
|
||||
substitutions = { "north": "north_america",\
|
||||
"central": "central_america",\
|
||||
"southeast": "southeast_asia",
|
||||
"south": "south_america" }
|
||||
# wish I had used - as separator between key and date
|
||||
nibble = fname.split('_')[0]
|
||||
nibble = substitutions.get(nibble,nibble)
|
||||
return(nibble)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if console_installed:
|
||||
main()
|
57
roles/osm-vector/templates/index.html
Normal file
57
roles/osm-vector/templates/index.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Osm-Vector Splash Page</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Bootstrap -->
|
||||
<link href="/common/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src='/common/js/jquery.min.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<h2>Vector Maps Test Page -- Use The Admin Console to Download a Selected Region</h2>
|
||||
<p>The IIAB vector maps are based upon OpenStreetMap Data. Each map has general geographic information that covers the <b>whole world </b>with a resolution of about 5 KM. The detailed regions provide data about items that are 5 meters apart. </p>
|
||||
<div class="row">
|
||||
<div class="col-sm-12"><a href="/admin"><button id="INST-MODS" type="button" class="btn btn-lg btn-primary">Go To Admin Console</button></a></div>
|
||||
</div>
|
||||
|
||||
<div id="osmRegionSelection" >
|
||||
<style>
|
||||
#map-container{
|
||||
background-color: #b2d3f8;
|
||||
float: right;
|
||||
width: 70%;
|
||||
right: 10px;
|
||||
height: 500px;
|
||||
}
|
||||
body {
|
||||
padding: 40px;
|
||||
}
|
||||
</style>
|
||||
<div id="map-container"></div>
|
||||
|
||||
</div>
|
||||
<div id='regionlist'>placeholdr</div>
|
||||
</div> <!-- End instOsmRegion Submenu Option Pane -->
|
||||
<script>
|
||||
function readableSize(kbytes) {
|
||||
if (kbytes == 0)
|
||||
return "0";
|
||||
var bytes = 1024 * kbytes;
|
||||
var s = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'];
|
||||
var e = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
return (bytes / Math.pow(1024, e)).toFixed(2) + " " + s[e];
|
||||
}
|
||||
</script>
|
||||
<script src="/osm-vector/maplist/assets/osm_functions.js"></script>
|
||||
<script>
|
||||
window.$ = window.$ = jQuery;
|
||||
$.when(readOsmCatalog()).done(function() {
|
||||
renderRegionList(false);
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="/osm-vector/maplist/main.js"></script></body>
|
||||
</html>
|
89
roles/osm-vector/templates/main.js
Normal file
89
roles/osm-vector/templates/main.js
Normal file
|
@ -0,0 +1,89 @@
|
|||
import {Fill, Stroke, Style} from 'ol/style';
|
||||
import 'ol/ol.css';
|
||||
import GeoJSON from 'ol/format/GeoJSON';
|
||||
import Map from 'ol/Map';
|
||||
import VectorLayer from 'ol/layer/Vector';
|
||||
import VectorSource from 'ol/source/Vector';
|
||||
import View from 'ol/View';
|
||||
//import XYZSource from 'ol/source/XYZ';
|
||||
//import MVT from 'ol/format/MVT';
|
||||
|
||||
// a global variable to control which features are shown
|
||||
var show = {};
|
||||
var mapData = "/common/assets";
|
||||
|
||||
|
||||
var map = new Map({
|
||||
target: 'map-container',
|
||||
layers: [
|
||||
new VectorLayer({
|
||||
source: new VectorSource({
|
||||
format: new GeoJSON(),
|
||||
url: mapData + '/countries.json'
|
||||
}),
|
||||
style: new Style({
|
||||
fill: new Fill({
|
||||
color: 'rgb(219, 180, 131)'
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: 'white'
|
||||
})
|
||||
})
|
||||
}),
|
||||
|
||||
],
|
||||
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
})
|
||||
});
|
||||
|
||||
var setBoxStyle = function(feature) {
|
||||
var name = feature.get("name");
|
||||
//alert(keys+'');
|
||||
if (typeof show !== 'undefined' &&
|
||||
show != null && name == show) {
|
||||
return new Style({
|
||||
fill: new Fill({
|
||||
color: 'rgba(67, 163, 46, 0.2)'
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: 'rgba(67, 163, 46, 1)',
|
||||
width: 2
|
||||
})
|
||||
})
|
||||
} else {
|
||||
return new Style({
|
||||
fill: new Fill({
|
||||
color: 'rgba(255,255,255,.10)'
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: 'rgba(255,255,255,.3)'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var boxLayer = new VectorLayer({
|
||||
source: new VectorSource({
|
||||
format: new GeoJSON(),
|
||||
url: mapData + '/bboxes.geojson'
|
||||
}),
|
||||
id: 'boxes',
|
||||
style: setBoxStyle
|
||||
});
|
||||
map.addLayer(boxLayer);
|
||||
|
||||
$( document ).on("mouseover",".extract",function(){
|
||||
|
||||
var data = JSON.parse($(this).attr('data-region'));
|
||||
show = data.name;
|
||||
//setBoxStyle();
|
||||
boxLayer.changed();
|
||||
});
|
||||
$( document ).on("mouseout",".extract",function(){
|
||||
var data = JSON.parse($(this).attr('data-region'));
|
||||
show = '';
|
||||
boxLayer.changed();
|
||||
});
|
8
roles/osm-vector/templates/osm-vector.conf
Normal file
8
roles/osm-vector/templates/osm-vector.conf
Normal file
|
@ -0,0 +1,8 @@
|
|||
# For downloadable regional vector tilesets
|
||||
Alias /maps {{ osm_vector_path }}
|
||||
Alias /osm-vector {{ osm_vector_path }}
|
||||
<Directory {{ osm_vector_path }}>
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
CURR_VER="undefined" # Ansible version you currently have installed
|
||||
GOOD_VER="2.7.9" # For XO laptops (pip install) & CentOS (yum install rpm)
|
||||
GOOD_VER="2.7.10" # For XO laptops (pip install) & CentOS (yum install rpm)
|
||||
# On other OS's we attempt the latest from PPA, which might be more recent
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
CURR_VER="undefined" # Ansible version you currently have installed
|
||||
GOOD_VER="2.7.9" # For XO laptops (pip install) & CentOS (yum install rpm)
|
||||
GOOD_VER="2.7.10" # For XO laptops (pip install) & CentOS (yum install rpm)
|
||||
# On other OS's we attempt the latest from PPA, which might be more recent
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
CURR_VER="undefined" # Ansible version you currently have installed
|
||||
GOOD_VER="2.7.9" # For XO laptops (pip install) & CentOS (yum install rpm)
|
||||
GOOD_VER="2.7.10" # For XO laptops (pip install) & CentOS (yum install rpm)
|
||||
# On other OS's we attempt the latest from PPA, which might be more recent
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
|
|
@ -15,6 +15,7 @@ pip_packages_dir: "{{ iiab_base }}/pip-packages"
|
|||
yum_packages_dir: "{{ iiab_base }}/yum-packages"
|
||||
downloads_dir: "{{ iiab_base }}/downloads"
|
||||
iiab_download_url: http://download.iiab.io/packages
|
||||
iiab_osm_url : http://download.iiab.io/content/OSM/vector-tiles/maplist/hidden
|
||||
|
||||
content_base: "/library"
|
||||
doc_base: "{{ content_base }}/www"
|
||||
|
@ -350,6 +351,11 @@ mongodb_install: False
|
|||
mongodb_enabled: False
|
||||
mongodb_port: 27018
|
||||
|
||||
# Regional OSM vector maps use much less disk space than bitmap/raster versions
|
||||
osm_vector_install: True
|
||||
osm_vector_enabled: True
|
||||
osm_vector_path: '{{ content_base }}/www/osm-vector'
|
||||
|
||||
# roles/sugarizer/meta/main.yml auto-invokes 2 above prereqs: mongodb & nodejs
|
||||
# Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879
|
||||
# Sugarizer 1.0.1+ strategies to solve? github.com/iiab/iiab/pull/957
|
||||
|
|
|
@ -229,6 +229,10 @@ moodle_install: True
|
|||
moodle_enabled: True
|
||||
# If using Moodle intensively, set apache_high_php_limits in 3-BASE-SERVER
|
||||
|
||||
# Regional OSM vector maps use much less disk space than bitmap/raster versions
|
||||
osm_vector_install: True
|
||||
osm_vector_enabled: True
|
||||
|
||||
# Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879
|
||||
# Sugarizer 1.0.1+ strategies to solve? github.com/iiab/iiab/pull/957
|
||||
sugarizer_install: True
|
||||
|
|
|
@ -229,6 +229,10 @@ moodle_install: False
|
|||
moodle_enabled: False
|
||||
# If using Moodle intensively, set apache_high_php_limits in 3-BASE-SERVER
|
||||
|
||||
# Regional OSM vector maps use much less disk space than bitmap/raster versions
|
||||
osm_vector_install: True
|
||||
osm_vector_enabled: True
|
||||
|
||||
# Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879
|
||||
# Sugarizer 1.0.1+ strategies to solve? github.com/iiab/iiab/pull/957
|
||||
sugarizer_install: True
|
||||
|
|
|
@ -229,6 +229,10 @@ moodle_install: False
|
|||
moodle_enabled: False
|
||||
# If using Moodle intensively, set apache_high_php_limits in 3-BASE-SERVER
|
||||
|
||||
# Regional OSM vector maps use much less disk space than bitmap/raster versions
|
||||
osm_vector_install: True
|
||||
osm_vector_enabled: True
|
||||
|
||||
# Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879
|
||||
# Sugarizer 1.0.1+ strategies to solve? github.com/iiab/iiab/pull/957
|
||||
sugarizer_install: False
|
||||
|
|
|
@ -23,8 +23,8 @@ apache_log: /var/log/apache2/access.log
|
|||
sshd_package: openssh-server
|
||||
sshd_service: ssh
|
||||
php_version: 7.2
|
||||
# "postgresql_version: 10.3" fails (too detailed for /etc/systemd/system/postgresql-iiab.service on Ubuntu 18.04)
|
||||
postgresql_version: 10
|
||||
# "postgresql_version: 11.2" fails (too detailed for /etc/systemd/system/postgresql-iiab.service on Ubuntu 19.04)
|
||||
postgresql_version: 11
|
||||
systemd_location: /lib/systemd/system
|
||||
# Upgrade Ubuntu 19.x's Calibre 3.39.1+ to very latest
|
||||
calibre_via_debs: False
|
||||
|
|
Loading…
Reference in a new issue