Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
56a79e7
reuse config_vars.yml for installed app tracking
jvonau Sep 5, 2019
ab39fe9
rename 'test_kalite_installed' add installed tracker
jvonau Sep 5, 2019
8fab1e5
kiwix rework and add iiab_installed
jvonau Sep 5, 2019
ebfc137
kolibri rework and add iiab_installed
jvonau Sep 5, 2019
d1e01e8
sugarizer rework and add iiab_installed
jvonau Sep 5, 2019
7c6274e
moodle rework and add iiab_installed
jvonau Sep 5, 2019
bae9084
elgg rework and add iiab_installed
jvonau Sep 1, 2019
5e62904
wordpress db setup and installed tracker
jvonau Sep 1, 2019
9dab734
nextcloud add iiab_installed and tweeks
jvonau Sep 1, 2019
529b170
awstats split and iiab_installed
jvonau Sep 5, 2019
9151498
use lineinfile
jvonau Sep 9, 2019
1e14cab
azuracast - iiab_installed
jvonau Sep 14, 2019
9756860
bluetooth - iiab_installed
jvonau Sep 14, 2019
4463e4e
calibre-web - iiab_installed
jvonau Sep 14, 2019
24f1b4f
calibre - iiab_installed
jvonau Sep 14, 2019
e7ea453
dokuwiki - iiab_installed
jvonau Sep 14, 2019
3de43a3
gitea - iiab_installed
jvonau Sep 14, 2019
4094edc
lokole - iiab_installed
jvonau Sep 14, 2019
cb5e640
mediawiki - iiab_installed
jvonau Sep 14, 2019
8302811
minetest - iiab_installed
jvonau Sep 14, 2019
a311a0f
mosquitto - iiab_installed
jvonau Sep 14, 2019
130e6a2
munin - iiab_installed
jvonau Sep 14, 2019
9565410
nodered - iiab_installed
jvonau Sep 15, 2019
2807fbc
needs True
jvonau Oct 7, 2019
5b183e1
mongodb - iiab_installed
jvonau Oct 14, 2019
c63f9ba
provide ICO fuctionality at cmdline
jvonau Oct 10, 2019
8c74448
iiab-configure - deal with web services only
jvonau Oct 16, 2019
02fe653
use config_vars2 in source yaml files
jvonau Oct 1, 2019
4e52e41
mongo installed on image but not recorded workaround
jvonau Oct 14, 2019
d8df590
iiab-install can use faster code if /etc/iiab/config_vars2.yml exists
jvonau Oct 15, 2019
46f48fa
remove when install
jvonau Oct 15, 2019
83546e5
runrole --reinstall to remove role installed marker
jvonau Oct 16, 2019
2265a24
create config_vars2.yml at start of stage-4
jvonau Oct 16, 2019
ce2ec3b
kiwix allow reinstall/updates with runrole --reinstall
jvonau Oct 16, 2019
ddf8e1d
stage 4 installed
jvonau Oct 16, 2019
c396f44
cmdline tweeks
jvonau Oct 16, 2019
b67a19c
network guard against faulty user edits to local_vars
jvonau Oct 16, 2019
8423d73
runrole - ensure local_vars has *_install is set to True
jvonau Oct 17, 2019
a66b650
iiab_state
jvonau Oct 24, 2019
800ae2f
iiab_state2
jvonau Oct 24, 2019
9a0e054
Merge pull request #305 from iiab/master
holta Oct 24, 2019
626473e
Merge pull request #306 from jvonau/installed
holta Oct 24, 2019
b533cb6
#2008 var names, output, comments, small bugs
holta Oct 25, 2019
5ae521d
double-double-quote vars in echo for safety etc
holta Oct 25, 2019
217fdc5
Fix var name captive_portal_installed (not captiveportal_installed)
holta Oct 25, 2019
1604d8e
Remove 2 unnec '| bool' clauses
holta Oct 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
calibre - iiab_installed
  • Loading branch information
jvonau committed Oct 24, 2019
commit 24f1b4fa537ea9bd3889c75c4493263da04b914d
54 changes: 54 additions & 0 deletions roles/calibre/tasks/enable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 5. WRAP UP: ENABLE CALIBRE SERVICE, http://box/books ETC

# http://box:8080 & http://box:8080/mobile WORK BUT OTHER URL'S LIKE http://box/calibre ARE A MESS (BOOKS RARELY DISPLAY)
#
# 2018-08-27 POSSIBLE FIX...CONSIDER THIS ProxyPass / ProxyPassReverse TECHNIQUE:
# https://github.com/iiab/iiab/tree/master/roles/calibre-web/templates/calibre-web.conf.j2
# (anyway this works great for calibre-web, allowing http://box/books
# to work even better than http://box:8083 when box == 192.168.0.x !)
- name: Create symlink calibre.conf from sites-enabled to sites-available, for UNTESTED http://box/calibre etc (debuntu)
file:
src: /etc/apache2/sites-available/calibre.conf
dest: /etc/apache2/sites-enabled/calibre.conf
state: link
when: calibre_enabled and is_debuntu

- name: Remove symlink /etc/apache2/sites-enabled/calibre.conf (debuntu)
file:
dest: /etc/apache2/sites-enabled/calibre.conf
state: absent
when: (not calibre_enabled) and is_debuntu

- name: Enable & Start service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal)
service:
name: calibre-serve
enabled: yes
state: started
when: calibre_enabled | bool
#async: 900
#poll: 5

- name: Reload Apache service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
state: reloaded

- name: Add 'calibre' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: calibre
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- 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: calibre_enabled
value: "{{ calibre_enabled }}"
87 changes: 87 additions & 0 deletions roles/calibre/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# 1. INSTALL THE LATEST CALIBRE 3.X+ (calibre, calibredb, calibre-server etc) ON ALL OS'S

- name: Does /usr/bin/calibre exist?
stat:
path: "/usr/bin/calibre"
register: calib_executable

- name: "Install OS's latest packages: calibre, calibre-bin (IF not rpi AND /usr/bin/calibre MISSING)"
package:
name:
- calibre
- calibre-bin
state: latest
when: internet_available and not is_rpi and (not calib_executable.stat.exists)

- name: Install Calibre .debs IF calibre_via_debs (AND /usr/bin/calibre WAS MISSING)
include_tasks: debs.yml
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)

# 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

- name: Create calibre-serve.service and calibre.conf (IF /usr/bin/calibre WAS MISSING)
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: "{{ item.mode }}"
backup: no
#register: calibre_config
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: (not calib_executable.stat.exists)

- name: Stop service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal)
systemd:
name: calibre-serve
state: stopped
daemon_reload: yes

# 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)

- name: Does /library/calibre/metadata.db exist?
stat:
path: "{{ calibre_dbpath }}/metadata.db"
register: calibre_db

- name: Create database (required since Calibre 3.x) with a sample book
include_tasks: create-db.yml
when: not calibre_db.stat.exists

- name: Add 'calibre_installed' variable values to {{ iiab_installed }}
lineinfile:
dest: "{{ iiab_installed }}"
regexp: '^calibreweb_installed'
line: 'calibre_installed'
state: present
154 changes: 4 additions & 150 deletions roles/calibre/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,151 +1,5 @@
# 1. INSTALL THE LATEST CALIBRE 3.X+ (calibre, calibredb, calibre-server etc) ON ALL OS'S
- include_tasks: install.yml
when: calibre_install and not calibre_installed is defined

- name: Does /usr/bin/calibre exist?
stat:
path: "/usr/bin/calibre"
register: calib_executable

- name: "Install OS's latest packages: calibre, calibre-bin (IF not rpi AND /usr/bin/calibre MISSING)"
package:
name:
- calibre
- calibre-bin
state: latest
when: internet_available and not is_rpi and (not calib_executable.stat.exists)

- name: Install Calibre .debs IF calibre_via_debs (AND /usr/bin/calibre WAS MISSING)
include_tasks: debs.yml
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)

# 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

- name: Create calibre-serve.service and calibre.conf (IF /usr/bin/calibre WAS MISSING)
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: "{{ item.mode }}"
backup: no
#register: calibre_config
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: (not calib_executable.stat.exists)

- name: Force systemd to reread configs (IF /usr/bin/calibre WAS MISSING)
systemd:
daemon_reload: yes
when: (not calib_executable.stat.exists)
#when: calibre_config.changed

# 2. STOP CALIBRE SERVICE (REQUIRED FOR DB ACTIVITY...AND IF not calibre_enabled)

#- name: Check if Calibre systemd service exists
# stat:
# path: /etc/systemd/system/calibre-serve.service
# register: calibre_svc

- name: Stop service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal)
systemd:
name: calibre-serve
state: stopped
#enabled: no
#register: command_result # gist.github.com/tyrells/0a79681de339237cb04c
#failed_when: False # Never Fail during "systemctl stop calibre-serve" (even if service doesn't exist!)
#when: calibre_svc.stat.exists

# 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)

- name: Does /library/calibre/metadata.db exist?
stat:
path: "{{ calibre_dbpath }}/metadata.db"
register: calibre_db

- name: Create database (required since Calibre 3.x) with a sample book
include_tasks: create-db.yml
when: not calibre_db.stat.exists

# 5. WRAP UP: ENABLE CALIBRE SERVICE, http://box/books ETC

# http://box:8080 & http://box:8080/mobile WORK BUT OTHER URL'S LIKE http://box/calibre ARE A MESS (BOOKS RARELY DISPLAY)
#
# 2018-08-27 POSSIBLE FIX...CONSIDER THIS ProxyPass / ProxyPassReverse TECHNIQUE:
# https://github.com/iiab/iiab/tree/master/roles/calibre-web/templates/calibre-web.conf.j2
# (anyway this works great for calibre-web, allowing http://box/books
# to work even better than http://box:8083 when box == 192.168.0.x !)
- name: Create symlink calibre.conf from sites-enabled to sites-available, for UNTESTED http://box/calibre etc (debuntu)
file:
src: /etc/apache2/sites-available/calibre.conf
dest: /etc/apache2/sites-enabled/calibre.conf
state: link
when: calibre_enabled and is_debuntu

- name: Remove symlink /etc/apache2/sites-enabled/calibre.conf (debuntu)
file:
dest: /etc/apache2/sites-enabled/calibre.conf
state: absent
when: (not calibre_enabled) and is_debuntu

- name: Enable & Start service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal)
service:
name: calibre-serve
enabled: yes
state: started
when: calibre_enabled | bool
#async: 900
#poll: 5

- name: Reload Apache service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
state: reloaded

- name: Add 'calibre' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: calibre
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- 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: calibre_enabled
value: "{{ calibre_enabled }}"
- include_tasks: enable.yml
when: calibre_install or calibre_installed is defined