mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Auto-install latest/official kiwix-tools + tighten up code
This commit is contained in:
parent
38fa807a00
commit
8643285dc9
3 changed files with 37 additions and 45 deletions
|
@ -21,14 +21,27 @@
|
|||
# - index = directory for legacy *.zim.idx's
|
||||
kiwix_library_xml: "{{ iiab_zim_path }}/library.xml"
|
||||
|
||||
# 3 lines below specify which version(s) of kiwix-tools to download from...
|
||||
# https://download.iiab.io/packages/ ...as originally obtained from...
|
||||
# https://download.kiwix.org/release/kiwix-tools/ ...or sometimes...
|
||||
# https://download.kiwix.org/nightly/
|
||||
kiwix_base_url: https://download.kiwix.org/release/kiwix-tools/
|
||||
#kiwix_base_url: https://download.kiwix.org/nightly/2022-10-04/
|
||||
#kiwix_base_url: "{{ iiab_download_url }}/" # https://download.iiab.io/packages/
|
||||
|
||||
kiwix_version_armhf: kiwix-tools_linux-armhf-3.3.0-1
|
||||
kiwix_version_linux64: kiwix-tools_linux-x86_64-3.3.0-1
|
||||
kiwix_version_i686: kiwix-tools_linux-i586-3.3.0-1
|
||||
kiwix_arch_dict:
|
||||
#i386:
|
||||
i686: i586
|
||||
x86_64: x86_64
|
||||
armv6l: armhf
|
||||
armv7l: armhf
|
||||
aarch64: armhf
|
||||
|
||||
# ansible_architecture can also work:
|
||||
# https://stackoverflow.com/questions/66828315/what-is-the-difference-between-ansible-architecture-and-ansible-machine-on-a/66828837#66828837
|
||||
kiwix_arch: "{{ kiwix_arch_dict[ansible_machine] | default('unsupported') }}"
|
||||
|
||||
# Latest official kiwix-tools release, per Kiwix permalink redirects:
|
||||
# https://www.kiwix.org/en/downloads/kiwix-serve/
|
||||
# https://github.com/kiwix/container-images/issues/236
|
||||
kiwix_tar_gz: "kiwix-tools_linux-{{ kiwix_arch }}.tar.gz"
|
||||
#kiwix_tar_gz: "kiwix-tools_linux-{{ kiwix_arch }}-3.3.0-1.tar.gz" # Version can be hard-coded if you prefer (as was done til 2022-10-04)
|
||||
|
||||
# kiwix_src_file_i686: "kiwix-linux-i686.tar.bz2"
|
||||
# v0.9 for i686 published May 2014 ("use it to test legacy ZIM content")
|
||||
|
|
|
@ -1,42 +1,22 @@
|
|||
# 0. SET CPU ARCHITECTURE
|
||||
# 0. VERIFY CPU/OS ARCHITECTURE SUPPORTED
|
||||
|
||||
- name: "Initialize 'kiwix_src_dir: False' just in case CPU architecture is not supported"
|
||||
set_fact:
|
||||
kiwix_src_dir: False
|
||||
|
||||
- name: "Set fact 'kiwix_src_dir: {{ kiwix_version_armhf }}' (armv6l or armv71 or aarch64)"
|
||||
set_fact:
|
||||
kiwix_src_dir: "{{ kiwix_version_armhf }}"
|
||||
when: ansible_machine == "armv6l" or ansible_machine == "armv7l" or ansible_machine == "aarch64"
|
||||
|
||||
- name: "Set fact 'kiwix_src_dir: {{ kiwix_version_linux64 }}' (x86_64)"
|
||||
set_fact:
|
||||
kiwix_src_dir: "{{ kiwix_version_linux64 }}"
|
||||
when: ansible_machine == "x86_64"
|
||||
|
||||
- name: "Set fact 'kiwix_src_dir: {{ kiwix_version_i686 }}' (i686)"
|
||||
set_fact:
|
||||
kiwix_src_dir: "{{ kiwix_version_i686 }}"
|
||||
when: ansible_machine == "i686"
|
||||
# COMMENT OUT LINE ABOVE TO TEST i686 CODE PATH ON X86_64 (WORKS NOV 2017)
|
||||
|
||||
- name: Force Ansible to exit (FAIL) if kiwix-tools appears unavailable for your architecture ({{ ansible_machine }})
|
||||
- name: Force Ansible to exit (FAIL) if kiwix-tools appears unavailable for your CPU/OS architecture ({{ ansible_machine }})
|
||||
fail:
|
||||
msg: "WARNING: kiwix-tools SOFTWARE APPEARS UNAVAILABLE FOR YOUR {{ ansible_machine }} OS/ARCHITECTURE."
|
||||
when: not kiwix_src_dir
|
||||
|
||||
- name: "Set fact 'kiwix_src_file: {{ kiwix_src_dir }}.tar.gz'"
|
||||
set_fact:
|
||||
kiwix_src_file: "{{ kiwix_src_dir }}.tar.gz"
|
||||
msg: "WARNING: kiwix-tools SOFTWARE APPEARS UNAVAILABLE FOR YOUR {{ ansible_machine }} CPU/OS ARCHITECTURE."
|
||||
when: kiwix_arch == "unsupported"
|
||||
|
||||
|
||||
# 1. PUT IN PLACE: /opt/iiab/downloads/kiwix-tools_linux-*.tar.gz, essential dirs, and test.zim if nec (library.xml is created later, by enable-or-disable.yml)
|
||||
|
||||
- name: Download {{ iiab_download_url }}/{{ kiwix_src_file }} to /opt/iiab/downloads
|
||||
# 2022-10-04: get_url might be removed in future (unarchive below can handle
|
||||
# everything!) Conversely: (1) unarchive doesn't support timeout (2) one day
|
||||
# /opt/iiab/downloads might have practical value beyond hoarding (unlikely!)
|
||||
- name: Download {{ kiwix_base_url }}{{ kiwix_tar_gz }} to /opt/iiab/downloads
|
||||
get_url:
|
||||
url: "{{ iiab_download_url }}/{{ kiwix_src_file }}" # https://download.iiab.io/packages
|
||||
dest: "{{ downloads_dir }}/{{ kiwix_src_file }}" # /opt/iiab/downloads
|
||||
url: "{{ kiwix_base_url }}{{ kiwix_tar_gz }}" # e.g. https://download.kiwix.org/release/kiwix-tools/ + kiwix-tools_linux-x86_64.tar.gz
|
||||
dest: "{{ downloads_dir }}" # /opt/iiab/downloads
|
||||
timeout: "{{ download_timeout }}"
|
||||
register: kiwix_dl # Kiwix URL redirects to a longer filename, including the actual kiwix-tools version (placed in kiwix_dl.dest with its path, for unarchive ~28 lines below)
|
||||
|
||||
- name: "Create dirs, including parent dirs: {{ kiwix_path }}/bin (executables), {{ iiab_zim_path }}/content (ZIM files), {{ iiab_zim_path }}/index (legacy indexes) (by default 0755)"
|
||||
file:
|
||||
|
@ -63,13 +43,11 @@
|
|||
|
||||
# 2. INSTALL KIWIX-TOOLS EXECUTABLES
|
||||
|
||||
- name: Unarchive {{ kiwix_src_file }} to /tmp # e.g. kiwix-tools_linux-armhf-3.1.2-3.tar.gz
|
||||
- name: Unarchive {{ kiwix_dl.dest }} to {{ kiwix_path }}/bin -- use '--strip-components=1' to remove tarball's top-level dir during unpacking
|
||||
unarchive:
|
||||
src: "{{ downloads_dir }}/{{ kiwix_src_file }}"
|
||||
dest: /tmp
|
||||
|
||||
- name: Move /tmp/{{ kiwix_src_dir }}/* to permanent location {{ kiwix_path }}/bin
|
||||
shell: "mv /tmp/{{ kiwix_src_dir }}/* {{ kiwix_path }}/bin/" # /opt/iiab/kiwix
|
||||
src: "{{ kiwix_dl.dest }}" # See ~28 lines above, e.g. /opt/iiab/downloads/kiwix-tools_linux-x86_64-3.3.0-1.tar.gz
|
||||
dest: "{{ kiwix_path }}/bin" # /opt/iiab/kiwix/bin
|
||||
extra_opts: --strip-components=1
|
||||
|
||||
|
||||
# 3. ENABLE MODS FOR APACHE PROXY IF DEBUNTU
|
||||
|
@ -103,7 +81,6 @@
|
|||
systemd:
|
||||
daemon_reload: yes
|
||||
|
||||
# install kiwix app
|
||||
- name: Install Kiwix Android app
|
||||
include_tasks: kiwix-apk.yml
|
||||
when: kiwix_incl_apk
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
value: "{{ kiwix_install }}"
|
||||
- option: kiwix_enabled
|
||||
value: "{{ kiwix_enabled }}"
|
||||
- option: kiwix_tar_gz
|
||||
value: "{{ kiwix_tar_gz }}"
|
||||
- option: kiwix_url
|
||||
value: "{{ kiwix_url }}"
|
||||
- option: kiwix_url_plus_slash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue