1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00

Merge pull request #184 from iiab/master

sync from iiab/iiab
This commit is contained in:
A Holt 2018-11-15 13:57:37 -05:00 committed by GitHub
commit 6b8e741b43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 23 deletions

View file

@ -1,5 +1,5 @@
elgg_xx: elgg
elgg_version: "2.3.8"
elgg_version: "2.3.9"
# elgg_mysql_password: defined in default_vars
elgg_url: /elgg

View file

@ -1,9 +1,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-0.7.0"
kiwix_version_linux64: "kiwix-tools_linux-x86_64-0.7.0"
kiwix_version_i686: "kiwix-tools_linux-i586-0.7.0"
kiwix_version_armhf: "kiwix-tools_linux-armhf-0.7.0-1"
kiwix_version_linux64: "kiwix-tools_linux-x86_64-0.7.0-1"
kiwix_version_i686: "kiwix-tools_linux-i586-0.7.0-1"
# 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:

View file

@ -51,7 +51,7 @@ old_zim_map = {"bad.zim" : "unparseable name"}
# Working variables
# zim_files - list of zims and possible index from file system
# path_to_array_map - list of zims in current library.xml with array index number (for delete)
# 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():
@ -78,23 +78,21 @@ def main():
except OSError:
pass
zims_installed = {}
path_to_array_map = {}
path_to_id_map = {}
else:
zims_installed, path_to_array_map = read_library_xml(kiwix_library_xml)
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_array_map:
for item in path_to_id_map:
if item not in zim_files:
remove_list_str += str(path_to_array_map[item]) + " "
if remove_list_str:
rem_libr_xml(remove_list_str)
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_array_map:
if item not in path_to_id_map:
add_libr_xml(kiwix_library_xml, zim_path, item, zim_files[item])
# Write Version Map
@ -139,13 +137,13 @@ def read_library_xml(lib_xml_file, kiwix_exclude_attr=[""]): # duplicated from i
kiwix_exclude_attr.append("id") # don't include id
kiwix_exclude_attr.append("favicon") # don't include large favicon
zims_installed = {}
path_to_array_map = {}
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
#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"
@ -154,17 +152,20 @@ def read_library_xml(lib_xml_file, kiwix_exclude_attr=[""]): # duplicated from i
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_array_map[child.attrib['path']] = xml_item_no
path_to_id_map[child.attrib['path']] = id
except IOError:
zims_installed = {}
return zims_installed, path_to_array_map
return zims_installed, path_to_id_map
def rem_libr_xml(list_str):
command = kiwix_manage + " " + kiwix_library_xml + " remove " + list_str
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

View file

@ -1,4 +1,5 @@
export OPWEN_STATE_DIRECTORY='{{lokole_run_directory}}'
export OPWEN_SESSION_KEY='{{ lookup('password', '/dev/null chars=ascii_letters,digits,_ length=32') }}'
export OPWEN_PASSWORD_SALT='{{ lookup('password', '/dev/null chars=ascii_letters,digits,_ length=16') }}'
export OPWEN_CLIENT_NAME='iiab-{{ iiab_hostname }}'
export OPWEN_CLIENT_NAME='{{ iiab_hostname }}'
export OPWEN_ROOT_DOMAIN='{{ iiab_domain }}'