mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	rm 25 *.deprecated files/dirs
This commit is contained in:
		
							parent
							
								
									2a63ca5bd6
								
							
						
					
					
						commit
						cb1a708abb
					
				
					 25 changed files with 0 additions and 2078 deletions
				
			
		| 
						 | 
				
			
			@ -1,13 +0,0 @@
 | 
			
		|||
- hosts: all
 | 
			
		||||
  become: yes
 | 
			
		||||
 | 
			
		||||
  vars_files:
 | 
			
		||||
  - vars/default_vars.yml
 | 
			
		||||
  - vars/{{ ansible_local.local_facts.os_ver }}.yml
 | 
			
		||||
  - /etc/iiab/local_vars.yml
 | 
			
		||||
 | 
			
		||||
  roles:
 | 
			
		||||
    - { role: 0-init, tags: ['0-init'] }
 | 
			
		||||
    - { role: sshd, tags: ['sshd'] }
 | 
			
		||||
    - { role: iiab-admin, tags: ['iiab-admin'] }
 | 
			
		||||
    - { role: openvpn, tags: ['openvpn'] }
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +0,0 @@
 | 
			
		|||
MAILTO=root
 | 
			
		||||
 | 
			
		||||
*/10 * * * * www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh
 | 
			
		||||
 | 
			
		||||
# Generate static reports:
 | 
			
		||||
10 03 * * * www-data [ -x /usr/share/awstats/tools/buildstatic.sh ] && /usr/share/awstats/tools/buildstatic.sh
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
# For new vector tileset, as documented @ http://FAQ.IIAB.IO ("How do I add zoomable maps for my region? ") & http://download.iiab.io/content/OSM/vector-tiles/
 | 
			
		||||
Alias /maps /library/www/html/modules/en-osm-omt-min/
 | 
			
		||||
Alias /osm /library/www/html/modules/en-osm-omt-min/
 | 
			
		||||
| 
						 | 
				
			
			@ -1,8 +0,0 @@
 | 
			
		|||
# Configuration file for the httpd service.
 | 
			
		||||
# earlier XS httpd passed memory size as command line variable
 | 
			
		||||
# systemd requires that this be done at setup time in httpd.conf
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
OPTIONS=" -f conf/httpd-xs.conf 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
apache ALL=NOPASSWD: /usr/sbin/iptables-save,/usr/sbin/fdisk,/usr/bin/xs-flashbench,/usr/bin/xs-acpowergaps,/root/xs-apply-changes,/usr/bin/xs-regenerate-activities,/bin/mount,/bin/ls,/bin/df,/bin/cat,/bin/systemctl
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
apache ALL=NOPASSWD: /usr/sbin/iptables-save,/usr/sbin/fdisk,/usr/bin/xs-flashbench,/usr/bin/xs-acpowergaps,/root/xs-apply-changes,/usr/bin/xs-regenerate-activities,/bin/mount,/bin/ls,/bin/df,/bin/cat,/bin/systemctl
 | 
			
		||||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
Alias /info/ {{ iiab_dir }}/docs/html/
 | 
			
		||||
Alias /info {{ iiab_dir }}/docs/html/
 | 
			
		||||
 | 
			
		||||
<directory {{ iiab_dir }}/docs/html>
 | 
			
		||||
   Options +Indexes
 | 
			
		||||
   IndexOptions FancyIndexing
 | 
			
		||||
   IndexOptions HTMLTable
 | 
			
		||||
   IndexOptions SuppressColumnsorting
 | 
			
		||||
   IndexOptions Charset=UTF-8
 | 
			
		||||
   Require all granted
 | 
			
		||||
</directory>
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,14 +0,0 @@
 | 
			
		|||
# This is for an OS other than Fedora 18
 | 
			
		||||
 | 
			
		||||
# The stock install puts a small /library/ka-lite/content/assessmentitems.sqlite file, so use size instead of exists
 | 
			
		||||
- name: See if assessment is already installed
 | 
			
		||||
  stat: path="{{ kalite_root }}/content/assessment/khan/assessmentitems.sqlite"
 | 
			
		||||
  register: khan_assessment_installed
 | 
			
		||||
 | 
			
		||||
- name: Run the assessment setup using kalite manage
 | 
			
		||||
  command: "{{ kalite_program }} manage unpack_assessment_zip {{ downloads_dir }}/khan_assessment.zip"
 | 
			
		||||
  environment:
 | 
			
		||||
    KALITE_HOME: "{{ kalite_root }}"
 | 
			
		||||
  async: 900
 | 
			
		||||
  poll: 10
 | 
			
		||||
  when: not khan_assessment_installed.stat.exists or khan_assessment_installed.stat.size < 20000
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
from kalite.project.settings.base import *
 | 
			
		||||
LANGUAGE_CODE = "{{ default_language }}"
 | 
			
		||||
ASSESSMENT_ITEMS_ZIP_URL = "scheme://{{ downloads_dir }}/khan_assessment.zip"
 | 
			
		||||
| 
						 | 
				
			
			@ -1,326 +0,0 @@
 | 
			
		|||
#!/usr/bin/python3
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
   Creates temp library.xml file for kiwix from contents of /zims/content and index
 | 
			
		||||
   Updated to handle incremental additions and deletions
 | 
			
		||||
 | 
			
		||||
   Author: Tim Moody <tim(at)timmoody(dot)com>
 | 
			
		||||
   Contributors: Jerry Vonau <jvonau3(at)gmail.com>
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import os, sys, syslog
 | 
			
		||||
import pwd, grp
 | 
			
		||||
import time
 | 
			
		||||
from datetime import date, datetime
 | 
			
		||||
import json
 | 
			
		||||
import yaml
 | 
			
		||||
import re
 | 
			
		||||
import subprocess
 | 
			
		||||
import shlex
 | 
			
		||||
#import ConfigParser
 | 
			
		||||
import configparser
 | 
			
		||||
import xml.etree.ElementTree as ET
 | 
			
		||||
import argparse
 | 
			
		||||
import fnmatch
 | 
			
		||||
 | 
			
		||||
