Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Librum Server #169

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Librephotos](https://github.com/LibrePhotos/librephotos) - self-hosted open source photo
* [Librespeed](https://github.com/librespeed/speedtest) - Self-hosted Speedtest for HTML5 and more
* [LibreTranslate](https://libretranslate.com/) - Free and Open Source Machine Translation API
* [Librum Server](https://github.com/Librum-Reader/Librum-Server) - A clean and powerful way to read and manage your e-books on any device
* [Lidarr](https://github.com/lidarr/Lidarr) - Music collection manager for Usenet and BitTorrent users
* [Light LDAP](https://github.com/lldap/lldap) - Light LDAP implementation
* [Linkding](https://github.com/sissbruecker/linkding) - Self-hosted bookmark service
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@
tags:
- libretranslate

- role: librum
tags:
- librum

- role: lidarr
tags:
- lidarr
Expand Down
40 changes: 40 additions & 0 deletions roles/librum/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
librum_enabled: false
librum_available_externally: false

# directories
librum_data_directory: "{{ docker_home }}/librum"

# network
librum_port: "5009"
librum_hostname: "librum"
librum_network_name: "librum"

# specs
librum_memory: 1g
librum_db_memory: 1g

# docker
librum_container_name: librum
librum_db_container_name: librum-db
librum_image_name: "ghcr.io/librum-reader/librum-server"
librum_image_version: "latest"
librum_db_image_name: "mariadb"
librum_db_image_version: latest
librum_user_id: "1000"
librum_group_id: "1000"

librum_db_database: "librum"
librum_db_user: "librum"
librum_db_password: "librum"
librum_db_root_password: "supersecure"
librum_jwt_valid_issuer: exampleIssuer
librum_jwt_key: exampleOfALongSecretToken
librum_smtp_endpoint: "smtp.example.com:587"
librum_smtp_username: "mailuser123"
librum_smtp_password: "smtpUserPassword123"
librum_smtp_mail_from: "[email protected]"
librum_db_connection_string: "Server={{ librum_db_container_name }};port=3306;Database={{ librum_db_database }};Uid=root;Pwd={{ librum_db_root_password }};"
librum_admin_email: "[email protected]"
librum_admin_password: "strongPassword123"
librum_open_ai_token: ""
11 changes: 11 additions & 0 deletions roles/librum/docs/librum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Librum Server

Homepage: [https://github.com/Librum-Reader/Librum-Server](https://github.com/Librum-Reader/Librum-Server)

A clean and powerful way to read and manage your e-books on any device.

## Usage

Set `librum_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

Librum web interface can be found at [http://ansible_nas_host_or_ip:5009](http://ansible_nas_host_or_ip:5009).
16 changes: 16 additions & 0 deletions roles/librum/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
platforms:
- name: instance
image: geerlingguy/docker-ubuntu2204-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /var/run/docker.sock:/var/run/docker.sock
- /tmp:/tmp:rw
privileged: true
pre_build_image: true
provisioner:
inventory:
group_vars:
all:
librum_enabled: true
librum_data_directory: "/tmp/librum"
10 changes: 10 additions & 0 deletions roles/librum/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
librum_enabled: false
26 changes: 26 additions & 0 deletions roles/librum/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get librum db container state
community.docker.docker_container:
name: "{{ librum_db_container_name }}"
register: result_db

- name: Get librum container state
community.docker.docker_container:
name: "{{ librum_container_name }}"
register: result

- name: Check if librum containers are running
ansible.builtin.assert:
that:
- result_db.container['State']['Status'] == "running"
- result_db.container['State']['Restarting'] == false
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
26 changes: 26 additions & 0 deletions roles/librum/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove librum
community.docker.docker_container:
name: "{{ librum_container_name }}"
state: absent
register: result

- name: Try and stop and remove librum db
community.docker.docker_container:
name: "{{ librum_db_container_name }}"
state: absent
register: result_db

- name: Check if librum is stopped
ansible.builtin.assert:
that:
- not result.changed
- not result_db.changed
1 change: 1 addition & 0 deletions roles/librum/requirements.yml
89 changes: 89 additions & 0 deletions roles/librum/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
- name: Start Librum
block:
- name: Create Librum Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: 999
group: 999
with_items:
- "{{ librum_data_directory }}"
- "{{ librum_data_directory }}/data"

- name: Create Librum network
community.docker.docker_network:
name: "{{ librum_network_name }}"

- name: Create Librum database container
community.docker.docker_container:
name: "{{ librum_db_container_name }}"
image: "{{ librum_db_image_name }}:{{ librum_db_image_version }}"
networks:
- name: "{{ librum_network_name }}"
network_mode: "{{ librum_network_name }}"
pull: true
volumes:
- "{{ librum_data_directory }}/mariadb_data:/var/lib/mysql"
env:
MARIADB_DATABASE: "{{ librum_db_database }}"
MARIADB_USER: "{{ librum_db_user }}"
MARIADB_PASSWORD: "{{ librum_db_password }}"
MARIADB_ROOT_PASSWORD: "{{ librum_db_root_password }}"
restart_policy: unless-stopped
memory: "{{ librum_db_memory }}"
labels:
traefik.enable: "false"
healthcheck:
test: ["CMD", "mariadb-admin", "ping", "-u", "root", "-p'{{ librum_db_root_password }}'", "-h", "localhost"]
interval: 20s
timeout: 40s
retries: 3
start_period: 30s

- name: Create Librum Docker Container
community.docker.docker_container:
name: "{{ librum_container_name }}"
image: "{{ librum_image_name }}:{{ librum_image_version }}"
networks:
- name: "{{ librum_network_name }}"
network_mode: "{{ librum_network_name }}"
pull: true
volumes:
- "{{ librum_data_directory }}/data:/var/lib/librum-server/librum_storage"
ports:
- "{{ librum_port }}:5000"
env:
JWTValidIssuer: "{{ librum_jwt_valid_issuer }}"
JWTKey: "{{ librum_jwt_key }}"
SMTPEndpoint: "{{ librum_smtp_endpoint }}"
SMTPUsername: "{{ librum_smtp_username }}"
SMTPPassword: "{{ librum_smtp_password }}"
SMTPMailFrom: "{{ librum_smtp_mail_from }}"
DBConnectionString: "{{ librum_db_connection_string }}"
AdminEmail: "{{ librum_admin_email }}"
AdminPassword: "{{ librum_admin_password }}"
# OpenAIToken: "{{ librum_open_ai_token }}"
restart_policy: unless-stopped
memory: "{{ librum_memory }}"
labels:
traefik.enable: "{{ librum_available_externally | string }}"
traefik.http.routers.librum.rule: "Host(`{{ librum_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.librum.tls.certresolver: "letsencrypt"
traefik.http.routers.librum.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.librum.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.librum.loadbalancer.server.port: "5000"
when: librum_enabled is true

- name: Stop Librum
block:
- name: Stop Librum
community.docker.docker_container:
name: "{{ librum_container_name }}"
state: absent

- name: Stop Librum DB
community.docker.docker_container:
name: "{{ librum_db_container_name }}"
state: absent
when: librum_enabled is false
14 changes: 14 additions & 0 deletions website/docs/applications/media-serving/librum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Librum Server"
description: "A clean and powerful way to read and manage your e-books on any device."
---

Homepage: [https://github.com/Librum-Reader/Librum-Server](https://github.com/Librum-Reader/Librum-Server)

The Librum-Server includes the API, database, and other fundamental infrastructure required for the "backend" of all Librum client applications and the website.

## Usage

Set `tooljet_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

Librum web interface can be found at [http://ansible_nas_host_or_ip:5009](http://ansible_nas_host_or_ip:5009).
Loading