diff --git a/calibre/CHANGELOG.md b/calibre/CHANGELOG.md new file mode 100644 index 000000000..66f7e8b76 --- /dev/null +++ b/calibre/CHANGELOG.md @@ -0,0 +1 @@ +- Initial release diff --git a/calibre/Dockerfile b/calibre/Dockerfile new file mode 100644 index 000000000..6c65d85a5 --- /dev/null +++ b/calibre/Dockerfile @@ -0,0 +1,109 @@ +#============================# +# ALEXBELGIUM'S DOCKERFILE # +#============================# +# _.------. +# _.-` ('>.-`"""-. +# '.--'` _'` _ .--.) +# -' '-.-';` ` +# ' - _.' ``'--. +# '---` .-'""` +# /` +#=== Home Assistant Addon ===# + +################# +# 1 Build Image # +################# + +ARG BUILD_FROM +ARG BUILD_VERSION +FROM ${BUILD_FROM} +ENV BASHIO_VERSION=1.29.1 + +################## +# 2 Modify Image # +################## + +# Allow UID and GID setting +RUN sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ + \ + # Change home folder location + && sed -i 's|/config|/config/addons_config/addons_config/calibre|g' /defaults/* \ + && sed -i 's|/config|/config/addons_config/addons_config/calibre|g' /etc/cont-init.d/* \ + && sed -i 's|/config|/config/addons_config/addons_config/calibre|g' /etc/services.d/*/run \ + && usermod --home /config/addons_config/addons_config/calibre abc \ + \ + # Correct error in upstream image + && sed -i 's|startwm |startwm.sh |g' /etc/cont-init.d/30-config \ + \ + # Update distribution + # hadolint ignore=DL3017 + && apk upgrade --no-cache + +################## +# 3 Install apps # +################## + +# Copy local files +COPY rootfs/ / + +# Modules +ARG MODULES="00-banner.sh 00-global_var.sh 92-local_mounts.sh 92-smb_mounts.sh" + +# Automatic modules download +RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && mkdir -p /etc/cont-init.d \ + && for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \ + && chmod -R 755 /etc/cont-init.d || printf '%s\n' "${MODULES}" >/MODULESFILE + +# Manual apps +ENV PACKAGES="" + +# Automatic apps & bashio +RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \ + && chmod 777 /automatic_packages.sh \ + && eval /./automatic_packages.sh "${PACKAGES:-}" \ + && rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] + +############ +# 5 Labels # +############ + +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_DESCRIPTION +ARG BUILD_NAME +ARG BUILD_REF +ARG BUILD_REPOSITORY +ARG BUILD_VERSION +LABEL \ + io.hass.name="${BUILD_NAME}" \ + io.hass.description="${BUILD_DESCRIPTION}" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.title="${BUILD_NAME}" \ + org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ + org.opencontainers.image.vendor="Home Assistant Add-ons" \ + org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.url="https://github.com/alexbelgium" \ + org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ + org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ + org.opencontainers.image.created=${BUILD_DATE} \ + org.opencontainers.image.revision=${BUILD_REF} \ + org.opencontainers.image.version=${BUILD_VERSION} diff --git a/calibre/Readme.md b/calibre/Readme.md new file mode 100644 index 000000000..b63687155 --- /dev/null +++ b/calibre/Readme.md @@ -0,0 +1,72 @@ +# Home assistant add-on: calibre + +[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium) + +![Version](https://img.shields.io/badge/dynamic/json?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fcalibre%2Fconfig.json) +![Ingress](https://img.shields.io/badge/dynamic/json?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fcalibre%2Fconfig.json) +![Arch](https://img.shields.io/badge/dynamic/json?color=success&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fcalibre%2Fconfig.json) + +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9c6cf10bdbba45ecb202d7f579b5be0e)](https://www.codacy.com/gh/alexbelgium/hassio-addons/dashboard?utm_source=github.com&utm_medium=referral&utm_content=alexbelgium/hassio-addons&utm_campaign=Badge_Grade) +[![GitHub Super-Linter](https://github.com/alexbelgium/hassio-addons/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter) +[![Builder](https://github.com/alexbelgium/hassio-addons/workflows/Builder/badge.svg)](https://github.com/alexbelgium/hassio-addons/actions/workflows/builder.yaml) + +[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white + +_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_ + +[![Stargazers repo roster for @alexbelgium/hassio-addons](https://reporoster.com/stars/alexbelgium/hassio-addons)](https://github.com/alexbelgium/hassio-addons/stargazers) + +## About + +--- + +[Calibre](https://calibre-ebook.com/) is a powerful and easy to use e-book manager. Users say it’s outstanding and a must-have. It’ll allow you to do nearly everything and it takes things a step beyond normal e-book software. It’s also completely free and open source and great for both casual users and computer experts. + +This addon is based on the docker image https://github.com/linuxserver/docker-calibre + +## Installation + +--- + +The installation of this add-on is pretty straightforward and not different in comparison to installing any other add-on. + +1. Add my add-ons repository to your home assistant instance (in supervisor addons store at top right, or click button below if you have configured my HA) + [![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Falexbelgium%2Fhassio-addons) +1. Install this add-on. +1. Click the `Save` button to store your configuration. +1. Set the add-on options to your preferences +1. Start the add-on. +1. Check the logs of the add-on to see if everything went well. +1. Open the webUI and adapt the software options + +## Configuration + +--- + +Webui can be found at . +The default username/password : described in the startup log. +Configurations can be done through the app webUI, except for the following options + +```yaml +GUID: user +GPID: user +TZ: timezone +PASSWORD: Optionally set a password for the gui +CLI_ARGS: Optionally pass cli start arguments to calibre +localdisks: sda1 #put the hardware name of your drive to mount separated by commas, or its label. Ex: sda1, sdb1, MYNAS... +networkdisks: "//SERVER/SHARE" # optional, list of smb servers to mount, separated by commas +cifsusername: "username" # optional, smb username, same for all smb shares +cifspassword: "password" # optional, smb password +``` + +## Support + +Create an issue on github + +## Illustration + +--- + +![illustration](https://calibre.com/img/slider/artistdetails.png) + +[repository]: https://github.com/alexbelgium/hassio-addons diff --git a/calibre/apparmor.txt b/calibre/apparmor.txt new file mode 100644 index 000000000..17f52ab7d --- /dev/null +++ b/calibre/apparmor.txt @@ -0,0 +1,56 @@ +#include + +profile calibre_addon flags=(attach_disconnected,mediate_deleted) { + #include + + capability, + file, + signal, + mount, + umount, + remount, + network udp, + network tcp, + network dgram, + network stream, + network inet, + network inet6, + network netlink raw, + + capability setgid, + capability setuid, + capability sys_admin, + capability dac_read_search, + # capability dac_override, + # capability sys_rawio, + +# S6-Overlay + /bin/** ix, + /usr/bin/** ix, + /usr/lib/bashio/** ix, + /etc/s6/** rix, + /run/s6/** rix, + /etc/services.d/** rwix, + /etc/cont-init.d/** rwix, + /etc/cont-finish.d/** rwix, + /init rix, + /var/run/** mrwkl, + /var/run/ mrwkl, + /dev/i2c-1 mrwkl, + # Files required + /dev/sda1 mrwkl, + /dev/sdb1 mrwkl, + /dev/mmcblk0p1 mrwkl, + /dev/* mrwkl, + /tmp/** mrkwl, + + # Data access + /data/** rw, + + # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container + ptrace (trace,read) peer=docker-default, + + # docker daemon confinement requires explict allow rule for signal + signal (receive) set=(kill,term) peer=/usr/bin/docker, + +} diff --git a/calibre/build.json b/calibre/build.json new file mode 100644 index 000000000..7af98d690 --- /dev/null +++ b/calibre/build.json @@ -0,0 +1,10 @@ +{ + "build_from": { + "aarch64": "lscr.io/linuxserver/calibre:arm64v8-latest", + "amd64": "lscr.io/linuxserver/calibre:amd64-latest", + "armv7": "lscr.io/linuxserver/calibre:arm32v7-latest" + }, + "codenotary": { + "signer": "alexandrep.github@gmail.com" + } +} \ No newline at end of file diff --git a/calibre/config.json b/calibre/config.json new file mode 100644 index 000000000..aa39d212d --- /dev/null +++ b/calibre/config.json @@ -0,0 +1,86 @@ +{ + "arch": [ + "aarch64", + "amd64", + "armv7" + ], + "codenotary": "alexandrep.github@gmail.com", + "description": "Request management and media discovery tool built to work with your existing Plex ecosystem", + "devices": [ + "/dev/sda", + "/dev/sdb", + "/dev/sdc", + "/dev/sdd", + "/dev/sde", + "/dev/sdf", + "/dev/sdg", + "/dev/nvme", + "/dev/mmcblk", + "/dev/sda1", + "/dev/sdb1", + "/dev/sdc1", + "/dev/sdd1", + "/dev/sde1", + "/dev/sdf1", + "/dev/sdg1", + "/dev/sda2", + "/dev/sdb2", + "/dev/sdc2", + "/dev/sdd2", + "/dev/sde2", + "/dev/sdf2", + "/dev/sdg2", + "/dev/sda3", + "/dev/sdb3", + "/dev/sda4", + "/dev/sdb4", + "/dev/nvme0", + "/dev/nvme1", + "/dev/nvme2" + ], + "environment": { + "PGID": "0", + "PUID": "0", + "CALIBRE_CONFIG_DIRECTORY": "/config/addons_config/calibre", + "FM_HOME": "/config/addons_config/calibre", + "HOME": "/config/addons_config/calibre", + "shm_size": "1gb" + }, + "ingress": true, + "map": [ + "media:rw", + "share:rw", + "ssl" + ], + "name": "Calibre", + "options": { + "PGID": 0, + "PUID": 0 + }, + "panel_icon": "mdi:monitor", + "ports": { + "8080/tcp": 8080, + "8081/tcp": 8081, + }, + "ports_description": { + "8080/tcp": "Calibre desktop gui" + "8081/tcp": "Calibre webserver gui" + }, + "privileged": [], + "schema": { + "PGID": "int", + "PUID": "int", + "TZ": "str?", + "PASSWORD": "str?", + "CLI_ARGS": "str?", + "cifspassword": "str?", + "cifsusername": "str?", + "localdisks": "str?", + "networkdisks": "str?" + }, + "slug": "calibre", + "url": "https://github.com/alexbelgium/hassio-addons/tree/master/calibre", + "version": "1.29.1", + "webui": "http://[HOST]:[PORT:8080]", + "video": true +} \ No newline at end of file diff --git a/calibre/icon.png b/calibre/icon.png new file mode 100644 index 000000000..6f28f70d1 Binary files /dev/null and b/calibre/icon.png differ diff --git a/calibre/logo.png b/calibre/logo.png new file mode 100644 index 000000000..6f28f70d1 Binary files /dev/null and b/calibre/logo.png differ diff --git a/calibre/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/calibre/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..8989b365f --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && mkdir -p /etc/cont-init.d \ + && for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \ + && chmod -R 755 /etc/cont-init.d +fi + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \ + && chmod 777 /automatic_packages.sh \ + && eval /./automatic_packages.sh "${PACKAGES:-}" \ + && rm /automatic_packages.sh +fi diff --git a/calibre/rootfs/etc/cont-init.d/00-data_location.sh b/calibre/rootfs/etc/cont-init.d/00-data_location.sh new file mode 100644 index 000000000..895b62a8d --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/00-data_location.sh @@ -0,0 +1,47 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# Define user +PUID=$(bashio::config "PUID") +PGID=$(bashio::config "PGID") + +# Check data location +LOCATION=$(bashio::config 'data_location') + +if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then + # Default location + LOCATION="/config/addons_config/addons_config/calibre" +else + bashio::log.warning "Warning : a custom data location was selected, but the previous folder will NOT be copied. You need to do it manually" + + # Check if config is located in an acceptable location + LOCATIONOK="" + for location in "/share" "/config" "/data" "/mnt"; do + if [[ "$LOCATION" == "$location"* ]]; then + LOCATIONOK=true + fi + done + + if [ -z "$LOCATIONOK" ]; then + LOCATION=/config/addons_config/${HOSTNAME#*-} + bashio::log.fatal "Your data_location value can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $LOCATION" + fi + +fi + +# Set data location +bashio::log.info "Setting data location to $LOCATION" +sed -i "1a export HOME=$LOCATION" /etc/services.d/web/run +sed -i "1a export FM_HOME=$LOCATION" /etc/services.d/web/run +sed -i "s|/config/addons_config/addons_config/calibre|$LOCATION|g" /defaults/* +sed -i "s|/config/addons_config/addons_config/calibre|$LOCATION|g" /etc/cont-init.d/* +sed -i "s|/config/addons_config/addons_config/calibre|$LOCATION|g" /etc/services.d/*/run +usermod --home "$LOCATION" abc + +# Create folder +echo "Creating $LOCATION" +mkdir -p "$LOCATION" + +# Set ownership +bashio::log.info "Setting ownership to $PUID:$PGID" +chown "$PUID":"$PGID" "$LOCATION" diff --git a/calibre/rootfs/etc/cont-init.d/20-folders.sh b/calibre/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..a84c02095 --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ ! -d /config/addons_config/calibre ]; then + echo "Creating /config/addons_config/calibre" + mkdir -p /config/addons_config/calibre +fi + +chown -R abc:abc /config/addons_config/calibre diff --git a/calibre/rootfs/etc/cont-init.d/32-nginx.sh b/calibre/rootfs/etc/cont-init.d/32-nginx.sh new file mode 100644 index 000000000..6ac38a5b6 --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/32-nginx.sh @@ -0,0 +1,33 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare port +declare certfile +declare ingress_interface +declare ingress_port +declare keyfile + +port=$(bashio::addon.port 80) +if bashio::var.has_value "${port}"; then + bashio::config.require.ssl + + if bashio::config.true 'ssl'; then + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf + sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf + sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf + + else + mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf + fi +fi + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf diff --git a/calibre/rootfs/etc/nginx/includes/mime.types b/calibre/rootfs/etc/nginx/includes/mime.types new file mode 100644 index 000000000..7c7cdef2d --- /dev/null +++ b/calibre/rootfs/etc/nginx/includes/mime.types @@ -0,0 +1,96 @@ +types { + text/html html htm shtml; + text/css css; + text/xml xml; + image/gif gif; + image/jpeg jpeg jpg; + application/javascript js; + application/atom+xml atom; + application/rss+xml rss; + + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/x-component htc; + + image/png png; + image/svg+xml svg svgz; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/webp webp; + image/x-icon ico; + image/x-jng jng; + image/x-ms-bmp bmp; + + font/woff woff; + font/woff2 woff2; + + application/java-archive jar war ear; + application/json json; + application/mac-binhex40 hqx; + application/msword doc; + application/pdf pdf; + application/postscript ps eps ai; + application/rtf rtf; + application/vnd.apple.mpegurl m3u8; + application/vnd.google-earth.kml+xml kml; + application/vnd.google-earth.kmz kmz; + application/vnd.ms-excel xls; + application/vnd.ms-fontobject eot; + application/vnd.ms-powerpoint ppt; + application/vnd.oasis.opendocument.graphics odg; + application/vnd.oasis.opendocument.presentation odp; + application/vnd.oasis.opendocument.spreadsheet ods; + application/vnd.oasis.opendocument.text odt; + application/vnd.openxmlformats-officedocument.presentationml.presentation + pptx; + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + xlsx; + application/vnd.openxmlformats-officedocument.wordprocessingml.document + docx; + application/vnd.wap.wmlc wmlc; + application/x-7z-compressed 7z; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/xhtml+xml xhtml; + application/xspf+xml xspf; + application/zip zip; + + application/octet-stream bin exe dll; + application/octet-stream deb; + application/octet-stream dmg; + application/octet-stream iso img; + application/octet-stream msi msp msm; + + audio/midi mid midi kar; + audio/mpeg mp3; + audio/ogg ogg; + audio/x-m4a m4a; + audio/x-realaudio ra; + + video/3gpp 3gpp 3gp; + video/mp2t ts; + video/mp4 mp4; + video/mpeg mpeg mpg; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-m4v m4v; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; +} diff --git a/calibre/rootfs/etc/nginx/includes/proxy_params.conf b/calibre/rootfs/etc/nginx/includes/proxy_params.conf new file mode 100644 index 000000000..1990d4959 --- /dev/null +++ b/calibre/rootfs/etc/nginx/includes/proxy_params.conf @@ -0,0 +1,15 @@ +proxy_http_version 1.1; +proxy_ignore_client_abort off; +proxy_read_timeout 86400s; +proxy_redirect off; +proxy_send_timeout 86400s; +proxy_max_temp_file_size 0; + +proxy_set_header Accept-Encoding ""; +proxy_set_header Connection $connection_upgrade; +proxy_set_header Host $http_host; +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_set_header X-NginX-Proxy true; +proxy_set_header X-Real-IP $remote_addr; diff --git a/calibre/rootfs/etc/nginx/includes/resolver.conf b/calibre/rootfs/etc/nginx/includes/resolver.conf new file mode 100644 index 000000000..6485af141 --- /dev/null +++ b/calibre/rootfs/etc/nginx/includes/resolver.conf @@ -0,0 +1 @@ +resolver 127.0.0.11; diff --git a/calibre/rootfs/etc/nginx/includes/server_params.conf b/calibre/rootfs/etc/nginx/includes/server_params.conf new file mode 100644 index 000000000..09c06543e --- /dev/null +++ b/calibre/rootfs/etc/nginx/includes/server_params.conf @@ -0,0 +1,6 @@ +root /dev/null; +server_name $hostname; + +add_header X-Content-Type-Options nosniff; +add_header X-XSS-Protection "1; mode=block"; +add_header X-Robots-Tag none; diff --git a/calibre/rootfs/etc/nginx/includes/ssl_params.conf b/calibre/rootfs/etc/nginx/includes/ssl_params.conf new file mode 100644 index 000000000..6f1500599 --- /dev/null +++ b/calibre/rootfs/etc/nginx/includes/ssl_params.conf @@ -0,0 +1,9 @@ +ssl_protocols TLSv1.2; +ssl_prefer_server_ciphers on; +ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA; +ssl_ecdh_curve secp384r1; +ssl_session_timeout 10m; +ssl_session_cache shared:SSL:10m; +ssl_session_tickets off; +ssl_stapling on; +ssl_stapling_verify on; diff --git a/calibre/rootfs/etc/nginx/includes/upstream.conf b/calibre/rootfs/etc/nginx/includes/upstream.conf new file mode 100644 index 000000000..b292326bd --- /dev/null +++ b/calibre/rootfs/etc/nginx/includes/upstream.conf @@ -0,0 +1,3 @@ +upstream backend { + server 127.0.0.1:8080; +} diff --git a/calibre/rootfs/etc/nginx/nginx.conf b/calibre/rootfs/etc/nginx/nginx.conf new file mode 100644 index 000000000..7e5bc6f7c --- /dev/null +++ b/calibre/rootfs/etc/nginx/nginx.conf @@ -0,0 +1,56 @@ +# Run nginx in foreground. +daemon off; + +# This is run inside Docker. +user root; + +# Pid storage location. +pid /var/run/nginx.pid; + +# Set number of worker processes. +worker_processes 1; + +# Enables the use of JIT for regular expressions to speed-up their processing. +pcre_jit on; + +# Write error log to Hass.io add-on log. +error_log /proc/1/fd/1 error; + +# Load allowed environment vars +env HASSIO_TOKEN; + +# Load dynamic modules. +include /etc/nginx/modules/*.conf; + +# Max num of simultaneous connections by a worker process. +events { + worker_connections 512; +} + +http { + include /etc/nginx/includes/mime.types; + + log_format hassio '[$time_local] $status ' + '$http_x_forwarded_for($remote_addr) ' + '$request ($http_user_agent)'; + + access_log /proc/1/fd/1 hassio; + client_max_body_size 4G; + default_type application/octet-stream; + gzip on; + keepalive_timeout 65; + sendfile on; + server_tokens off; + tcp_nodelay on; + tcp_nopush on; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + include /etc/nginx/includes/resolver.conf; + include /etc/nginx/includes/upstream.conf; + + include /etc/nginx/servers/*.conf; +} diff --git a/calibre/rootfs/etc/nginx/servers/ingress.conf b/calibre/rootfs/etc/nginx/servers/ingress.conf new file mode 100644 index 000000000..736940492 --- /dev/null +++ b/calibre/rootfs/etc/nginx/servers/ingress.conf @@ -0,0 +1,18 @@ +server { + listen %%interface%%:%%port%% default_server; + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + client_max_body_size 0; + server_name webtop.*; + + location / { + add_header Access-Control-Allow-Origin *; + proxy_pass http://127.0.0.1:8080; + proxy_buffering off; + proxy_read_timeout 30; + proxy_set_header Connection "Upgrade"; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Host $host; + } +} + diff --git a/calibre/rootfs/etc/services.d/nginx/finish b/calibre/rootfs/etc/services.d/nginx/finish new file mode 100644 index 000000000..444240135 --- /dev/null +++ b/calibre/rootfs/etc/services.d/nginx/finish @@ -0,0 +1,8 @@ +#!/usr/bin/execlineb -S0 +# ============================================================================== +# Take down the S6 supervision tree when Nginx fails +# ============================================================================== +if { s6-test ${1} -ne 0 } +if { s6-test ${1} -ne 256 } + +s6-svscanctl -t /var/run/s6/services diff --git a/calibre/rootfs/etc/services.d/nginx/run b/calibre/rootfs/etc/services.d/nginx/run new file mode 100644 index 000000000..07447d8b8 --- /dev/null +++ b/calibre/rootfs/etc/services.d/nginx/run @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== + +# Wait for transmission to become available +bashio::net.wait_for 8080 localhost 900 + +bashio::log.info "Starting NGinx..." + +exec nginx diff --git a/calibre/updater.json b/calibre/updater.json new file mode 100644 index 000000000..1fedcfb36 --- /dev/null +++ b/calibre/updater.json @@ -0,0 +1,8 @@ +{ + "last_update": "27-04-2022", + "repository": "alexbelgium/hassio-addons", + "slug": "calibre", + "source": "github", + "upstream_repo": "linuxserver/docker-calibre", + "upstream_version": "1.29.1" +} \ No newline at end of file