IIAB_PATH='/etc/iiab'
 | 
			
		||||
if not IIAB_PATH in sys.path:
 | 
			
		||||
    sys.path.append(IIAB_PATH)
 | 
			
		||||
from iiab_env import get_iiab_env
 | 
			
		||||
KIWIX_CAT = IIAB_PATH + '/kiwix_catalog.json'
 | 
			
		||||
 | 
			
		||||
# Config Files
 | 
			
		||||
# iiab_ini_file should be in {{ iiab_env_file }} (/etc/iiab/iiab.env) ?
 | 
			
		||||
#iiab_ini_file = "{{ iiab_ini_file }}" # nominally /etc/iiab/iiab.ini
 | 
			
		||||
iiab_ini_file = "/etc/iiab/iiab.ini" # comment out after testing
 | 
			
		||||
 | 
			
		||||
IIAB_INI = get_iiab_env('IIAB_INI') # future
 | 
			
		||||
if IIAB_INI:
 | 
			
		||||
    iiab_ini_file = IIAB_INI
 | 
			
		||||
 | 
			
		||||
# Variables that should be read from config file
 | 
			
		||||
# All of these variables will be read from config files and recomputed in init()
 | 
			
		||||
zim_path = "/library/zims"
 | 
			
		||||
 | 
			
		||||
iiab_base_path = "/opt/iiab"
 | 
			
		||||
kiwix_manage = iiab_base_path + "/kiwix/bin/kiwix-manage"
 | 
			
		||||
doc_root = get_iiab_env('WWWROOT')
 | 
			
		||||
zim_version_idx_dir = doc_root + "/common/assets/"
 | 
			
		||||
zim_version_idx_file = "zim_version_idx.json"
 | 
			
		||||
#zim_version_idx_file = "zim_version_idx_test.json"
 | 
			
		||||
menuDefs = doc_root + "/js-menu/menu-files/menu-defs/"
 | 
			
		||||
menuImages = doc_root + "/js-menu/menu-files/images/"
 | 
			
		||||
menuJsonPath = doc_root + "/home/menu.json"
 | 
			
		||||
 | 
			
		||||
assets_dir = doc_root + "/common/assets/"
 | 
			
		||||
lang_codes_path = assets_dir + "lang_codes.json"
 | 
			
		||||
lang_codes = {}
 | 
			
		||||
old_zim_map = {"bad.zim" : "unparseable name"}
 | 
			
		||||
 | 
			
		||||
# Working variables
 | 
			
		||||
# zim_files - list of zims and possible index from file system
 | 
			
		||||
# path_to_id_map - list of zims in current library.xml with id (for delete)
 | 
			
		||||
zim_versions = {} # map of zim's generic name to version installed, e.g. wikipedia_es_all to wikipedia_es_all_2017-01
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    """Server routine"""
 | 
			
		||||
    global kiwix_library_xml
 | 
			
		||||
    global zim_path
 | 
			
		||||
    global zim_version_idx_dir
 | 
			
		||||
    global zim_version_idx_file
 | 
			
		||||
 | 
			
		||||
    init()
 | 
			
		||||
    args = parse_args()
 | 
			
		||||
    if args.device: # allow override of path
 | 
			
		||||
        zim_path = args.device + zim_path
 | 
			
		||||
        zim_version_idx_dir = args.device + zim_version_idx_dir
 | 
			
		||||
 | 
			
		||||
    kiwix_library_xml = zim_path + "/library.xml"
 | 
			
		||||
    if not args.no_tmp: # don't append .tmp
 | 
			
		||||
        kiwix_library_xml += ".tmp"
 | 
			
		||||
 | 
			
		||||
    # remove existing file if force
 | 
			
		||||
    if args.force:
 | 
			
		||||
        try:
 | 
			
		||||
            os.remove(kiwix_library_xml)
 | 
			
		||||
        except OSError:
 | 
			
		||||
            pass
 | 
			
		||||
        zims_installed = {}
 | 
			
		||||
        path_to_id_map = {}
 | 
			
		||||
    else:
 | 
			
		||||
          zims_installed, path_to_id_map = read_library_xml(kiwix_library_xml)
 | 
			
		||||
 | 
			
		||||
    zim_files = get_zim_list(zim_path)
 | 
			
		||||
 | 
			
		||||
    # Remove zims not in file system from library.xml
 | 
			
		||||
    remove_list_str = ""
 | 
			
		||||
    for item in path_to_id_map:
 | 
			
		||||
        if item not in zim_files:
 | 
			
		||||
            rem_libr_xml(path_to_id_map[item])
 | 
			
		||||
 | 
			
		||||
    # Add zims from file system that are not in library.xml
 | 
			
		||||
    for item in zim_files:
 | 
			
		||||
          if item not in path_to_id_map:
 | 
			
		||||
              add_libr_xml(kiwix_library_xml, zim_path, item, zim_files[item])
 | 
			
		||||
 | 
			
		||||
    print("Writing zim_versions_idx")
 | 
			
		||||
    write_zim_versions_idx()
 | 
			
		||||
    sys.exit()
 | 
			
		||||
 | 
			
		||||
def get_zim_list(path):
 | 
			
		||||
    files_processed = {}
 | 
			
		||||
    zim_list = []
 | 
			
		||||
    content = path + "/content/"
 | 
			
		||||
    index = path + "/index/"
 | 
			
		||||
    flist = os.listdir(content)
 | 
			
		||||
    flist.sort()
 | 
			
		||||
    for filename in flist:
 | 
			
		||||
        zimpos = filename.find(".zim")
 | 
			
		||||
        if zimpos != -1:
 | 
			
		||||
            zim_info = {}
 | 
			
		||||
            filename = filename[:zimpos]
 | 
			
		||||
            zimname = "content/" + filename + ".zim"
 | 
			
		||||
            zimidx = "index/" + filename + ".zim.idx"
 | 
			
		||||
            if zimname not in files_processed:
 | 
			
		||||
                if not os.path.isdir (path + "/" + zimidx): # only declare index if exists (could be embedded)
 | 
			
		||||
                    zimidx = None
 | 
			
		||||
                files_processed[zimname] = zimidx
 | 
			
		||||
                zimname = content + filename + ".zim"
 | 
			
		||||
                zimidx = index + filename + ".zim.idx"
 | 
			
		||||
                if filename in old_zim_map: # handle old names that don't parse
 | 
			
		||||
                    wiki_name = old_zim_map[filename]
 | 
			
		||||
                else:
 | 
			
		||||
                    ulpos = filename.rfind("_")
 | 
			
		||||
                    # but old gutenberg and some other names are not canonical
 | 
			
		||||
                    if filename.rfind("-") < 0: # non-canonical name
 | 
			
		||||
                        ulpos = filename[:ulpos].rfind("_")
 | 
			
		||||
                    wiki_name = filename[:ulpos]
 | 
			
		||||
                zim_info['file_name'] = filename
 | 
			
		||||
                zim_versions[wiki_name] = zim_info # if there are multiples, last should win
 | 
			
		||||
    return files_processed
 | 
			
		||||
 | 
			
		||||
def read_library_xml(lib_xml_file, kiwix_exclude_attr=[""]): # duplicated from iiab-cmdsrv
 | 
			
		||||
    kiwix_exclude_attr.append("id") # don't include id
 | 
			
		||||
    kiwix_exclude_attr.append("favicon") # don't include large favicon
 | 
			
		||||
    zims_installed = {}
 | 
			
		||||
    path_to_id_map = {}
 | 
			
		||||
    try:
 | 
			
		||||
        tree = ET.parse(lib_xml_file)
 | 
			
		||||
        root = tree.getroot()
 | 
			
		||||
        xml_item_no = 0
 | 
			
		||||
        for child in root:
 | 
			
		||||
            #xml_item_no += 1 # hopefully this is the array number
 | 
			
		||||
            attributes = {}
 | 
			
		||||
            if 'id' not in child.attrib: # is this necessary? implies there are records with no book id which would break index for removal
 | 
			
		||||
                  print ("xml record missing Book Id")
 | 
			
		||||
            id = child.attrib['id']
 | 
			
		||||
            for attr in child.attrib:
 | 
			
		||||
                if attr not in kiwix_exclude_attr:
 | 
			
		||||
                    attributes[attr] = child.attrib[attr] # copy if not id or in exclusion list
 | 
			
		||||
            zims_installed[id] = attributes
 | 
			
		||||
            path_to_id_map[child.attrib['path']] = id
 | 
			
		||||
    except IOError:
 | 
			
		||||
        zims_installed = {}
 | 
			
		||||
    return zims_installed, path_to_id_map
 | 
			
		||||
 | 
			
		||||
def rem_libr_xml(id):
 | 
			
		||||
    command = kiwix_manage + " " + kiwix_library_xml + " remove " + id
 | 
			
		||||
    #print command
 | 
			
		||||
    args = shlex.split(command)
 | 
			
		||||
    try:
 | 
			
		||||
        outp = subprocess.check_output(args)
 | 
			
		||||
    except subprocess.CalledProcessError as e:
 | 
			
		||||
        if e.returncode != 2: # skip bogus file open error in kiwix-manage
 | 
			
		||||
            print (outp)
 | 
			
		||||
 | 
			
		||||
def add_libr_xml(kiwix_library_xml, zim_path, zimname, zimidx):
 | 
			
		||||
    command = kiwix_manage + " " + kiwix_library_xml + " add " + zim_path + "/" + zimname
 | 
			
		||||
    if zimidx:
 | 
			
		||||
          command += " -i " + zim_path + "/" + zimidx
 | 
			
		||||
    #print command
 | 
			
		||||
    args = shlex.split(command)
 | 
			
		||||
    try:
 | 
			
		||||
        outp = subprocess.check_output(args)
 | 
			
		||||
 | 
			
		||||
    except: #skip things that don't work
 | 
			
		||||
        #print 'skipping ' + zimname
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
def read_lang_codes():
 | 
			
		||||
   global lang_codes
 | 
			
		||||
   with open(lang_codes_path,"r") as f:
 | 
			
		||||
      reads = f.read()
 | 
			
		||||
      #print("menu.json:%s"%reads)
 | 
			
		||||
      lang_codes = json.loads(reads)
 | 
			
		||||
 | 
			
		||||
def kiwix_lang_to_iso2(zim_lang_code):
 | 
			
		||||
    return lang_codes[zim_lang_code]['iso2']
 | 
			
		||||
 | 
			
		||||
def init():
 | 
			
		||||
 | 
			
		||||
    global iiab_base_path
 | 
			
		||||
    global zim_path
 | 
			
		||||
    global kiwix_library_xml
 | 
			
		||||
    global kiwix_manage
 | 
			
		||||
 | 
			
		||||
#    config = ConfigParser.SafeConfigParser()
 | 
			
		||||
    config = configparser.ConfigParser()
 | 
			
		||||
    config.read(iiab_ini_file)
 | 
			
		||||
    iiab_base_path = config.get('location','iiab_base')
 | 
			
		||||
    zim_path = config.get('kiwix','iiab_zim_path')
 | 
			
		||||
    kiwix_library_xml = config.get('kiwix','kiwix_library_xml')
 | 
			
		||||
    kiwix_manage = iiab_base_path + "/kiwix/bin/kiwix-manage"
 | 
			
		||||
    read_lang_codes()
 | 
			
		||||
 | 
			
		||||
def parse_args():
 | 
			
		||||
    parser = argparse.ArgumentParser(description="Create library.xml for Kiwix.")
 | 
			
		||||
    parser.add_argument("--device", help="no trailing /. change the target device from internal storage to something else like /media/usb0")
 | 
			
		||||
    parser.add_argument("--no_tmp", help="don't append .tmp to the library.xml name", action="store_true")
 | 
			
		||||
    parser.add_argument("-f", "--force", help="force complete rebuild of library.xml", action="store_true")
 | 
			
		||||
    parser.add_argument("-v", "--verbose", help="Print messages.", action="store_true")
 | 
			
		||||
    return parser.parse_args()
 | 
			
		||||
 | 
			
		||||
