mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 03:32:12 +00:00
Install the latest Calibre on all OS's, Adds Verif
This commit is contained in:
parent
c5ad68b6ef
commit
a2c0c06113
1 changed files with 117 additions and 42 deletions
|
@ -1,62 +1,137 @@
|
|||
- name: Get Calibre setup file (CentOS)
|
||||
# the installer works for intel fedora, and Centos, and deals with dependencies
|
||||
- name: Download latest calibre-installer.py from GitHub
|
||||
# seems to work with just about any Linux, and deals with dependencies
|
||||
get_url:
|
||||
url="{{ calibre_src_url }}"
|
||||
dest="{{ downloads_dir }}/calibre-installer.py"
|
||||
mode=0755
|
||||
when: ansible_distribution == "CentOS"
|
||||
url: "{{ calibre_src_url }}"
|
||||
dest: "{{ downloads_dir }}/calibre-installer.py"
|
||||
mode: 0755
|
||||
force: yes
|
||||
backup: yes
|
||||
register: calibre_download_output
|
||||
when: internet_available
|
||||
|
||||
- name: Install Calibre (CentOS)
|
||||
# ALWAYS DEFINED, DESPITE get_url DOCUMENTATION CLAIM...
|
||||
# - debug:
|
||||
# msg: "{{ calibre_download_output.src }}"
|
||||
#
|
||||
# DEFINED ONLY WHEN /opt/iiab/downloads/calibre-installer.py CHANGES
|
||||
# - debug:
|
||||
# msg: "{{ calibre_download_output.backup_file }}"
|
||||
|
||||
# OOPS BAD IDEA: changes in https://github.com/kovidgoyal/calibre/commits/master/setup/linux-installer.py are not sync'd with Calibre releases!
|
||||
# - name: FORCE AN UPGRADE IF calibre-installer.py HAS CHANGED, IF SO ORIGINAL IS SAVED TO {{ calibre_download_output.backup_file }}
|
||||
# file:
|
||||
# path: /usr/bin/calibre-uninstall
|
||||
# state: absent
|
||||
# when: calibre_download_output.backup_file is defined
|
||||
|
||||
- name: Check if calibre-installer.py exists in /opt/iiab/downloads
|
||||
stat:
|
||||
path: "{{ downloads_dir }}/calibre-installer.py"
|
||||
register: calib_inst
|
||||
|
||||
- name: FAIL (force Ansible to exit) IF /opt/iiab/downloads/calibre-installer.py doesn't exist
|
||||
fail:
|
||||
msg: "{{ downloads_dir }}/calibre-installer.py is REQUIRED in order to install Calibre."
|
||||
when: not calib_inst.stat.exists
|
||||
|
||||
# INSTALL THE LATEST CALIBRE (calibre-server etc) ON ALL OS'S - RUNS IF /usr/bin/calibre-uninstall DOES NOT ALEADY EXIST
|
||||
|
||||
- name: Run calibre-installer.py to install Calibre programs into /usr/bin - REMOVE /usr/bin/calibre-uninstall TO FORCE calibre-installer.py TO REINSTALL/UPGRADE HERE!
|
||||
shell: "{{ downloads_dir }}/calibre-installer.py >> /dev/null"
|
||||
args:
|
||||
creates: /usr/bin/calibre-uninstall
|
||||
when: calibre_install and ansible_distribution == 'CentOS'
|
||||
when: internet_available
|
||||
|
||||
- name: Install Calibre (OS's other than CentOS)
|
||||
# the fedora rpm arm version, though older, takes care of dependencies, and exists
|
||||
package: name={{ item }}
|
||||
state=present
|
||||
with_items:
|
||||
- calibre
|
||||
when: calibre_install and ansible_distribution != 'CentOS'
|
||||
# - name: Install Calibre (OS's other than CentOS)
|
||||
# # the fedora rpm arm version, though older, takes care of dependencies, and exists
|
||||
# package: name={{ item }}
|
||||
# state=present
|
||||
# with_items:
|
||||
# - calibre
|
||||
# when: calibre_install and ansible_distribution != 'CentOS'
|
||||
|
||||
- name: Create calibre-serve.service and calibre.conf
|
||||
template: backup=no
|
||||
src={{ item.src }}
|
||||
dest={{ item.dest }}
|
||||
owner=root
|
||||
group=root
|
||||
mode={{ item.mode }}
|
||||
template:
|
||||
backup: no
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "{{ item.mode }}"
|
||||
with_items:
|
||||
- { src: 'calibre-serve.service.j2', dest: '/etc/systemd/system/calibre-serve.service', mode: '0644'}
|
||||
- { src: 'calibre.conf', dest: '/etc/{{ apache_config_dir }}', mode: '0644'}
|
||||
when: calibre_install
|
||||
|
||||
- name: Create the link for sites-enabled, containing ProxyPass[Reverse]...localhost:8080 (debuntu)
|
||||
file: src=/etc/apache2/sites-available/calibre.conf
|
||||
dest=/etc/apache2/sites-enabled/calibre.conf
|
||||
state=link
|
||||
when: is_debuntu and calibre_enabled
|
||||
# http://box:8080 & http://box:8080/mobile WORK BUT OTHER URL'S LIKE http://box/books ARE A MESS (BOOKS RARELY DISPLAY)
|
||||
- name: Create calibre.conf link for UNTESTED http://box/books etc (debuntu)
|
||||
file:
|
||||
src: /etc/apache2/sites-available/calibre.conf
|
||||
dest: /etc/apache2/sites-enabled/calibre.conf
|
||||
state: link
|
||||
when: is_debuntu
|
||||
|
||||
- name: Enable Calibre service -- runs calibre-server by Kovid Goyal
|
||||
service: name=calibre-serve
|
||||
enabled=yes
|
||||
state=started
|
||||
#async: 900
|
||||
#poll: 5
|
||||
when: calibre_enabled
|
||||
# CREATE CALIBRE DATABASE WITH A SAMPLE BOOK
|
||||
|
||||
- name: Disable Calibre service -- stops calibre-server by Kovid Goyal
|
||||
service: name=calibre-serve
|
||||
enabled=no
|
||||
state=stopped
|
||||
when: not calibre_enabled
|
||||
service:
|
||||
name: calibre-serve
|
||||
enabled: no
|
||||
state: stopped
|
||||
|
||||
- name: Create /library/calibre (mandatory since Calibre 3.x)
|
||||
file:
|
||||
path: "{{ calibre_dbpath }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: Check if sample book exists in /opt/iiab/downloads
|
||||
stat:
|
||||
path: "{{ content_base }}/downloads/{{ calibre_sample_book }}"
|
||||
register: sample_bk
|
||||
|
||||
- name: Download sample book (mandatory since Calibre 3.x)
|
||||
get_url:
|
||||
url: "{{ iiab_download_url }}/{{ calibre_sample_book }}"
|
||||
dest: "{{ content_base }}/downloads"
|
||||
when: internet_available and not sample_bk.stat.exists
|
||||
|
||||
- name: Check if sample book exists in /opt/iiab/downloads
|
||||
stat:
|
||||
path: "{{ content_base }}/downloads/{{ calibre_sample_book }}"
|
||||
register: sample_bk
|
||||
|
||||
- name: Check if /library/calibre/metadata.db exists
|
||||
stat:
|
||||
path: "{{ calibre_dbpath }}/metadata.db"
|
||||
register: calibre_db
|
||||
|
||||
- name: Incorporate sample book into Calibre DB (mandatory since Calibre 3.x)
|
||||
shell: "calibredb add {{ content_base }}/downloads/{{ calibre_sample_book }} --with-library {{ calibre_dbpath }}"
|
||||
when: sample_bk.stat.exists and not calibre_db.stat.exists
|
||||
|
||||
# WRAP UP CALIBRE INSTALLATION
|
||||
|
||||
- name: Enable Calibre service -- runs calibre-server by Kovid Goyal
|
||||
service:
|
||||
name: calibre-serve
|
||||
enabled: yes
|
||||
state: started
|
||||
#async: 900
|
||||
#poll: 5
|
||||
when: calibre_enabled
|
||||
|
||||
# - name: Disable Calibre service -- stops calibre-server by Kovid Goyal
|
||||
# service: name=calibre-serve
|
||||
# enabled=no
|
||||
# state=stopped
|
||||
# when: not calibre_enabled
|
||||
|
||||
- name: Add 'calibre-serve' to service list
|
||||
ini_file: dest='{{ service_filelist }}'
|
||||
section=calibre
|
||||
option='{{ item.option }}'
|
||||
value='{{ item.value }}'
|
||||
ini_file:
|
||||
dest: "{{ service_filelist }}"
|
||||
section: calibre
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value }}"
|
||||
with_items:
|
||||
- option: description
|
||||
value: '"Calibre is an extremely popular personal library system for e-books."'
|
||||
|
|
Loading…
Reference in a new issue