mirror of
https://github.com/iiab/iiab.git
synced 2025-02-15 04:32:11 +00:00
commit
2259eb8b4e
4 changed files with 67 additions and 25 deletions
|
@ -1,4 +1,3 @@
|
|||
---
|
||||
- hosts: all
|
||||
become: yes
|
||||
|
||||
|
@ -10,5 +9,5 @@
|
|||
roles:
|
||||
- { role: 0-init, tags: ['0-init'] }
|
||||
#- { role: 1-prep, tags: ['1-prep', 'platform', 'base'] }
|
||||
- { role: 1-prep, tags: ['1-prep'] }
|
||||
#- { role: openvpn, tags: ['openvpn'] } # no longer nec, as 1-prep calls role openvpn (2018-09-19)
|
||||
#- { role: 1-prep, tags: ['1-prep'] }
|
||||
- { role: openvpn, tags: ['openvpn'] }
|
||||
|
|
|
@ -12,7 +12,22 @@ if [ ! -f $PLAYBOOK ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
sed -i -e "s/openvpn_install: False/openvpn_install: True/" /etc/iiab/local_vars.yml
|
||||
sed -i -e "s/openvpn_enabled: False/openvpn_enabled: True/" /etc/iiab/local_vars.yml
|
||||
echo -en "\n\nWhat OpenVPN machine name (openvpn_handle) do you want? "
|
||||
read ans < /dev/tty
|
||||
if [ "$ans" != "" ]; then
|
||||
sed -i -e "s/^openvpn_handle:.*/openvpn_handle: $ans/" /etc/iiab/local_vars.yml
|
||||
echo -e "\nYour machine's openvpn_handle is now set, in /etc/iiab/local_vars.yml\n"
|
||||
else
|
||||
echo -e "\nWARNING: openvpn_handle remains unchanged in /etc/iiab/local_vars.yml\n"
|
||||
fi
|
||||
|
||||
sed -i -e "s/^openvpn_install:.*/openvpn_install: True/" /etc/iiab/local_vars.yml
|
||||
sed -i -e "s/^openvpn_enabled:.*/openvpn_enabled: True/" /etc/iiab/local_vars.yml
|
||||
|
||||
echo -e "Now let's (re)install and (re)start OpenVPN...\n"
|
||||
|
||||
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local
|
||||
|
||||
echo -en "\nYour OpenVPN handle is....... "
|
||||
cat /etc/iiab/openvpn_handle
|
||||
echo -e "\nYour OpenVPN IP address is... $(ip a | grep tun0$ | awk '{print $2}')\n\n"
|
||||
|
|
|
@ -1,20 +1,45 @@
|
|||
#!/bin/bash
|
||||
# DEPRECATED interactive script (over)writes /etc/iiab/openvpn_handle file, identifying client to server
|
||||
|
||||
echo -e '\nCORRECT METHOD: CHANGE VARIABLE openvpn_handle IN /etc/iiab/local_vars.yml'
|
||||
echo -e 'THEN RUN "cd /opt/iiab/iiab" THEN "./runrole openvpn"\n'
|
||||
|
||||
echo -e "Or, for a temporary solution until the next time Ansible is run,"
|
||||
read -p "what OpenVPN handle do you want to use? " ans
|
||||
echo -e '\n\nDEPRECATED:\n'
|
||||
|
||||
echo -e 'This interactive script TEMPORARILY (over)writes /etc/iiab/openvpn_handle'
|
||||
echo -e 'to identify IIAB to the upstream OpenVPN server, until Ansible next runs.\n\n'
|
||||
|
||||
|
||||
echo -e 'PLEASE USE THIS NEW METHOD INSTEAD:\n'
|
||||
|
||||
echo -e 'cd /opt/iiab/iiab'
|
||||
echo -e 'sudo ./install-support\n\n'
|
||||
|
||||
|
||||
#echo -e 'CORRECT METHOD: CHANGE VARIABLE openvpn_handle IN /etc/iiab/local_vars.yml'
|
||||
#echo -e 'THEN RUN "cd /opt/iiab/iiab" THEN "./runrole openvpn"\n'
|
||||
|
||||
echo -e 'PLEASE NOW TYPE CTRL-C TO QUIT. Or, if you really want it temporary until the'
|
||||
read -p 'next time Ansible is run, what OpenVPN handle do you want? ' ans
|
||||
echo
|
||||
|
||||
if [ "$ans" == "" ]; then
|
||||
if [ -f /etc/iiab/openvpn_handle ]; then
|
||||
rm -f /etc/iiab/openvpn_handle
|
||||
fi
|
||||
else
|
||||
|
||||
if [ "$ans" != "" ]; then
|
||||
echo $ans > /etc/iiab/openvpn_handle
|
||||
echo -e "\nYour machine's openvpn_handle is TEMPORARILY now set... \n"
|
||||
else
|
||||
echo -e "\nWARNING: your machine's openvpn_handle remains unchanged...\n"
|
||||
fi
|
||||
|
||||
echo -e "Restarting OpenVPN daemon...\n\n"
|
||||
|
||||
# 2019-05-09: removing /etc/iiab/openvpn_handle (or setting it to "") are both very bad practices
|
||||
#if [ "$ans" == "" ]; then
|
||||
# if [ -f /etc/iiab/openvpn_handle ]; then
|
||||
# rm -f /etc/iiab/openvpn_handle
|
||||
# fi
|
||||
#else
|
||||
# echo $ans > /etc/iiab/openvpn_handle
|
||||
#fi
|
||||
|
||||
|
||||
{{ systemctl_program }} restart openvpn@xscenet
|
||||
# This would also work: (but would bounce all VPN connections, if others exist, causing unnec disruption if so)
|
||||
#{{ systemctl_program }} restart openvpn
|
||||
|
|
|
@ -8,6 +8,7 @@ import os
|
|||
import sys
|
||||
import fnmatch
|
||||
import re
|
||||
from datetime import date
|
||||
|
||||
IIAB_PATH='/etc/iiab'
|
||||
if not IIAB_PATH in sys.path:
|
||||
|
@ -36,7 +37,7 @@ 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))
|
||||
|
||||
|
@ -76,7 +77,7 @@ def get_map_catalog():
|
|||
#print(json.dumps(map_catalog,indent=2))
|
||||
|
||||
def get_menu_def_names(intended_use='map'):
|
||||
menu_def_list =[]
|
||||
menu_def_list =[]
|
||||
os.chdir(menuDefs)
|
||||
for filename in os.listdir('.'):
|
||||
if fnmatch.fnmatch(filename, '*.json'):
|
||||
|
@ -107,7 +108,7 @@ def get_installed_regions():
|
|||
return installed
|
||||
|
||||
def write_vector_map_idx(installed_maps):
|
||||
map_dict ={}
|
||||
map_dict ={}
|
||||
idx_dict = {}
|
||||
for fname in installed_maps:
|
||||
region = extract_region_from_filename(fname)
|
||||
|
@ -117,7 +118,7 @@ def write_vector_map_idx(installed_maps):
|
|||
|
||||
# Create the idx file in format required bo js-menu system
|
||||
item = map_dict['perma_ref']
|
||||
idx_dict[item] = {}
|
||||
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']
|
||||
|
@ -125,8 +126,8 @@ def write_vector_map_idx(installed_maps):
|
|||
idx_dict[item]['region'] = region
|
||||
idx_dict[item]['language'] = map_dict['perma_ref'][:2]
|
||||
|
||||
with open(vector_map_idx_dir + '/osm_version_idx.json','w') as idx:
|
||||
idx.write(json.dumps(idx_dict,indent=2))
|
||||
with open(vector_map_idx_dir + '/vector-map-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]
|
||||
|
@ -145,11 +146,13 @@ def create_menu_def(region,default_name,intended_use='map'):
|
|||
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]
|
||||
# the following is in the idx json
|
||||
#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"
|
||||
#menuDef["automatically_generated"] = "true"
|
||||
menuDef["change_ref"] = "generated"
|
||||
menuDef["change_date"] = str(date.today())
|
||||
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:
|
||||
|
@ -183,7 +186,7 @@ def extract_region_from_filename(fname):
|
|||
nibble = fname.split('_')[0]
|
||||
nibble = substitutions.get(nibble,nibble)
|
||||
return(nibble)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if console_installed:
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue