From 6ab7a6a106f3117fa700a0354fe594ee710781b5 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Fri, 17 Dec 2021 17:39:12 +0100 Subject: [PATCH 01/16] add support for up/down and pre/post scripts --- Dockerfile | 1 + rootfs/etc/services.d/openvpn/run | 1 + rootfs/etc/services.d/qbittorrent/run | 19 +++++++++++++++++++ rootfs/usr/sbin/tunnelDown.sh | 9 +++++++++ rootfs/usr/sbin/tunnelUp.sh | 9 +++++++++ 5 files changed, 39 insertions(+) create mode 100644 rootfs/usr/sbin/tunnelDown.sh create mode 100644 rootfs/usr/sbin/tunnelUp.sh diff --git a/Dockerfile b/Dockerfile index 42a6670..4f9aaa8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,7 @@ RUN addgroup -S openvpn \ && chmod +x /usr/sbin/healthcheck.sh ENV CONFIG_DIR=/config \ + SCRIPTS_DIR=/config/scripts \ QBT_SAVE_PATH=/downloads \ QBT_WEBUI_PORT=8080 \ TUN=/dev/net/tun \ diff --git a/rootfs/etc/services.d/openvpn/run b/rootfs/etc/services.d/openvpn/run index 4668437..72c1b8d 100644 --- a/rootfs/etc/services.d/openvpn/run +++ b/rootfs/etc/services.d/openvpn/run @@ -28,3 +28,4 @@ exec s6-setuidgid "$(id -u openvpn):$(id -g openvpn)" openvpn \ --dhcp-option DNS "${DNS}" \ --redirect-gateway def1 bypass-dhcp \ --route "${LAN_FIRST_IP}" "${LAN_MASK}" net_gateway + --script-security 2 --up-delay --up /usr/sbin/tunnelUp.sh --down /usr/sbin/tunnelDown.sh diff --git a/rootfs/etc/services.d/qbittorrent/run b/rootfs/etc/services.d/qbittorrent/run index 5ec7075..32e2cb6 100644 --- a/rootfs/etc/services.d/qbittorrent/run +++ b/rootfs/etc/services.d/qbittorrent/run @@ -30,5 +30,24 @@ else echo "INFO: no port updater for provider ${OPENVPN_PROVIDER}" fi + +if [[ -x ${SCRIPTS_DIR}/preQBittorrentStart.sh ]]; then + echo "Executing ${SCRIPTS_DIR}/preQBittorrentStart.sh" + ${SCRIPTS_DIR}/preQBittorrentStart.sh + echo "${SCRIPTS_DIR}/preQBittorrentStart.sh returned $?" +else + echo "${SCRIPTS_DIR}/preQBittorrentStart.sh does not exist." +fi + + umask "${UMASK_SET:-002}" exec s6-setuidgid "${PUID}:${PGID}" qbittorrent-nox + + +if [[ -x ${SCRIPTS_DIR}/postQBittorrentStart.sh ]]; then + echo "Executing ${SCRIPTS_DIR}/postQBittorrentStart.sh" + ${SCRIPTS_DIR}/postQBittorrentStart.sh + echo "${SCRIPTS_DIR}/postQBittorrentStart.sh returned $?" +else + echo "${SCRIPTS_DIR}/preQBittorrentStart.sh does not exist." +fi \ No newline at end of file diff --git a/rootfs/usr/sbin/tunnelDown.sh b/rootfs/usr/sbin/tunnelDown.sh new file mode 100644 index 0000000..eb90995 --- /dev/null +++ b/rootfs/usr/sbin/tunnelDown.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [[ -x /${SCRIPTS_DIR}tunnelDown.sh ]]; then + echo "Executing /${SCRIPTS_DIR}tunnelDown.sh" + /${SCRIPTS_DIR}tunnelDown.sh + echo "/${SCRIPTS_DIR}tunnelDown.sh returned $?" +else + echo "${SCRIPTS_DIR}/tunnelDown.sh does not exist." +fi \ No newline at end of file diff --git a/rootfs/usr/sbin/tunnelUp.sh b/rootfs/usr/sbin/tunnelUp.sh new file mode 100644 index 0000000..f7e7cb4 --- /dev/null +++ b/rootfs/usr/sbin/tunnelUp.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [[ -x /${SCRIPTS_DIR}tunnelUp.sh ]]; then + echo "Executing /${SCRIPTS_DIR}tunnelUp.sh" + /${SCRIPTS_DIR}tunnelUp.sh + echo "/${SCRIPTS_DIR}tunnelUp.sh returned $?" +else + echo "${SCRIPTS_DIR}/tunnelUp.sh does not exist." +fi \ No newline at end of file From 0dd3e0cb9e64c4d8fd7c73fde39f9c44e9bd55d4 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Fri, 17 Dec 2021 19:18:38 +0100 Subject: [PATCH 02/16] fix indentation --- rootfs/usr/sbin/tunnelDown.sh | 2 +- rootfs/usr/sbin/tunnelUp.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/usr/sbin/tunnelDown.sh b/rootfs/usr/sbin/tunnelDown.sh index eb90995..620f361 100644 --- a/rootfs/usr/sbin/tunnelDown.sh +++ b/rootfs/usr/sbin/tunnelDown.sh @@ -5,5 +5,5 @@ if [[ -x /${SCRIPTS_DIR}tunnelDown.sh ]]; then /${SCRIPTS_DIR}tunnelDown.sh echo "/${SCRIPTS_DIR}tunnelDown.sh returned $?" else - echo "${SCRIPTS_DIR}/tunnelDown.sh does not exist." + echo "${SCRIPTS_DIR}/tunnelDown.sh does not exist." fi \ No newline at end of file diff --git a/rootfs/usr/sbin/tunnelUp.sh b/rootfs/usr/sbin/tunnelUp.sh index f7e7cb4..d1699a8 100644 --- a/rootfs/usr/sbin/tunnelUp.sh +++ b/rootfs/usr/sbin/tunnelUp.sh @@ -5,5 +5,5 @@ if [[ -x /${SCRIPTS_DIR}tunnelUp.sh ]]; then /${SCRIPTS_DIR}tunnelUp.sh echo "/${SCRIPTS_DIR}tunnelUp.sh returned $?" else - echo "${SCRIPTS_DIR}/tunnelUp.sh does not exist." + echo "${SCRIPTS_DIR}/tunnelUp.sh does not exist." fi \ No newline at end of file From 96f802f4da44c7cf9d3b679adc85a4451d6bd4eb Mon Sep 17 00:00:00 2001 From: jaype87 Date: Fri, 17 Dec 2021 19:18:57 +0100 Subject: [PATCH 03/16] fix linebreak --- rootfs/etc/services.d/openvpn/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/etc/services.d/openvpn/run b/rootfs/etc/services.d/openvpn/run index 72c1b8d..a4b0122 100644 --- a/rootfs/etc/services.d/openvpn/run +++ b/rootfs/etc/services.d/openvpn/run @@ -27,5 +27,5 @@ exec s6-setuidgid "$(id -u openvpn):$(id -g openvpn)" openvpn \ --pull-filter ignore "dhcp-option DNS" \ --dhcp-option DNS "${DNS}" \ --redirect-gateway def1 bypass-dhcp \ - --route "${LAN_FIRST_IP}" "${LAN_MASK}" net_gateway - --script-security 2 --up-delay --up /usr/sbin/tunnelUp.sh --down /usr/sbin/tunnelDown.sh + --route "${LAN_FIRST_IP}" "${LAN_MASK}" net_gateway \ + --script-security 2 --up-delay --up /usr/sbin/tunnelUp.sh --route-pre-down /usr/sbin/tunnelDown.sh From 64f5011d0729056360b08f68588e6cb90f62de32 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Fri, 17 Dec 2021 20:18:09 +0100 Subject: [PATCH 04/16] fix usage of env variable --- rootfs/usr/sbin/tunnelDown.sh | 8 ++++---- rootfs/usr/sbin/tunnelUp.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rootfs/usr/sbin/tunnelDown.sh b/rootfs/usr/sbin/tunnelDown.sh index 620f361..d0874e7 100644 --- a/rootfs/usr/sbin/tunnelDown.sh +++ b/rootfs/usr/sbin/tunnelDown.sh @@ -1,9 +1,9 @@ #!/bin/bash -if [[ -x /${SCRIPTS_DIR}tunnelDown.sh ]]; then - echo "Executing /${SCRIPTS_DIR}tunnelDown.sh" - /${SCRIPTS_DIR}tunnelDown.sh - echo "/${SCRIPTS_DIR}tunnelDown.sh returned $?" +if [[ -x ${SCRIPTS_DIR}/tunnelDown.sh ]]; then + echo "Executing ${SCRIPTS_DIR}/tunnelDown.sh" + ${SCRIPTS_DIR}/tunnelDown.sh + echo "${SCRIPTS_DIR}/tunnelDown.sh returned $?" else echo "${SCRIPTS_DIR}/tunnelDown.sh does not exist." fi \ No newline at end of file diff --git a/rootfs/usr/sbin/tunnelUp.sh b/rootfs/usr/sbin/tunnelUp.sh index d1699a8..a840ae4 100644 --- a/rootfs/usr/sbin/tunnelUp.sh +++ b/rootfs/usr/sbin/tunnelUp.sh @@ -1,9 +1,9 @@ #!/bin/bash -if [[ -x /${SCRIPTS_DIR}tunnelUp.sh ]]; then - echo "Executing /${SCRIPTS_DIR}tunnelUp.sh" - /${SCRIPTS_DIR}tunnelUp.sh - echo "/${SCRIPTS_DIR}tunnelUp.sh returned $?" +if [[ -x ${SCRIPTS_DIR}/tunnelUp.sh ]]; then + echo "Executing ${SCRIPTS_DIR}/tunnelUp.sh" + ${SCRIPTS_DIR}/tunnelUp.sh + echo "${SCRIPTS_DIR}/tunnelUp.sh returned $?" else echo "${SCRIPTS_DIR}/tunnelUp.sh does not exist." fi \ No newline at end of file From e2c4c4937c00ca95913fd67230923e057de5e706 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Fri, 17 Dec 2021 20:36:05 +0100 Subject: [PATCH 05/16] hardcode scripts folder --- Dockerfile | 1 - rootfs/etc/services.d/qbittorrent/run | 20 ++++++++++---------- rootfs/usr/sbin/tunnelDown.sh | 10 +++++----- rootfs/usr/sbin/tunnelUp.sh | 10 +++++----- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f9aaa8..42a6670 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,6 @@ RUN addgroup -S openvpn \ && chmod +x /usr/sbin/healthcheck.sh ENV CONFIG_DIR=/config \ - SCRIPTS_DIR=/config/scripts \ QBT_SAVE_PATH=/downloads \ QBT_WEBUI_PORT=8080 \ TUN=/dev/net/tun \ diff --git a/rootfs/etc/services.d/qbittorrent/run b/rootfs/etc/services.d/qbittorrent/run index 32e2cb6..83f4afa 100644 --- a/rootfs/etc/services.d/qbittorrent/run +++ b/rootfs/etc/services.d/qbittorrent/run @@ -31,12 +31,12 @@ else fi -if [[ -x ${SCRIPTS_DIR}/preQBittorrentStart.sh ]]; then - echo "Executing ${SCRIPTS_DIR}/preQBittorrentStart.sh" - ${SCRIPTS_DIR}/preQBittorrentStart.sh - echo "${SCRIPTS_DIR}/preQBittorrentStart.sh returned $?" +if [[ -x /scripts/preQBittorrentStart.sh ]]; then + echo "Executing /scripts/preQBittorrentStart.sh" + /scripts/preQBittorrentStart.sh + echo "/scripts/preQBittorrentStart.sh returned $?" else - echo "${SCRIPTS_DIR}/preQBittorrentStart.sh does not exist." + echo "/scripts/preQBittorrentStart.sh does not exist." fi @@ -44,10 +44,10 @@ umask "${UMASK_SET:-002}" exec s6-setuidgid "${PUID}:${PGID}" qbittorrent-nox -if [[ -x ${SCRIPTS_DIR}/postQBittorrentStart.sh ]]; then - echo "Executing ${SCRIPTS_DIR}/postQBittorrentStart.sh" - ${SCRIPTS_DIR}/postQBittorrentStart.sh - echo "${SCRIPTS_DIR}/postQBittorrentStart.sh returned $?" +if [[ -x /scripts/postQBittorrentStart.sh ]]; then + echo "Executing /scripts/postQBittorrentStart.sh" + /scripts/postQBittorrentStart.sh + echo "/scripts/postQBittorrentStart.sh returned $?" else - echo "${SCRIPTS_DIR}/preQBittorrentStart.sh does not exist." + echo "/scripts/preQBittorrentStart.sh does not exist." fi \ No newline at end of file diff --git a/rootfs/usr/sbin/tunnelDown.sh b/rootfs/usr/sbin/tunnelDown.sh index d0874e7..45baede 100644 --- a/rootfs/usr/sbin/tunnelDown.sh +++ b/rootfs/usr/sbin/tunnelDown.sh @@ -1,9 +1,9 @@ #!/bin/bash -if [[ -x ${SCRIPTS_DIR}/tunnelDown.sh ]]; then - echo "Executing ${SCRIPTS_DIR}/tunnelDown.sh" - ${SCRIPTS_DIR}/tunnelDown.sh - echo "${SCRIPTS_DIR}/tunnelDown.sh returned $?" +if [[ -x /scripts/tunnelDown.sh ]]; then + echo "Executing /scripts/tunnelDown.sh" + /scripts/tunnelDown.sh + echo "/scripts/tunnelDown.sh returned $?" else - echo "${SCRIPTS_DIR}/tunnelDown.sh does not exist." + echo "/scripts/tunnelDown.sh does not exist." fi \ No newline at end of file diff --git a/rootfs/usr/sbin/tunnelUp.sh b/rootfs/usr/sbin/tunnelUp.sh index a840ae4..4aee44e 100644 --- a/rootfs/usr/sbin/tunnelUp.sh +++ b/rootfs/usr/sbin/tunnelUp.sh @@ -1,9 +1,9 @@ #!/bin/bash -if [[ -x ${SCRIPTS_DIR}/tunnelUp.sh ]]; then - echo "Executing ${SCRIPTS_DIR}/tunnelUp.sh" - ${SCRIPTS_DIR}/tunnelUp.sh - echo "${SCRIPTS_DIR}/tunnelUp.sh returned $?" +if [[ -x /scripts/tunnelUp.sh ]]; then + echo "Executing scripts/tunnelUp.sh" + /scripts/tunnelUp.sh + echo "/scripts/tunnelUp.sh returned $?" else - echo "${SCRIPTS_DIR}/tunnelUp.sh does not exist." + echo "/scripts/tunnelUp.sh does not exist." fi \ No newline at end of file From 420fff39a5bb1f47022f45f57fa8cc8e019db811 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Fri, 17 Dec 2021 20:40:43 +0100 Subject: [PATCH 06/16] set permissions --- rootfs/etc/cont-init.d/01-setup-permissions | 1 + 1 file changed, 1 insertion(+) diff --git a/rootfs/etc/cont-init.d/01-setup-permissions b/rootfs/etc/cont-init.d/01-setup-permissions index e520529..bb21fc5 100644 --- a/rootfs/etc/cont-init.d/01-setup-permissions +++ b/rootfs/etc/cont-init.d/01-setup-permissions @@ -8,6 +8,7 @@ mkdir -p "${QBT_SAVE_PATH}" # set permissions on configuration directory echo "${CONFIG_DIR}/qBittorrent true ${PUID}:${PGID} 0600 0700" | fix-attrs echo "${CONFIG_DIR}/openvpn true openvpn:openvpn 0600 0700" | fix-attrs +echo "/scripts true openvpn:openvpn 0600 0700" | fix-attrs # set ownership on download directory chown -R "${PUID}:${PGID}" "${QBT_SAVE_PATH}" From 4c6e23b7f49cebe0ca9b8b454f83cec37585a9ac Mon Sep 17 00:00:00 2001 From: jaype87 Date: Fri, 17 Dec 2021 20:58:13 +0100 Subject: [PATCH 07/16] remove permission fix --- rootfs/etc/cont-init.d/01-setup-permissions | 1 - 1 file changed, 1 deletion(-) diff --git a/rootfs/etc/cont-init.d/01-setup-permissions b/rootfs/etc/cont-init.d/01-setup-permissions index bb21fc5..e520529 100644 --- a/rootfs/etc/cont-init.d/01-setup-permissions +++ b/rootfs/etc/cont-init.d/01-setup-permissions @@ -8,7 +8,6 @@ mkdir -p "${QBT_SAVE_PATH}" # set permissions on configuration directory echo "${CONFIG_DIR}/qBittorrent true ${PUID}:${PGID} 0600 0700" | fix-attrs echo "${CONFIG_DIR}/openvpn true openvpn:openvpn 0600 0700" | fix-attrs -echo "/scripts true openvpn:openvpn 0600 0700" | fix-attrs # set ownership on download directory chown -R "${PUID}:${PGID}" "${QBT_SAVE_PATH}" From 393e5fe08ece5eb162f0a26a9a6bec284cd856a9 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Mon, 10 Jan 2022 00:07:32 +0100 Subject: [PATCH 08/16] Update rootfs/usr/sbin/tunnelUp.sh Co-authored-by: guillaumedsde <30023543+guillaumedsde@users.noreply.github.com> --- rootfs/usr/sbin/tunnelUp.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rootfs/usr/sbin/tunnelUp.sh b/rootfs/usr/sbin/tunnelUp.sh index 4aee44e..dd87fe1 100644 --- a/rootfs/usr/sbin/tunnelUp.sh +++ b/rootfs/usr/sbin/tunnelUp.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "INFO: VPN connection is UP" + if [[ -x /scripts/tunnelUp.sh ]]; then echo "Executing scripts/tunnelUp.sh" /scripts/tunnelUp.sh From 1b81ebc605e6f751f9fe6cb709a3dc34ef6647d1 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Mon, 10 Jan 2022 00:07:41 +0100 Subject: [PATCH 09/16] Update rootfs/usr/sbin/tunnelUp.sh Co-authored-by: guillaumedsde <30023543+guillaumedsde@users.noreply.github.com> --- rootfs/usr/sbin/tunnelUp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/usr/sbin/tunnelUp.sh b/rootfs/usr/sbin/tunnelUp.sh index dd87fe1..4b3943f 100644 --- a/rootfs/usr/sbin/tunnelUp.sh +++ b/rootfs/usr/sbin/tunnelUp.sh @@ -8,4 +8,4 @@ if [[ -x /scripts/tunnelUp.sh ]]; then echo "/scripts/tunnelUp.sh returned $?" else echo "/scripts/tunnelUp.sh does not exist." -fi \ No newline at end of file +fi From 3db74089ada1774409ef23580418b76ac04f8a2a Mon Sep 17 00:00:00 2001 From: jaype87 Date: Mon, 10 Jan 2022 00:07:46 +0100 Subject: [PATCH 10/16] Update rootfs/usr/sbin/tunnelDown.sh Co-authored-by: guillaumedsde <30023543+guillaumedsde@users.noreply.github.com> --- rootfs/usr/sbin/tunnelDown.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rootfs/usr/sbin/tunnelDown.sh b/rootfs/usr/sbin/tunnelDown.sh index 45baede..14bfc55 100644 --- a/rootfs/usr/sbin/tunnelDown.sh +++ b/rootfs/usr/sbin/tunnelDown.sh @@ -1,9 +1,9 @@ #!/bin/bash if [[ -x /scripts/tunnelDown.sh ]]; then - echo "Executing /scripts/tunnelDown.sh" + echo "INFO: Executing /scripts/tunnelDown.sh" /scripts/tunnelDown.sh - echo "/scripts/tunnelDown.sh returned $?" + echo "INFO: /scripts/tunnelDown.sh returned $?" else - echo "/scripts/tunnelDown.sh does not exist." + echo "INFO: /scripts/tunnelDown.sh does not exist." fi \ No newline at end of file From 4ee3003038f3b2e0b834145b69bf80b2ca9791b2 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Mon, 10 Jan 2022 00:07:51 +0100 Subject: [PATCH 11/16] Update rootfs/usr/sbin/tunnelDown.sh Co-authored-by: guillaumedsde <30023543+guillaumedsde@users.noreply.github.com> --- rootfs/usr/sbin/tunnelDown.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/usr/sbin/tunnelDown.sh b/rootfs/usr/sbin/tunnelDown.sh index 14bfc55..621afbb 100644 --- a/rootfs/usr/sbin/tunnelDown.sh +++ b/rootfs/usr/sbin/tunnelDown.sh @@ -6,4 +6,4 @@ if [[ -x /scripts/tunnelDown.sh ]]; then echo "INFO: /scripts/tunnelDown.sh returned $?" else echo "INFO: /scripts/tunnelDown.sh does not exist." -fi \ No newline at end of file +fi From 44a883e73752165f56ae3ecec75cb193db66fffd Mon Sep 17 00:00:00 2001 From: jaype87 Date: Mon, 10 Jan 2022 00:07:57 +0100 Subject: [PATCH 12/16] Update rootfs/etc/services.d/qbittorrent/run Co-authored-by: guillaumedsde <30023543+guillaumedsde@users.noreply.github.com> --- rootfs/etc/services.d/qbittorrent/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/services.d/qbittorrent/run b/rootfs/etc/services.d/qbittorrent/run index 83f4afa..b577e82 100644 --- a/rootfs/etc/services.d/qbittorrent/run +++ b/rootfs/etc/services.d/qbittorrent/run @@ -50,4 +50,4 @@ if [[ -x /scripts/postQBittorrentStart.sh ]]; then echo "/scripts/postQBittorrentStart.sh returned $?" else echo "/scripts/preQBittorrentStart.sh does not exist." -fi \ No newline at end of file +fi From 60606d3a9da96c7e7e5bcada8dc0310eedae25f9 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Mon, 10 Jan 2022 00:08:03 +0100 Subject: [PATCH 13/16] Update rootfs/usr/sbin/tunnelUp.sh Co-authored-by: guillaumedsde <30023543+guillaumedsde@users.noreply.github.com> --- rootfs/usr/sbin/tunnelUp.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rootfs/usr/sbin/tunnelUp.sh b/rootfs/usr/sbin/tunnelUp.sh index 4b3943f..eb16206 100644 --- a/rootfs/usr/sbin/tunnelUp.sh +++ b/rootfs/usr/sbin/tunnelUp.sh @@ -3,9 +3,9 @@ echo "INFO: VPN connection is UP" if [[ -x /scripts/tunnelUp.sh ]]; then - echo "Executing scripts/tunnelUp.sh" + echo "INFO: Executing scripts/tunnelUp.sh" /scripts/tunnelUp.sh - echo "/scripts/tunnelUp.sh returned $?" + echo "INFO: /scripts/tunnelUp.sh returned $?" else - echo "/scripts/tunnelUp.sh does not exist." + echo "INFO: /scripts/tunnelUp.sh does not exist." fi From 121158af0010b3a89cfabc6d18622d29d88cf755 Mon Sep 17 00:00:00 2001 From: jaype87 Date: Mon, 10 Jan 2022 00:08:12 +0100 Subject: [PATCH 14/16] Update rootfs/etc/services.d/qbittorrent/run Co-authored-by: guillaumedsde <30023543+guillaumedsde@users.noreply.github.com> --- rootfs/etc/services.d/qbittorrent/run | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rootfs/etc/services.d/qbittorrent/run b/rootfs/etc/services.d/qbittorrent/run index b577e82..95d5249 100644 --- a/rootfs/etc/services.d/qbittorrent/run +++ b/rootfs/etc/services.d/qbittorrent/run @@ -32,11 +32,11 @@ fi if [[ -x /scripts/preQBittorrentStart.sh ]]; then - echo "Executing /scripts/preQBittorrentStart.sh" + echo "INFO: Executing /scripts/preQBittorrentStart.sh" /scripts/preQBittorrentStart.sh - echo "/scripts/preQBittorrentStart.sh returned $?" + echo "INFO: /scripts/preQBittorrentStart.sh returned $?" else - echo "/scripts/preQBittorrentStart.sh does not exist." + echo "INFO: /scripts/preQBittorrentStart.sh does not exist." fi From 418b2f026fa2cdd97866d322965b32cd83252e4a Mon Sep 17 00:00:00 2001 From: jaype87 Date: Mon, 10 Jan 2022 00:08:18 +0100 Subject: [PATCH 15/16] Update rootfs/etc/services.d/qbittorrent/run Co-authored-by: guillaumedsde <30023543+guillaumedsde@users.noreply.github.com> --- rootfs/etc/services.d/qbittorrent/run | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rootfs/etc/services.d/qbittorrent/run b/rootfs/etc/services.d/qbittorrent/run index 95d5249..a193889 100644 --- a/rootfs/etc/services.d/qbittorrent/run +++ b/rootfs/etc/services.d/qbittorrent/run @@ -45,9 +45,9 @@ exec s6-setuidgid "${PUID}:${PGID}" qbittorrent-nox if [[ -x /scripts/postQBittorrentStart.sh ]]; then - echo "Executing /scripts/postQBittorrentStart.sh" + echo "INFO: Executing /scripts/postQBittorrentStart.sh" /scripts/postQBittorrentStart.sh - echo "/scripts/postQBittorrentStart.sh returned $?" + echo "INFO: /scripts/postQBittorrentStart.sh returned $?" else - echo "/scripts/preQBittorrentStart.sh does not exist." + echo "INFO: /scripts/preQBittorrentStart.sh does not exist." fi From a24c72befffb148c8456f146e70627712337f5ec Mon Sep 17 00:00:00 2001 From: jaype87 Date: Tue, 11 Jan 2022 00:42:52 +0100 Subject: [PATCH 16/16] change scripts to use environment variables --- rootfs/etc/services.d/qbittorrent/run | 25 +++++++++---------------- rootfs/usr/sbin/tunnelDown.sh | 14 +++++++++----- rootfs/usr/sbin/tunnelUp.sh | 16 +++++++++------- 3 files changed, 27 insertions(+), 28 deletions(-) mode change 100644 => 100755 rootfs/usr/sbin/tunnelDown.sh mode change 100644 => 100755 rootfs/usr/sbin/tunnelUp.sh diff --git a/rootfs/etc/services.d/qbittorrent/run b/rootfs/etc/services.d/qbittorrent/run index a193889..aa156b0 100644 --- a/rootfs/etc/services.d/qbittorrent/run +++ b/rootfs/etc/services.d/qbittorrent/run @@ -30,24 +30,17 @@ else echo "INFO: no port updater for provider ${OPENVPN_PROVIDER}" fi - -if [[ -x /scripts/preQBittorrentStart.sh ]]; then - echo "INFO: Executing /scripts/preQBittorrentStart.sh" - /scripts/preQBittorrentStart.sh - echo "INFO: /scripts/preQBittorrentStart.sh returned $?" +if [[ -v PRESTART ]]; then + if [[ -x $PRESTART ]]; then + echo "INFO: Executing $PRESTART..." + $PRESTART + echo "INFO: $PRESTART returned $?" + else + echo "WARNING: Variable PRESTART defined, but no executable file found at $PRESTART..." + fi else - echo "INFO: /scripts/preQBittorrentStart.sh does not exist." + echo "INFO: PRESTART not defined." fi - umask "${UMASK_SET:-002}" exec s6-setuidgid "${PUID}:${PGID}" qbittorrent-nox - - -if [[ -x /scripts/postQBittorrentStart.sh ]]; then - echo "INFO: Executing /scripts/postQBittorrentStart.sh" - /scripts/postQBittorrentStart.sh - echo "INFO: /scripts/postQBittorrentStart.sh returned $?" -else - echo "INFO: /scripts/preQBittorrentStart.sh does not exist." -fi diff --git a/rootfs/usr/sbin/tunnelDown.sh b/rootfs/usr/sbin/tunnelDown.sh old mode 100644 new mode 100755 index 621afbb..04eec11 --- a/rootfs/usr/sbin/tunnelDown.sh +++ b/rootfs/usr/sbin/tunnelDown.sh @@ -1,9 +1,13 @@ #!/bin/bash -if [[ -x /scripts/tunnelDown.sh ]]; then - echo "INFO: Executing /scripts/tunnelDown.sh" - /scripts/tunnelDown.sh - echo "INFO: /scripts/tunnelDown.sh returned $?" +if [[ -v TUNNELDOWN ]]; then + if [[ -x $TUNNELDOWN ]]; then + echo "INFO: Executing $TUNNELDOWN..." + $TUNNELDOWN + echo "INFO: $TUNNELDOWN returned $?" + else + echo "WARNING: Variable TUNNELDOWN defined, but no executable file found at $TUNNELDOWN..." + fi else - echo "INFO: /scripts/tunnelDown.sh does not exist." + echo "INFO: TUNNELDOWN not defined." fi diff --git a/rootfs/usr/sbin/tunnelUp.sh b/rootfs/usr/sbin/tunnelUp.sh old mode 100644 new mode 100755 index eb16206..6c0aab4 --- a/rootfs/usr/sbin/tunnelUp.sh +++ b/rootfs/usr/sbin/tunnelUp.sh @@ -1,11 +1,13 @@ #!/bin/bash -echo "INFO: VPN connection is UP" - -if [[ -x /scripts/tunnelUp.sh ]]; then - echo "INFO: Executing scripts/tunnelUp.sh" - /scripts/tunnelUp.sh - echo "INFO: /scripts/tunnelUp.sh returned $?" +if [[ -v TUNNELUP ]]; then + if [[ -x $TUNNELUP ]]; then + echo "INFO: Executing $TUNNELUP..." + $TUNNELUP + echo "INFO: $TUNNELUP returned $?" + else + echo "WARNING: Variable TUNNELUP defined, but no executable file found at $TUNNELUP..." + fi else - echo "INFO: /scripts/tunnelUp.sh does not exist." + echo "INFO: TUNNELUP not defined." fi