def write_zim_versions_idx():
 | 
			
		||||
   global zim_versions
 | 
			
		||||
   zims_installed,path_to_id_map = read_library_xml(kiwix_library_xml)
 | 
			
		||||
   for perma_ref in zim_versions:
 | 
			
		||||
      zim_versions[perma_ref]['menu_item'] = find_menuitem_from_zimname(perma_ref)
 | 
			
		||||
      articlecount,mediacount,size,tags,lang,date = \
 | 
			
		||||
           get_substitution_data(perma_ref, zims_installed, path_to_id_map)
 | 
			
		||||
      zim_versions[perma_ref]['article_count'] = articlecount
 | 
			
		||||
      zim_versions[perma_ref]['media_count'] = mediacount
 | 
			
		||||
      size = human_readable(float(size) * 1024) # kiwix reports in K
 | 
			
		||||
      zim_versions[perma_ref]['size'] = size
 | 
			
		||||
      zim_versions[perma_ref]['tags'] = tags
 | 
			
		||||
 | 
			
		||||
      zim_versions[perma_ref]['language'] = lang
 | 
			
		||||
      zim_versions[perma_ref]['zim_date'] = date
 | 
			
		||||
 | 
			
		||||
   # Write Version Map
 | 
			
		||||
   if os.path.isdir(zim_version_idx_dir):
 | 
			
		||||
      with open(zim_version_idx_dir + zim_version_idx_file, 'w') as fp:
 | 
			
		||||
         fp.write(json.dumps(zim_versions,indent=2 ))
 | 
			
		||||
         fp.close()
 | 
			
		||||
   else:
 | 
			
		||||
      print (zim_version_idx_dir + " not found.")
 | 
			
		||||
 | 
			
		||||
def get_substitution_data(perma_ref,zims_installed, path_to_id_map):
 | 
			
		||||
   #reconstruct the path in the id map
 | 
			
		||||
   path = 'content/' + zim_versions[perma_ref]['file_name'] + '.zim'
 | 
			
		||||
   id = path_to_id_map[path]
 | 
			
		||||
   item = zims_installed[id]
 | 
			
		||||
 | 
			
		||||
   if len(item) != 0 or perma_ref == 'test':
 | 
			
		||||
      mediacount = item.get('mediaCount','')
 | 
			
		||||
      articlecount = item.get('articleCount','')
 | 
			
		||||
      size = item.get('size','')
 | 
			
		||||
      tags = item.get('tags','')
 | 
			
		||||
      zim_lang = item.get('language')
 | 
			
		||||
      menu_def_lang = kiwix_lang_to_iso2(zim_lang)
 | 
			
		||||
      date =  item.get('date','')
 | 
			
		||||
      return (articlecount,mediacount,size,tags,menu_def_lang,date)
 | 
			
		||||
   return ('0','0','0','0','0','0')
 | 
			
		||||
 | 
			
		||||
def get_menu_def_zimnames(intended_use='zim'):
 | 
			
		||||
   menu_def_dict = {}
 | 
			
		||||
   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','') != 'zim':
 | 
			
		||||
            continue
 | 
			
		||||
         zimname = data.get('zim_name','')
 | 
			
		||||
         if zimname != '':
 | 
			
		||||
            menu_def_dict[data['zim_name']] = menuDefs + filename
 | 
			
		||||
   return menu_def_dict
 | 
			
		||||
 | 
			
		||||
def find_menuitem_from_zimname(zimname):
 | 
			
		||||
   defs = get_menu_def_zimnames()
 | 
			
		||||
   defs_filename = defs.get(zimname,'')
 | 
			
		||||
   if defs_filename != '':
 | 
			
		||||
      #print("reading menu-def:%s"%defs_filename)
 | 
			
		||||
      with open(defs_filename,'r') as json_file:
 | 
			
		||||
          readstr = json_file.read()
 | 
			
		||||
          data = json.loads(readstr)
 | 
			
		||||
          return data.get('menu_item_name','')
 | 
			
		||||
   return ''
 | 
			
		||||
 | 
			
		||||
def get_kiwix_catalog_item(perma_ref):
 | 
			
		||||
   # Read the kiwix catalog
 | 
			
		||||
   with open(KIWIX_CAT, 'r') as kiwix_cat:
 | 
			
		||||
      json_data = kiwix_cat.read()
 | 
			
		||||
      download = json.loads(json_data)
 | 
			
		||||
      zims = download['zims']
 | 
			
		||||
      for uuid in zims.keys():
 | 
			
		||||
         #print("%s   %s"%(zims[uuid]['perma_ref'],perma_ref,))
 | 
			
		||||
         if zims[uuid]['perma_ref'] == perma_ref:
 | 
			
		||||
            return zims[uuid]
 | 
			
		||||
      return {}
 | 
			
		||||
 | 
			
		||||
def human_readable(num):
 | 
			
		||||
    # return 3 significant digits and unit specifier
 | 
			
		||||
    # TFM 7/15/2019 change to factor of 1024, not 1000 to match similar calcs elsewhere
 | 
			
		||||
    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 /= 1024.0
 | 
			
		||||
 | 
			
		||||
# Now start the application
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
 | 
			
		||||
    # Run the main routine
 | 
			
		||||
    main()
 | 
			
		||||
| 
						 | 
				
			
			@ -1,17 +0,0 @@
 | 
			
		|||
- name: Stop 'Wired WAN connection'
 | 
			
		||||
  shell: nmcli dev disconnect {{ discovered_wan_iface }}
 | 
			
		||||
  ignore_errors: True
 | 
			
		||||
  changed_when: False
 | 
			
		||||
  when: discovered_wan_iface != "none" and not has_WAN and has_ifcfg_gw == "none"
 | 
			
		||||
 | 
			
		||||
# set user_wan_iface: <device> for static
 | 
			
		||||
# use wan_* for static info
 | 
			
		||||
- name: Supply ifcfg-WAN file
 | 
			
		||||
  template: src=network/ifcfg-WAN.j2
 | 
			
		||||
            dest=/etc/sysconfig/network-scripts/ifcfg-WAN
 | 
			
		||||
  when: iiab_wan_iface != "none" and not has_WAN  and has_ifcfg_gw == "none"
 | 
			
		||||
 | 
			
		||||
