diff --git a/roles/4-server-options/tasks/main.yml b/roles/4-server-options/tasks/main.yml index 4c56b0572..8974085e3 100644 --- a/roles/4-server-options/tasks/main.yml +++ b/roles/4-server-options/tasks/main.yml @@ -13,6 +13,12 @@ when: named_install tags: base, named, network, domain +- name: Installing vector map test page + include_role: + name: osm-vector-maps + when: osm_vector_maps_install + tags: base, map + - name: Installing captive portal include_tasks: roles/captive-portal/tasks/main.yml when: captive_portal_install diff --git a/roles/lokole/defaults/main.yml b/roles/lokole/defaults/main.yml index 0fdda9872..bc8a1ca9c 100644 --- a/roles/lokole/defaults/main.yml +++ b/roles/lokole/defaults/main.yml @@ -5,7 +5,7 @@ # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! # Info needed to install Lokole -lokole_version: 0.1.41 +lokole_version: 0.1.39 lokole_admin_user: admin # lowercase seems nec here (even though uppercase Admin/changeme is IIAB's OOB recommendation!) lokole_admin_password: changeme lokole_install_path: "{{ content_base }}/lokole" # /library/lokole diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index c5677dde1..f783a86c7 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -40,7 +40,7 @@ wondershaper_upspeed: "1024" # Wi-Fi host_ssid: IIAB -hostapd_wait: 1 +hostapd_wait: 5 host_wifi_mode: g host_channel: 6 host_wireless_n: False diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index eb22b8e5a..fd9ee0d49 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -53,7 +53,7 @@ creates: /etc/sysconfig/olpc-scripts/setup.d/installed/gateway when: iiab_network_mode == "Gateway" -- name: Waiting {{ hostapd_wait }} seconds for network to stabilize +- name: Waiting {{ hostapd_wait }} seconds for network to stabilize (iiap-gen-iptables will fail if dnsmasq isn't ready!) shell: sleep {{ hostapd_wait }} - name: Run /usr/bin/iiab-gen-iptables diff --git a/roles/openvpn/defaults/main.yml b/roles/openvpn/defaults/main.yml index e29db28d8..adc23ec2b 100644 --- a/roles/openvpn/defaults/main.yml +++ b/roles/openvpn/defaults/main.yml @@ -1,12 +1,15 @@ -openvpn_install: True -openvpn_enable: False +# openvpn_install: True +# openvpn_enabled: False # For /etc/iiab/openvpn_handle -openvpn_handle: "" +# openvpn_handle: "" # cron seems necessary on CentOS: -openvpn_cron_enabled: False +# openvpn_cron_enabled: False -openvpn_server: xscenet.net -openvpn_server_virtual_ip: 10.8.0.1 -openvpn_server_port: 1194 +# openvpn_server: xscenet.net +# openvpn_server_virtual_ip: 10.8.0.1 +# openvpn_server_port: 1194 + +# 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! diff --git a/roles/osm-vector-maps/defaults/main.yml b/roles/osm-vector-maps/defaults/main.yml new file mode 100644 index 000000000..07882b688 --- /dev/null +++ b/roles/osm-vector-maps/defaults/main.yml @@ -0,0 +1,8 @@ +osm_vector_maps_install: True +osm_vector_maps_enabled: True +vector_map_path: '{{ content_base }}/www/osm-vector-maps' + +# 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! + +iiab_map_url : http://download.iiab.io/content/OSM/vector-tiles/maplist/hidden diff --git a/roles/osm-vector/files/countries.json b/roles/osm-vector-maps/files/countries.json similarity index 100% rename from roles/osm-vector/files/countries.json rename to roles/osm-vector-maps/files/countries.json diff --git a/roles/osm-vector/files/en-map_test.json b/roles/osm-vector-maps/files/en-map_test.json similarity index 100% rename from roles/osm-vector/files/en-map_test.json rename to roles/osm-vector-maps/files/en-map_test.json diff --git a/roles/osm-vector/files/osm_functions.js b/roles/osm-vector-maps/files/map_functions.js similarity index 79% rename from roles/osm-vector/files/osm_functions.js rename to roles/osm-vector-maps/files/map_functions.js index 819b76ee1..23ab66746 100644 --- a/roles/osm-vector/files/osm_functions.js +++ b/roles/osm-vector-maps/files/map_functions.js @@ -1,16 +1,16 @@ -// osm_functions.js -- (non authoritative see below) src = iiab/roles/files/ +// map_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 +// CAUTION -- this file is duplicate to admin-console/console/files/js/map_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 mapAssetsDir = '/osm-vector-maps/maplist/assets/'; var iiab_config_dir = '/etc/iiab/'; var onChangeFunc = "setSize"; -var osmCatalog = {}; +var mapCatalog = {}; // following 2 lines an experiment to see if test page and console can be common //var jquery = require("./assets/jquery.min"); @@ -19,7 +19,7 @@ var osmCatalog = {}; function getOsmStat(){ // called during the init console.log('in getOsmStat'); - readOsmCatalog( true ); // we want checkboxes + readMapCatalog( true ); // we want checkboxes readOsmIdx(); } @@ -27,25 +27,25 @@ function readOsmIdx(){ //consoleLog ("in readOsmIdx"); var resp = $.ajax({ type: 'GET', - url: consoleJsonDir + 'osm-vector-idx.json', + url: consoleJsonDir + 'osm-vector-maps-idx.json', dataType: 'json' }) .done(function( data ) { - osmInstalled = data['regions']; + mapInstalled = data['regions']; regionInstalled = []; for (region in data['regions']) { if (data['regions'].hasOwnProperty(region)) { regionInstalled.push(region); } } - //consoleLog(osmInstalled + ''); + //consoleLog(mapInstalled + ''); }) .fail(jsonErrhandler); return resp; } -function readOsmCatalog(checkbox){ +function readMapCatalog(checkbox){ checkbox = checkbox || true; console.log ("in readOsmCalalog"); regionList = []; @@ -56,11 +56,11 @@ function readOsmCatalog(checkbox){ }) .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]); + mapCatalog = regionJson['regions']; + for(var key in mapCatalog){ + //console.log(key + ' ' + mapCatalog[key]['title']); + mapCatalog[key]['name'] = key; + regionList.push(mapCatalog[key]); } }) .fail(jsonErrhandler); @@ -120,13 +120,13 @@ function genRegionItem(region,checkbox) { function instOsmItem(name) { var command = "INST-OSM-VECT-SET"; var cmd_args = {}; - cmd_args['osm_vect_id'] = name; + cmd_args['map_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); + mapDownloading.push(name); + if ( mapWip.indexOf(name) != -1 ) + mapWip.push(mapCatalog[name]); + console.log('mapWip: ' + mapWip); return true; } @@ -161,19 +161,19 @@ function updateOsmSpace(cb){ } function updateOsmSpaceUtil(region, checked){ - var size = parseInt(osmCatalog[region].size); + var size = parseInt(mapCatalog[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; + sysStorage.map_selected_size += size; selectedOsmItems.push(region); } } else { if (modIdx != -1){ - sysStorage.osm_selected_size -= size; + sysStorage.map_selected_size -= size; selectedOsmItems.splice(modIdx, 1); } } @@ -188,29 +188,29 @@ function totalSpace(){ $( ".extract" ).each(function(ind,elem){ var data = JSON.parse($(this).attr('data-region')); var region = data.name; - var size = parseInt(osmCatalog[region]['size']); + var size = parseInt(mapCatalog[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)); + $( "#mapDiskSpace" ).html(readableSize(ksize)); } $( '#instOsmRegion').on('click', function(evnt){ - readOsmCatalog(); - osm.render(); + readMapCatalog(); + map.render(); }); */ function renderOsm(){ console.log('in renderOsm'); - window.map.setTarget($("#osm-container")[0]); + window.map.setTarget($("#map-container")[0]); window.map.render(); renderRegionList(true); } function initOsm(){ var dummy = 0; - sysStorage.osm_selected_size = 0; - $.when(readOsmCatalog(true)).then(renderRegionList); + sysStorage.map_selected_size = 0; + $.when(readMapCatalog(true)).then(renderRegionList); } diff --git a/roles/osm-vector-maps/files/test-index.redirect b/roles/osm-vector-maps/files/test-index.redirect new file mode 100644 index 000000000..9ad3694cc --- /dev/null +++ b/roles/osm-vector-maps/files/test-index.redirect @@ -0,0 +1,4 @@ +
+ + + diff --git a/roles/osm-vector-maps/tasks/main.yml b/roles/osm-vector-maps/tasks/main.yml new file mode 100644 index 000000000..ca3cd9276 --- /dev/null +++ b/roles/osm-vector-maps/tasks/main.yml @@ -0,0 +1,84 @@ +- name: Make sure the osm-vector-maps directory exists + file: + path: '{{ vector_map_path }}/maplist/assets' + state: directory + owner: '{{ apache_user }}' + group: '{{ apache_user }}' + mode: '0755' + +- name: Fetch the catalog for osm maps + get_url: + url: "{{ iiab_map_url }}/assets/regions.json" + dest: '{{ vector_map_path }}/maplist/assets/' + +- name: Create a link to osm catalog in /common/assets + file: + src: "{{ vector_map_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_map_url }}/../main.js" + dest: '{{ vector_map_path }}/maplist/' + +- name: Fetch the index.html for test page + template: + src: "index.html" + dest: '{{ vector_map_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_map_url }}/assets/bboxes.geojson" + dest: '{{ vector_map_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-map + dest: /usr/bin/iiab-update-map + mode: "0755" + +- name: Run the script that does osm-vector-maps housekeeping + shell: /usr/bin/iiab-update-map + +- name: Copy the Countries geojson to assets + copy: + src: countries.json + dest: '{{ vector_map_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: map_functions.js + dest: '{{ vector_map_path }}/maplist/assets' + +- name: Install /etc/{{ apache_config_dir }}/osm-vector-maps.conf from template + template: + src: osm-vector-maps.conf + dest: "/etc/{{ apache_config_dir }}/osm-vector-maps.conf" + +- name: Create symlink osm-vector-maps.conf from sites-enabled to sites-available (debuntu, not nec for redhat) + file: + src: /etc/apache2/sites-available/osm-vector-maps.conf + path: /etc/apache2/sites-enabled/osm-vector-maps.conf + state: link + when: osm_vector_maps_enabled and is_debuntu + +- name: Remove symlink /etc/apache2/sites-enabled/osm-vector-maps.conf (debuntu) + file: + path: /etc/apache2/sites-enabled/osm-vector-maps.conf + state: absent + when: not osm_vector_maps_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: "{{ vector_map_path }}/index.html" + diff --git a/roles/osm-vector/templates/iiab-update-osm b/roles/osm-vector-maps/templates/iiab-update-map similarity index 94% rename from roles/osm-vector/templates/iiab-update-osm rename to roles/osm-vector-maps/templates/iiab-update-map index 8d8758e21..23a5869c3 100755 --- a/roles/osm-vector/templates/iiab-update-osm +++ b/roles/osm-vector-maps/templates/iiab-update-map @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Scan the osm-vector directory, update the osm-vector-idx.json, add menu-defs +# Scan the osm-vector-maps directory, update the osm-vector-maps-idx.json, add menu-defs from geojson import Feature, Point, FeatureCollection, Polygon import geojson @@ -25,9 +25,9 @@ else: 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' +vector_map_idx_dir = doc_root + "/common/assets" +#map_doc_root = '{{ vector_map_path }}' +map_doc_root = '/library/www/osm-vector-maps' # map_catalog will be global, assumed always available map_catalog = {} map_menu_def_list = [] @@ -43,7 +43,7 @@ def main(): installed_maps = get_installed_regions() print(installed_maps) - write_osm_vector_idx(installed_maps) + write_vector_map_idx(installed_maps) # For installed regions, check that a menu def exists, and it's on home page for fname in installed_maps: @@ -106,7 +106,7 @@ def get_installed_regions(): installed.append('maplist') return installed -def write_osm_vector_idx(installed_maps): +def write_vector_map_idx(installed_maps): map_dict ={} idx_dict = {} for fname in installed_maps: @@ -125,7 +125,7 @@ def write_osm_vector_idx(installed_maps): 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: + with open(vector_map_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'): diff --git a/roles/osm-vector/templates/index.html b/roles/osm-vector-maps/templates/index.html similarity index 89% rename from roles/osm-vector/templates/index.html rename to roles/osm-vector-maps/templates/index.html index ee7592eea..62615ae84 100644 --- a/roles/osm-vector/templates/index.html +++ b/roles/osm-vector-maps/templates/index.html @@ -46,12 +46,12 @@ return (bytes / Math.pow(1024, e)).toFixed(2) + " " + s[e]; } - + -