diff --git a/roles/audiobookshelf/files/audiobookshelf.default b/roles/audiobookshelf/files/audiobookshelf.default new file mode 100644 index 0000000..4b553f5 --- /dev/null +++ b/roles/audiobookshelf/files/audiobookshelf.default @@ -0,0 +1,4 @@ +METADATA_PATH=/srv/audiobookshelf/metadata +CONFIG_PATH=/srv/audiobookshelf/config +PORT=13378 +HOST=127.0.0.1 diff --git a/roles/audiobookshelf/files/meta.md b/roles/audiobookshelf/files/meta.md new file mode 100644 index 0000000..5e22e02 --- /dev/null +++ b/roles/audiobookshelf/files/meta.md @@ -0,0 +1,30 @@ += Preparing files for upload = + +== Filenames == + +Filenames should always contain track number (and optionally disc number) with leading zeros first and subtitle after that. Few exmaples: + +``` +01. Luku.mp3 +01. Osa.mp3 +CD 1 - 01.mp3 +``` + +Directory should also contain `cover.jpg` with book cover picture and `desc.txt` containing book description. + +== Metadata (id3 tags) == + +First clear old tags then set new ones: + +``` +id3v2 -D "01. Osa.mp3" +id3v2 \ + --TPE1 "Douglas Adams" \ + --TALB "$(echo 'Linnunradan käsikirja liftareille' | iconv -f utf-8 -t iso-8859-1)" \ + --TCOM "$(echo 'Heikki Kinnunen,Pekka Autiovuori,Yrjö Järvinen,Martti Järvinen,Esa Saario,Kauko Helavirta,Aila Svedberg' | iconv -f utf-8 -t iso-8859-1)" \ + --TLAN "fi" \ + --TPUB "Yleisradio" \ + --TYER 1984 \ + --genre "Science Fiction/Fiction/Humor" \ + "01. Osa.mp3" +``` diff --git a/roles/audiobookshelf/handlers/main.yml b/roles/audiobookshelf/handlers/main.yml new file mode 100644 index 0000000..fd2df00 --- /dev/null +++ b/roles/audiobookshelf/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Restart audiobookshelf + ansible.builtin.service: + name: audiobookshelf + state: restarted diff --git a/roles/audiobookshelf/meta/main.yml b/roles/audiobookshelf/meta/main.yml new file mode 100644 index 0000000..954fabd --- /dev/null +++ b/roles/audiobookshelf/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - {role: nginx} diff --git a/roles/audiobookshelf/tasks/main.yml b/roles/audiobookshelf/tasks/main.yml new file mode 100644 index 0000000..1bc2f99 --- /dev/null +++ b/roles/audiobookshelf/tasks/main.yml @@ -0,0 +1,90 @@ +--- +- name: Enable repository + ansible.builtin.yum_repository: + name: audiobookshelf + baseurl: https://raw.githubusercontent.com/lkiesow/audiobookshelf-rpm/el$releasever/ + description: Audiobookshelf el$releasever repository + gpgcheck: true + gpgkey: https://raw.githubusercontent.com/lkiesow/audiobookshelf-rpm/main/audiobookshelf-rpm.key + enabled: true + +- name: Install packcages + ansible.builtin.package: + name: audiobookshelf + state: present + +- name: Create data directories + ansible.builtin.file: + path: "{{ item }}" + state: directory + mode: "0770" + owner: root + group: audiobookshelf + with_items: + - /export/audiobookshelf + - /export/audiobookshelf/audiobooks + - /export/audiobookshelf/config + - /export/audiobookshelf/metadata + - /export/audiobookshelf/podcasts + - /export/audiobookshelf/radioplays + +- name: Link data directory + ansible.builtin.file: + dest: /srv/audiobookshelf + src: /export/audiobookshelf + state: link + owner: root + group: "{{ ansible_wheel }}" + follow: false + +- name: Copy naming instructions + ansible.builtin.copy: + dest: /srv/audiobookshelf/audiobooks/README.md + src: meta.md + mode: "0644" + owner: root + group: "{{ ansible_wheel }}" + +- name: Copy service config + ansible.builtin.copy: + dest: /etc/default/audiobookshelf + src: audiobookshelf.default + mode: "0644" + owner: root + group: "{{ ansible_wheel }}" + notify: Restart audiobookshelf + +- name: Enable service + ansible.builtin.service: + name: audiobookshelf + state: started + enabled: true + +- name: Allow nginx to connect audiobookshelf + ansible.posix.seboolean: + name: httpd_can_network_connect + state: true + persistent: true + +- name: Copy nginx config + ansible.builtin.copy: + dest: "/etc/nginx/conf.d/{{ inventory_hostname }}/audiobookshelf.conf" + content: | + location / { + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host audiobooks.foo.sh; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_http_version 1.1; + proxy_pass http://127.0.0.1:13378/; + location /audiobookshelf/api/upload { + # increase size to allow uploads + client_max_body_size 10g; + proxy_pass http://127.0.0.1:13378/api/upload; + } + } + mode: "0644" + owner: root + group: "{{ ansible_wheel }}" + notify: Restart nginx