- name: Now setting ifcfg-WAN True after creating file
 | 
			
		||||
  set_fact:
 | 
			
		||||
    has_WAN: True
 | 
			
		||||
  when: iiab_wan_iface != "none" and has_ifcfg_gw == "none"
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
# this (hosts.yml) WAS invoked by roles/network/tasks/main.yml up until 2019-12-10
 | 
			
		||||
 | 
			
		||||
#TODO: Use vars instead of hardcoded values
 | 
			
		||||
- name: Remove FQDN with 172.18.96.1 in /etc/hosts without LAN (if iiab_lan_iface == "none" and not installing)
 | 
			
		||||
  lineinfile:
 | 
			
		||||
    path: /etc/hosts
 | 
			
		||||
    regexp: '^172\.18\.96\.1'
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: iiab_lan_iface == "none" and not installing
 | 
			
		||||
 | 
			
		||||
- name: Configure FQDN with 172.18.96.1 in /etc/hosts with LAN (if iiab_lan_iface != "none" and not installing)
 | 
			
		||||
  lineinfile:
 | 
			
		||||
    path: /etc/hosts
 | 
			
		||||
    regexp: '^172\.18\.96\.1'
 | 
			
		||||
    line: '172.18.96.1     {{ iiab_hostname }}.{{ iiab_domain }} {{ iiab_hostname }} box box.lan'
 | 
			
		||||
    state: present
 | 
			
		||||
  when: not (iiab_lan_iface == "none") and not installing
 | 
			
		||||
 | 
			
		||||
# roles/0-init/tasks/hostname.yml ALSO does this:
 | 
			
		||||
- name: 'Put FQDN & hostnames in /etc/hosts: "127.0.0.1 {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan" (if iiab_lan_iface == "none" and not installing, appliance mode?)'
 | 
			
		||||
  lineinfile:
 | 
			
		||||
    path: /etc/hosts
 | 
			
		||||
    regexp: '^127\.0\.0\.1'
 | 
			
		||||
    line: '127.0.0.1     {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan'
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: 0644
 | 
			
		||||
  when: iiab_lan_iface == "none" and not installing
 | 
			
		||||
| 
						 | 
				
			
			@ -1,47 +0,0 @@
 | 
			
		|||
# Generated by IIAB
 | 
			
		||||
# This file describes the network interfaces available on your system
 | 
			
		||||
# and how to activate them. For more information, see interfaces(5).
 | 
			
		||||
 | 
			
		||||
# iiab_network_mode is {{ gui_desired_network_role }}
 | 
			
		||||
 | 
			
		||||
{% if discovered_wireless_iface != 'none' %}
 | 
			
		||||
auto {{ discovered_wireless_iface }}
 | 
			
		||||
iface {{ discovered_wireless_iface }} inet manual
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
{% if iiab_network_mode == "Appliance"  %}
 | 
			
		||||
#################   APPLIANCE #########################
 | 
			
		||||
auto {{ discovered_wan_iface }}
 | 
			
		||||
#  if gui_static_wan == true  dhcpcd.conf will be modified
 | 
			
		||||
iface {{ discovered_wan_iface }} inet manual
 | 
			
		||||
 | 
			
		||||
{% elif iiab_network_mode == "Gateway"  %}
 | 
			
		||||
#################   GATEWAY   #########################
 | 
			
		||||
auto br0
 | 
			
		||||
iface br0 inet static
 | 
			
		||||
    bridge_ports {% if discovered_wireless_iface != "none" %} {{ discovered_wireless_iface }} {% endif %} {% if discovered_lan_iface != "none" %} {{ discovered_lan_iface }} {% endif %}
 | 
			
		||||
 | 
			
		||||
    bridge_maxwait 0
 | 
			
		||||
    address {{ lan_ip }}
 | 
			
		||||
    netmask {{ lan_netmask }}
 | 
			
		||||
    dns-nameservers {{ lan_ip }}
 | 
			
		||||
# change for debian 9, let dhcpcd.conf set the static ip
 | 
			
		||||
#  if gui_static_wan == True
 | 
			
		||||
auto {{ discovered_wan_iface }}
 | 
			
		||||
