diff --git a/transmission_openvpn/CHANGELOG.md b/transmission_openvpn/CHANGELOG.md new file mode 100644 index 000000000..68dde260e --- /dev/null +++ b/transmission_openvpn/CHANGELOG.md @@ -0,0 +1 @@ +- Initial build diff --git a/transmission_openvpn/Dockerfile b/transmission_openvpn/Dockerfile new file mode 100644 index 000000000..ef718bdb2 --- /dev/null +++ b/transmission_openvpn/Dockerfile @@ -0,0 +1,94 @@ +#============================# +# ALEXBELGIUM'S DOCKERFILE # +#============================# +# _.------. +# _.-` ('>.-`"""-. +# '.--'` _'` _ .--.) +# -' '-.-';` ` +# ' - _.' ``'--. +# '---` .-'""` +# /` +#=== Home Assistant Addon ===# + +################# +# 1 Build Image # +################# + +ARG BUILD_FROM +ARG BUILD_VERSION +ARG BUILD_UPSTREAM=4.0 +FROM ${BUILD_FROM} + +################## +# 2 Modify Image # +################## + +# MOFIFY DATA PATH +ENV TRANSMISSION_HOME="/addons_config/transmission" \ + CREATE_TUN_DEVICE=false + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Modules +ARG MODULES="00-banner.sh 90-dns_set.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 +CMD [ "/entrypoint.sh" ] +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 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/transmission_openvpn/README.md b/transmission_openvpn/README.md new file mode 100644 index 000000000..006071a31 --- /dev/null +++ b/transmission_openvpn/README.md @@ -0,0 +1,44 @@ +# Home assistant add-on: Transmission Openvpn + +[![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%2Ftransmission_openvpn%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%2Ftransmission_openvpn%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%2Ftransmission_openvpn%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 + +Transmission is a bittorrent client. +This addon is based on the [Haugene docker image](https://github.com/haugene/docker-transmission-openvpn). + +## Installation + +The installation of this add-on is pretty straightforward and not different in +comparison to installing any other Hass.io add-on. + +1. [Add my Hass.io add-ons repository][repository] to your Hass.io instance. +1. Install this add-on. +1. Click the `Save` button to store your configuration. +1. Start the add-on. +1. Check the logs of the add-on to see if everything went well. +1. Carefully configure the add-on to your preferences, see the official documentation for for that. + +## Configuration + +Options : see https://github.com/haugene/docker-transmission-openvpn for documentation + +Complete transmission options are in /config/addons_config/transmission (make sure addon is stopped before modifying it as Transmission writes its ongoing values when stopping and could erase your changes) + +Webui can be found at `:9091`. + +[repository]: https://github.com/alexbelgium/hassio-addons diff --git a/transmission_openvpn/apparmor.txt b/transmission_openvpn/apparmor.txt new file mode 100644 index 000000000..eed8d0d3e --- /dev/null +++ b/transmission_openvpn/apparmor.txt @@ -0,0 +1,57 @@ +#include + +profile db21ed7f_transmission_openvpn 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, + /dev/net/tun 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/transmission_openvpn/build.json b/transmission_openvpn/build.json new file mode 100644 index 000000000..381e7979d --- /dev/null +++ b/transmission_openvpn/build.json @@ -0,0 +1,10 @@ +{ + "build_from": { + "aarch64": "haugene/transmission-openvpn:latest", + "amd64": "haugene/transmission-openvpn:latest", + "armv7": "haugene/transmission-openvpn:latest" + }, + "codenotary": { + "signer": "alexandrep.github@gmail.com" + } +} diff --git a/transmission_openvpn/config.json b/transmission_openvpn/config.json new file mode 100644 index 000000000..609a6a127 --- /dev/null +++ b/transmission_openvpn/config.json @@ -0,0 +1,108 @@ +{ + "arch": [ + "aarch64", + "amd64", + "armv7" + ], + "codenotary": "alexandrep.github@gmail.com", + "description": "Bittorrent client based on linuxserver image", + "devices": [ + "/dev/net/tun", + "/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" + ], + "image": "ghcr.io/alexbelgium/transmission_openvpn-{arch}", + "map": [ + "config:rw", + "share:rw", + "media:rw", + "ssl" + ], + "name": "Transmission Openvpn", + "options": { + "PGID": "1000", + "PUID": "1000", + "DNS_server": "8.8.8.8,1.1.1.1", + "TRANSMISSION_WEB_UI": "transmission-web-control", + "TRANSMISSION_DOWNLOAD_DIR": "/share/downloads", + "TRANSMISSION_INCOMPLETE_DIR": "/share/incomplete", + "OPENVPN_PROVIDER": "PIA", + "OPENVPN_CONFIG": "france", + "OPENVPN_USERNAME": "user", + "OPENVPN_PASSWORD": "pass", + "LOCAL_NETWORK": "192.168.178.0/16", + "TRANSMISSION_DOWNLOAD_DIR": "/addons_config/transmission/downloads", + "TRANSMISSION_INCOMPLETE_DIR": "/addons_config/transmission/incomplete", + "TRANSMISSION_WATCH_DIR": "/addons_config/transmission/watch_dir", + "DEBUG": false + }, + "ports": { + "51413/tcp": 51413, + "51413/udp": 51413, + "9091/tcp": 9091 + }, + "ports_description": { + "51413/tcp": "Peer port (setup router port forwarding to this port)", + "51413/udp": "Peer port (setup router port forwarding to this port)", + "9091/tcp": "Web UI port (required)" + }, + "privileged": [ + "SYS_ADMIN", + "DAC_READ_SEARCH", + "NET_ADMIN" + ], + "schema": { + "PGID": "int", + "PUID": "int", + "DNS_server": "str?", + "cifspassword": "str?", + "cifsusername": "str?", + "TRANSMISSION_WEB_UI": "list(standard|combustion|kettu|transmission-web-control|flood-for-transmission|shift)", + "localdisks": "str?", + "networkdisks": "str?", + "pass": "str?", + "user": "str?", + "OPENVPN_PROVIDER": "str", + "OPENVPN_CONFIG": "str?", + "OPENVPN_USERNAME": "str", + "OPENVPN_PASSWORD": "str", + "LOCAL_NETWORK": "str", + "TRANSMISSION_DOWNLOAD_DIR": "str", + "TRANSMISSION_INCOMPLETE_DIR": "str", + "TRANSMISSION_WATCH_DIR": "str", + "DEBUG": "bool" + }, + "slug": "transmission_openvpn", + "startup": "services", + "url": "https://github.com/alexbelgium/hassio-addons", + "version": "4.0", + "webui": "http://[HOST]:[PORT:9091]" +} \ No newline at end of file diff --git a/transmission_openvpn/icon.png b/transmission_openvpn/icon.png new file mode 100644 index 000000000..678ef848b Binary files /dev/null and b/transmission_openvpn/icon.png differ diff --git a/transmission_openvpn/logo.png b/transmission_openvpn/logo.png new file mode 100644 index 000000000..678ef848b Binary files /dev/null and b/transmission_openvpn/logo.png differ diff --git a/transmission_openvpn/rootfs/entrypoint.sh b/transmission_openvpn/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/transmission_openvpn/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/transmission_openvpn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/transmission_openvpn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..bb8872f05 --- /dev/null +++ b/transmission_openvpn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,43 @@ +#!/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 + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi diff --git a/transmission_openvpn/rootfs/etc/cont-init.d/99-run.sh b/transmission_openvpn/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..c72a85f96 --- /dev/null +++ b/transmission_openvpn/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,15 @@ +#!/usr/bin/bashio + +#################### +# Export variables # +#################### + +echo "Exporting variables" +for k in $(bashio::jq "/data/options.json" 'keys | .[]'); do + bashio::log.blue $k=$(bashio::config $k) + export $k=$(bashio::config $k) +done + +echo "" +bashio::log.info "Starting app" +/./etc/openvpn/start.sh diff --git a/transmission_openvpn/updater.json b/transmission_openvpn/updater.json new file mode 100644 index 000000000..9d04451f0 --- /dev/null +++ b/transmission_openvpn/updater.json @@ -0,0 +1,9 @@ +{ + "github_fulltag": "true", + "last_update": "21-05-2022", + "repository": "alexbelgium/hassio-addons", + "slug": "transmission_openvpn", + "source": "github", + "upstream_repo": "haugene/docker-transmission-openvpn", + "upstream_version": "3.00-r5-ls125" +} \ No newline at end of file