2018-05-10 20:13:58 +00:00
|
|
|
# 1. INSTALL THE LATEST CALIBRE 3.X+ (calibre, calibredb, calibre-server etc) ON ALL OS'S
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-05-10 20:13:58 +00:00
|
|
|
- name: Check if /usr/bin/calibre exists
|
|
|
|
stat:
|
|
|
|
path: "/usr/bin/calibre"
|
|
|
|
register: calib_executable
|
|
|
|
|
2018-07-11 07:40:50 +00:00
|
|
|
- name: Install Calibre via OS's package installer (IF /usr/bin/calibre MISSING)
|
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: latest
|
|
|
|
with_items:
|
|
|
|
- calibre
|
|
|
|
- calibre-bin
|
|
|
|
when: internet_available and (not calib_executable.stat.exists)
|
2017-11-19 20:33:53 +00:00
|
|
|
|
2018-05-10 20:13:58 +00:00
|
|
|
- name: Install Calibre experimental .debs IF calibre_via_debs (AND /usr/bin/calibre WAS MISSING)
|
2017-11-19 20:33:53 +00:00
|
|
|
include_tasks: debs.yml
|
2018-05-10 20:13:58 +00:00
|
|
|
when: calibre_via_debs and (not calib_executable.stat.exists)
|
|
|
|
|
|
|
|
- name: Install Calibre via calibre-installer.py IF calibre_via_python (AND /usr/bin/calibre WAS MISSING)
|
|
|
|
include_tasks: py-installer.yml
|
|
|
|
when: calibre_via_python and (not calib_executable.stat.exists)
|
2018-04-07 03:43:44 +00:00
|
|
|
|
2018-05-10 20:13:58 +00:00
|
|
|
# SEE calibre_via_python's value vars/default_vars.yml, vars/ubuntu-18.yml &
|
|
|
|
# vars/raspbian-9.yml: try to AVOID Python installer on Raspbian since its
|
|
|
|
# .deb's (http://raspbian.raspberrypi.org/raspbian/pool/main/c/calibre/)
|
|
|
|
# are updated within about 10 days of Calibre's quasi-monthly releases!
|
|
|
|
#
|
|
|
|
# BUT IF ABSOLUTELY NEC: (SEE roles/calibre/tasks/debs.yml)
|
|
|
|
# - run testing branch for RPi: scripts/calibre-install-latest-rpi.sh
|
|
|
|
# - run testing branch for Ubuntu 16.04: scripts/calibre-install-latest.sh
|
|
|
|
# - run unstable branch for Debian etc: scripts/calibre-install-unstable.sh
|
2017-11-19 20:33:53 +00:00
|
|
|
|
2018-07-07 20:20:28 +00:00
|
|
|
- name: Create calibre-serve.service and calibre.conf (IF /usr/bin/calibre WAS MISSING)
|
2017-12-07 16:06:37 +00:00
|
|
|
template:
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "{{ item.mode }}"
|
2017-12-07 16:27:19 +00:00
|
|
|
backup: no
|
2018-07-07 19:54:44 +00:00
|
|
|
# register: calibre_config
|
2017-12-07 16:06:37 +00:00
|
|
|
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'}
|
2018-07-07 19:54:44 +00:00
|
|
|
when: (not calib_executable.stat.exists)
|
2018-07-07 19:49:46 +00:00
|
|
|
|
2018-07-07 20:20:28 +00:00
|
|
|
- name: Force systemd to reread configs (IF /usr/bin/calibre WAS MISSING)
|
2017-12-07 16:22:03 +00:00
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
2018-07-07 19:54:44 +00:00
|
|
|
when: (not calib_executable.stat.exists)
|
|
|
|
# when: calibre_config.changed
|
2017-12-07 16:06:37 +00:00
|
|
|
|
2017-11-20 10:27:02 +00:00
|
|
|
# 2. STOP CALIBRE SERVICE IF IT EXISTS (REQUIRED FOR DB ACTIVITY...AND IF not calibre_enabled)
|
2017-11-20 08:25:53 +00:00
|
|
|
|
2017-11-20 10:27:02 +00:00
|
|
|
#- name: Check if Calibre systemd service exists
|
|
|
|
# stat:
|
|
|
|
# path: /etc/systemd/system/calibre-serve.service
|
|
|
|
# register: calibre_svc
|
2017-11-20 08:25:53 +00:00
|
|
|
|
2017-11-20 10:27:02 +00:00
|
|
|
- name: Stop Calibre service -- calibre-server by Kovid Goyal
|
|
|
|
# systemd:
|
2017-11-20 08:25:53 +00:00
|
|
|
service:
|
|
|
|
name: calibre-serve
|
|
|
|
state: stopped
|
2017-11-20 10:27:02 +00:00
|
|
|
#enabled: no
|
|
|
|
# register: command_result # gist.github.com/tyrells/0a79681de339237cb04c
|
2017-12-07 16:10:04 +00:00
|
|
|
# failed_when: false # Never Fail during "systemctl stop calibre-serve" (even if service doesn't exist!)
|
2017-11-20 10:27:02 +00:00
|
|
|
# when: calibre_svc.stat.exists
|
2017-11-20 08:25:53 +00:00
|
|
|
|
2018-07-09 07:29:54 +00:00
|
|
|
# 3. CREATE USER DATABASE
|
|
|
|
|
|
|
|
- name: Create /library/calibre (mandatory since Calibre 3.x)
|
|
|
|
file:
|
|
|
|
path: "{{ calibre_dbpath }}"
|
|
|
|
state: directory
|
|
|
|
#mode: 0755
|
|
|
|
|
|
|
|
- name: Copy template userdb to /library/calibre/users.sqlite (IF /usr/bin/calibre WAS MISSING)
|
|
|
|
copy:
|
|
|
|
src: /opt/iiab/iiab/roles/calibre/templates/users.sqlite
|
|
|
|
dest: "{{ calibre_userdb }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
when: (not calib_executable.stat.exists)
|
|
|
|
|
|
|
|
# 4. CREATE CONTENT DATABASE WITH A SAMPLE BOOK (REQUIRED AS OF CALIBRE 3.x)
|
2017-11-20 07:04:40 +00:00
|
|
|
|
2017-11-20 08:01:38 +00:00
|
|
|
- name: Check if /library/calibre/metadata.db exists
|
|
|
|
stat:
|
|
|
|
path: "{{ calibre_dbpath }}/metadata.db"
|
|
|
|
register: calibre_db
|
|
|
|
|
2017-11-20 08:13:00 +00:00
|
|
|
- name: Create database (required since Calibre 3.x) with a sample book
|
|
|
|
include_tasks: create-db.yml
|
2017-11-19 19:53:41 +00:00
|
|
|
when: not calibre_db.stat.exists
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-07-09 07:29:54 +00:00
|
|
|
# 5. WRAP UP: ENABLE CALIBRE SERVICE, http://box/books ETC
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-11-15 18:45:43 +00:00
|
|
|
# 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
|
2017-11-20 07:26:51 +00:00
|
|
|
when: calibre_enabled and is_debuntu
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-11-20 08:01:38 +00:00
|
|
|
- name: Remove calibre.conf link if disabled (debuntu)
|
|
|
|
file:
|
|
|
|
dest: /etc/apache2/sites-enabled/calibre.conf
|
|
|
|
state: absent
|
2017-11-20 08:32:40 +00:00
|
|
|
when: (not calibre_enabled) and is_debuntu
|
2017-11-20 08:01:38 +00:00
|
|
|
|
2017-11-14 15:51:08 +00:00
|
|
|
- name: Enable Calibre service -- runs calibre-server by Kovid Goyal
|
2017-11-15 18:45:43 +00:00
|
|
|
service:
|
|
|
|
name: calibre-serve
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
2017-05-27 18:09:50 +00:00
|
|
|
when: calibre_enabled
|
2017-11-20 08:03:25 +00:00
|
|
|
#async: 900
|
|
|
|
#poll: 5
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2017-12-06 16:44:58 +00:00
|
|
|
- name: Forcing apache to reread configs
|
|
|
|
service:
|
|
|
|
name: "{{ apache_service }}"
|
|
|
|
state: reloaded
|
|
|
|
|
2017-11-27 01:22:16 +00:00
|
|
|
- name: Add 'calibre' to list of services at /etc/iiab/iiab.ini
|
2017-11-15 18:45:43 +00:00
|
|
|
ini_file:
|
|
|
|
dest: "{{ service_filelist }}"
|
|
|
|
section: calibre
|
|
|
|
option: "{{ item.option }}"
|
|
|
|
value: "{{ item.value }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
with_items:
|
2017-11-27 01:22:16 +00:00
|
|
|
- option: name
|
|
|
|
value: Calibre
|
|
|
|
- option: description
|
|
|
|
value: '"Calibre is an extremely popular personal library system for e-books."'
|
|
|
|
- option: url
|
|
|
|
value: "{{ calibre_src_url }}"
|
|
|
|
- option: database
|
|
|
|
value: "{{ calibre_dbpath }}"
|
|
|
|
- option: port
|
|
|
|
value: "{{ calibre_port }}"
|
|
|
|
- option: enabled
|
2017-12-07 16:26:04 +00:00
|
|
|
value: "{{ calibre_enabled }}"
|