iface {{ discovered_wan_iface }} inet manual
 | 
			
		||||
 | 
			
		||||
{% else  %} {# end of iiab_network_mode == Gateway #}
 | 
			
		||||
 | 
			
		||||
#################   LANCONTROLLER   ###################
 | 
			
		||||
auto br0
 | 
			
		||||
iface br0 inet static
 | 
			
		||||
    bridge_ports {% if discovered_wireless_iface != "none" %} {{ discovered_wireless_iface }} {% endif %} {% if discovered_wan_iface != "none" %} {{ discovered_wan_iface }} {% endif %}
 | 
			
		||||
 | 
			
		||||
    bridge_maxwait 0
 | 
			
		||||
    address {{ lan_ip }}
 | 
			
		||||
    netmask {{ lan_netmask }}
 | 
			
		||||
    gateway {{ lan_ip }}
 | 
			
		||||
    dns-nameservers {{ lan_ip }}
 | 
			
		||||
    dns-search {{ iiab_domain }}
 | 
			
		||||
    post-up systemctl restart dhcpd && systemctl restart hostapd
 | 
			
		||||
{% endif %}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,30 +0,0 @@
 | 
			
		|||
#grep -r "not nginx_enabled" roles/
 | 
			
		||||
#roles/calibre-web/tasks/main.yml:  when: calibreweb_enabled and not nginx_enabled | bool
 | 
			
		||||
#roles/calibre-web/tasks/main.yml:  when: not nginx_enabled | bool
 | 
			
		||||
#roles/kolibri/tasks/main.yml:  when: kolibri_enabled and not nginx_enabled | bool
 | 
			
		||||
#roles/kolibri/tasks/main.yml:  when: not nginx_enabled | bool
 | 
			
		||||
#roles/kiwix/tasks/kiwix_install.yml:  when: kiwix_enabled and not nginx_enabled | bool
 | 
			
		||||
#roles/kiwix/tasks/kiwix_install.yml:  when: not nginx_enabled | bool
 | 
			
		||||
#roles/nginx/tasks/main.yml:  when: not nginx_enabled | bool
 | 
			
		||||
#roles/nginx/tasks/main.yml:  when: not nginx_enabled | bool
 | 
			
		||||
#roles/sugarizer/tasks/install.yml:  when: sugarizer_enabled and not nginx_enabled | bool
 | 
			
		||||
#roles/sugarizer/tasks/install.yml:  when: sugarizer_enabled and not nginx_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Enable Gitea for Apache
 | 
			
		||||
  command: a2ensite gitea.conf
 | 
			
		||||
 | 
			
		||||
- name: Enable Calibre-Web for Apache
 | 
			
		||||
  command: a2ensite calibre-web.conf
 | 
			
		||||
 | 
			
		||||
- name: Enable Kolibri for Apache
 | 
			
		||||
  command: a2ensite kolibri.conf
 | 
			
		||||
 | 
			
		||||
- name: Enable kiwix for Apache
 | 
			
		||||
  command: a2ensite kiwix.conf
 | 
			
		||||
 | 
			
		||||
- name: Enable Sugarizer for Apache
 | 
			
		||||
  command: a2ensite sugarizer.conf
 | 
			
		||||
 | 
			
		||||
- name: Enable AWStats for Apache
 | 
			
		||||
  command: a2ensite awstats.conf
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,98 +0,0 @@
 | 
			
		|||
# The ~100 lines of code below are near-identical to what's in tasks/enable.yml
 | 
			
		||||
# for these 6 playbooks.  Any way we can consolidate / reduce duplication?
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Remove symlink /etc/apache2/sites-enabled/awstats.conf
 | 
			
		||||
  command: a2dissite awstats.conf
 | 
			
		||||
 | 
			
		||||
- name: Install /etc/nginx/conf.d/awstats-nginx.conf from template, if awstats_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: roles/awstats/templates/awstats-nginx.conf
 | 
			
		||||
    dest: /etc/nginx/conf.d/awstats-nginx.conf
 | 
			
		||||
  when: awstats_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Remove NGINX support for AWStats, if not awstats_enabled
 | 
			
		||||
  file:
 | 
			
		||||
    path: /etc/nginx/conf.d/awstats-nginx.conf
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: not awstats_enabled
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Remove symlink /etc/apache2/sites-enabled/calibre-web.conf
 | 
			
		||||
  command: a2dissite calibre-web.conf
 | 
			
		||||
 | 
			
		||||
- name: Install /etc/nginx/conf.d/calibre-web-nginx.conf from template, if calibreweb_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: roles/calibre-web/templates/calibre-web-nginx.conf.j2
 | 
			
		||||
    dest: /etc/nginx/conf.d/calibre-web-nginx.conf
 | 
			
		||||
  when: calibreweb_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Remove NGINX support for Calibre-Web, if not calibreweb_enabled
 | 
			
		||||
  file:
 | 
			
		||||
    path: /etc/nginx/conf.d/calibre-web-nginx.conf
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: not calibreweb_enabled
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Remove symlink /etc/apache2/sites-enabled/gitea.conf
 | 
			
		||||
  command: a2dissite gitea.conf
 | 
			
		||||
 | 
			
		||||
- name: Install /etc/nginx/conf.d/gitea-nginx.conf from template, if gitea_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: roles/gitea/templates/gitea-nginx.conf.j2
 | 
			
		||||
    dest: /etc/nginx/conf.d/gitea-nginx.conf
 | 
			
		||||
  when: gitea_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Remove NGINX support for Gitea, if not gitea_enabled
 | 
			
		||||
  file:
 | 
			
		||||
    path: /etc/nginx/conf.d/gitea-nginx.conf
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: not gitea_enabled
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Remove symlink /etc/apache2/sites-enabled/kiwix.conf
 | 
			
		||||
  command: a2dissite kiwix.conf
 | 
			
		||||
 | 
			
		||||
- name: Install /etc/nginx/conf.d/kiwix-nginx.conf from template, if kiwix_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: roles/kiwix/templates/kiwix-nginx.conf
 | 
			
		||||
    dest: /etc/nginx/conf.d/kiwix-nginx.conf
 | 
			
		||||
  when: kiwix_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Remove NGINX support for Kiwix, if not kiwix_enabled
 | 
			
		||||
  file:
 | 
			
		||||
    path: /etc/nginx/conf.d/kiwix-nginx.conf
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: not kiwix_enabled
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Remove symlink /etc/apache2/sites-enabled/kolibri.conf
 | 
			
		||||
  command: a2dissite kolibri.conf
 | 
			
		||||
 | 
			
		||||
- name: Install /etc/nginx/conf.d/kolibri-nginx.conf from template, if kolibri_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: roles/kolibri/templates/kolibri-nginx.conf.j2
 | 
			
		||||
    dest: /etc/nginx/conf.d/kolibri-nginx.conf
 | 
			
		||||
  when: kolibri_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Remove NGINX support for Kolibri, if not kolibri_enabled
 | 
			
		||||
  file:
 | 
			
		||||
    path: /etc/nginx/conf.d/kolibri-nginx.conf
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: not kolibri_enabled
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Remove symlink /etc/apache2/sites-enabled/sugarizer.conf
 | 
			
		||||
  command: a2dissite sugarizer.conf
 | 
			
		||||
 | 
			
		||||
- name: Install /etc/nginx/conf.d/sugarizer-nginx.conf from template, if sugarizer_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: roles/sugarizer/templates/sugarizer-nginx.conf
 | 
			
		||||
    dest: /etc/nginx/conf.d/sugarizer-nginx.conf
 | 
			
		||||
  when: sugarizer_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Remove NGINX support for Sugarizer, if not sugarizer_enabled
 | 
			
		||||
  file:
 | 
			
		||||
    path: /etc/nginx/conf.d/sugarizer-nginx.conf
 | 
			
		||||
    state: absent
 | 
			
		||||
  when: not sugarizer_enabled
 | 
			
		||||
| 
						 | 
				
			
			@ -1,56 +0,0 @@
 | 
			
		|||
# The ~40 lines of code below are near-identical to what's in tasks/enable.yml
 | 
			
		||||
# for these 6 playbooks.  Any way PR #2131 etc can help reduce duplication?
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
- name: Install {{ nginx_conf_dir }}/dokuwiki-nginx.conf from template, if dokuwiki_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: dokuwiki-nginx.conf
 | 
			
		||||
    dest: "{{ nginx_conf_dir }}/dokuwiki-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
  when: dokuwiki_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Install {{ nginx_conf_dir }}/elgg-nginx.conf from template, if elgg_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: elgg-nginx.conf
 | 
			
		||||
    dest: "{{ nginx_conf_dir }}/elgg-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
  when: elgg_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Install {{ nginx_conf_dir }}/lokole-nginx.conf from template, if lokole_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: lokole-nginx.conf.j2
 | 
			
		||||
    dest: "{{ nginx_conf_dir }}/lokole-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
  when: lokole_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Install {{ nginx_conf_dir }}/moodle-nginx.conf from template, if moodle_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: moodle-nginx.conf.j2
 | 
			
		||||
    dest: "{{ nginx_conf_dir }}/moodle-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
  when: moodle_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Install {{ nginx_conf_dir }}/nextcloud-nginx.conf from template, if nextcloud_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: nextcloud-nginx.conf
 | 
			
		||||
    dest: "{{ nginx_conf_dir }}/nextcloud-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
  when: nextcloud_enabled | bool
 | 
			
		||||
 | 
			
		||||
- name: Install {{ nginx_conf_dir }}/nodered-nginx.conf from template, if nodered_enabled
 | 
			
		||||
  template:
 | 
			
		||||
    src: nodered-nginx.conf.j2
 | 
			
		||||
    dest: "{{ nginx_conf_dir }}/nodered-nginx.conf"    # /etc/nginx/conf.d
 | 
			
		||||
    # mode: '0666'
 | 
			
		||||
  when: nodered_enabled | bool
 | 
			
		||||
 | 
			
		||||
# mediawiki and wordpress are no longer proxied
 | 
			
		||||
 | 
			
		||||
#- name: Install MediaWiki's nginx conf.d file from template
 | 
			
		||||
#  template:
 | 
			
		||||
#    src: mediawiki-nginx.conf.j2
 | 
			
		||||
#    dest: /etc/nginx/conf.d/mediawiki-nginx.conf
 | 
			
		||||
#  when: mediawiki_enabled
 | 
			
		||||
 | 
			
		||||
#- name: Install WordPress's nginx conf.d file from template
 | 
			
		||||
#  template:
 | 
			
		||||
#      src: wordpress-nginx.conf
 | 
			
		||||
#      dest: /etc/nginx/conf.d/
 | 
			
		||||
#  when: wordpress_enabled
 | 
			
		||||
 | 
			
		||||
#- name: Install proxpass to apache running on localhost
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
location {{ dokuwiki_url }} {
 | 
			
		||||
  proxy_pass http://127.0.0.1:{{ apache_port }}{{ dokuwiki_url }};
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
location /mediawiki {
 | 
			
		||||
  proxy_pass http://127.0.0.1:{{ apache_port }}/mediawiki;
 | 
			
		||||
}
 | 
			
		||||
 location ~ /mediawiki/.*\.php$ {
 | 
			
		||||
 | 
			
		||||
    proxy_set_header X-Real-IP  $remote_addr;
 | 
			
		||||
    proxy_set_header X-Forwarded-For $remote_addr;
 | 
			
		||||
    proxy_set_header Host $host;
 | 
			
		||||
    proxy_pass http://127.0.0.1:{{ apache_port }};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
location /wordpress {
 | 
			
		||||
  proxy_pass http://127.0.0.1:{{ apache_port }}/wordpress;
 | 
			
		||||
}
 | 
			
		||||
 location ~ /wordpress/.*\.php$ {
 | 
			
		||||
 | 
			
		||||
    proxy_set_header X-Real-IP  $remote_addr;
 | 
			
		||||
    proxy_set_header X-Forwarded-For $remote_addr;
 | 
			
		||||
    proxy_set_header Host $host;
 | 
			
		||||
    proxy_pass http://127.0.0.1:{{ apache_port }};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,35 +0,0 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
echo -e "\n\n\e[41m             DEPRECATED           PLEASE RUN 'iiab-support' INSTEAD             \e[0m\n\n"
 | 
			
		||||
 | 
			
		||||
echo -e 'This older script TEMPORARILY (over)writes /etc/iiab/openvpn_handle to'
 | 
			
		||||
echo -e 'identify IIAB to the upstream OpenVPN server, until Ansible next runs.\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
 | 
			
		||||
    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"
 | 
			
		||||
 | 
			
		||||
# 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
 | 
			
		||||
| 
						 | 
				
			
			@ -1,27 +0,0 @@
 | 
			
		|||
$!/bin/bash
 | 
			
		||||
$ start the openvpn tunnel if the service is enabled
 | 
			
		||||
 | 
			
		||||
enabled={{ openvpn_enabled }}
 | 
			
		||||
VPNIP={{ openvpn_server_port }}
 | 
			
		||||
 | 
			
		||||
if [ "$enabled" = 'True' ]; then
 | 
			
		||||
    # make sure the wan is functioning
 | 
			
		||||
    # 8.8.8.8 is one of google's dns servers
 | 
			
		||||
    ping -c 3 -i 3 8.8.8.8
 | 
			
		||||
    if [ $? -ne 0 ]; then
 | 
			
		||||
        #echo "internet is not available, tunnel not possible"
 | 
			
		||||
        exit 1
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    # check the vpn tunnel
 | 
			
		||||
    ping -c 5 -i 5 "$VPNIP"
 | 
			
		||||
    # a zero return means the tunnel is up
 | 
			
		||||
    if [ $? -eq 0 ]; then
 | 
			
		||||
        exit 0
 | 
			
		||||
    else
 | 
			
		||||
        killall openvpn
 | 
			
		||||
        sleep 10
 | 
			
		||||
        #echo "Starting openvpn and waiting 10 seconds for daemon to become ready"
 | 
			
		||||
        systemctl start openvpn@xscenet
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
| 
						 | 
				
			
			@ -1,13 +0,0 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
# Not used as of August 2018: parent service "openvpn" reliably auto-starts child service "openpn@xscenet" on OS's in common use
 | 
			
		||||
# But could be revived for older CentOS etc?
 | 
			
		||||
 | 
			
		||||
# If the wan has recently come up, see if we need to start openvpn
 | 
			
		||||
 | 
			
		||||
systemctl is-enabled openvpn
 | 
			
		||||
if [ $? -eq 0 ]; then
 | 
			
		||||
    pgrep openvpn
 | 
			
		||||
    if [ $? -ne 0 ]; then
 | 
			
		||||
        systemctl start openvpn@xscenet
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
| 
						 | 
				
			
			@ -1,40 +0,0 @@
 | 
			
		|||
[information]
 | 
			
		||||
name = Sugarizer Server
 | 
			
		||||
description = Your Sugarizer Server
 | 
			
		||||
 | 
			
		||||
[web]
 | 
			
		||||
port = {{ sugarizer_port }}
 | 
			
		||||
 | 
			
		||||
[security]
 | 
			
		||||
min_password_size = 4
 | 
			
		||||
max_age = 172800000
 | 
			
		||||
https = false
 | 
			
		||||
certificate_file = ../server.crt
 | 
			
		||||
key_file = ../server.key
 | 
			
		||||
strict_ssl = false
 | 
			
		||||
 | 
			
		||||
[client]
 | 
			
		||||
path = ../sugarizer/
 | 
			
		||||
 | 
			
		||||
[database]
 | 
			
		||||
server = localhost
 | 
			
		||||
port = 27018
 | 
			
		||||
name = sugarizer
 | 
			
		||||
waitdb = 1
 | 
			
		||||
 | 
			
		||||
[presence]
 | 
			
		||||
port = 8039
 | 
			
		||||
 | 
			
		||||
[statistics]
 | 
			
		||||
active = true
 | 
			
		||||
 | 
			
		||||
[collections]
 | 
			
		||||
users = users
 | 
			
		||||
journal = journal
 | 
			
		||||
stats = stats
 | 
			
		||||
 | 
			
		||||
[activities]
 | 
			
		||||
activities_directory_name = activities
 | 
			
		||||
template_directory_name = ActivityTemplate
 | 
			
		||||
activity_info_path = activity/activity.info
 | 
			
		||||
favorites = org.sugarlabs.GearsActivity,org.sugarlabs.MazeWebActivity,org.olpcfrance.PaintActivity,org.olpcfrance.TamTamMicro,org.olpcfrance.MemorizeActivity,org.olpg-france.physicsjs,org.sugarlabs.CalculateActivity,org.sugarlabs.TurtleBlocksJS,org.sugarlabs.Clock,org.sugarlabs.SpeakActivity,org.sugarlabs.moon,org.olpcfrance.RecordActivity,org.olpcfrance.Abecedarium,org.olpcfrance.videoviewer,org.olpcfrance.FoodChain,org.olpc-france.labyrinthjs,org.olpcfrance.TankOp,org.sugarlabs.ChatPrototype,org.olpcfrance.Gridpaint,org.olpc-france.LOLActivity,org.olpcfrance.sharednotes,org.sugarlabs.ColorMyWorldActivity,com.homegrownapps.xoeditor,com.homegrownapps.reflection,com.homegrownapps.abacus,org.sugarlabs.Blockrain,org.sugarlabs.StopwatchActivity,com.homegrownapps.flip,org.somosazucar.JappyActivity,org.olpcfrance.qrcode,org.sugarlabs.Markdown,org.sugarlabs.gameOfLife,org.sugarlabs.Scratch,org.sugarlabs.FotoToonJs
 | 
			
		||||
| 
						 | 
				
			
			@ -1,43 +0,0 @@
 | 
			
		|||
// require files
 | 
			
		||||
var express = require('express'),
 | 
			
		||||
	http = require('http'),
 | 
			
		||||
	https = require('https'),
 | 
			
		||||
	settings = require('./config/settings'),
 | 
			
		||||
	common = require('./dashboard/helper/common');
 | 
			
		||||
	ini = settings.load(),
 | 
			
		||||
	app = express(),
 | 
			
		||||
	server = null;
 | 
			
		||||
 | 
			
		||||
// init common
 | 
			
		||||
common.init(ini);
 | 
			
		||||
 | 
			
		||||
//configure app setting
 | 
			
		||||
require('./config/main')(app, ini);
 | 
			
		||||
 | 
			
		||||
// include api routes
 | 
			
		||||
require('./api/route')(app, ini);
 | 
			
		||||
 | 
			
		||||
// include dashboard routes
 | 
			
		||||
require('./dashboard/route')(app, ini);
 | 
			
		||||
 | 
			
		||||
// Handle https
 | 
			
		||||
if (ini.security.https) {
 | 
			
		||||
	var credentials = common.loadCredentials(ini);
 | 
			
		||||
	if (!credentials) {
 | 
			
		||||
		console.log("Error reading HTTPS credentials");
 | 
			
		||||
		process.exit(-1);
 | 
			
		||||
	}
 | 
			
		||||
	server = https.createServer(credentials, app);
 | 
			
		||||
} else {
 | 
			
		||||
	server = http.createServer(app);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var pathPrefix = '/sugarizer';
 | 
			
		||||
app.use(pathPrefix, require('path-prefix-proxy')(pathPrefix));
 | 
			
		||||
 | 
			
		||||
// Start listening
 | 
			
		||||
server.listen(ini.web.port,"0.0.0.0");
 | 
			
		||||
console.log("Sugarizer Server is listening on"+(ini.security.https ? " secure":"")+" port " + ini.web.port + "...");
 | 
			
		||||
 | 
			
		||||
//export app for testing
 | 
			
		||||
module.exports = app;
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue