Skip to content

Commit d6d6f06

Browse files
committed
Release 2.7.1
# What's Changed - **New** Uses semantic versioning - **New** Added installation script and documentation for hotio containers - **Fixes** TheCaptain989/radarr-striptracks#73 - Light editing of README - Added GHCR pull counts - Updated Docker image labeling
1 parent c52b87f commit d6d6f06

File tree

9 files changed

+271
-9
lines changed

9 files changed

+271
-9
lines changed
15.6 KB
Loading

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
.gitignore
44
.github
55
.gitattributes
6+
.vscode
67
.assets
8+
hotio
79
READMETEMPLATE.md
810
README.md
911
SECURITY.md

.github/workflows/BuildImage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT
2323
echo "MULTI_ARCH=${{ env.MULTI_ARCH }}" >> $GITHUB_OUTPUT
2424
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
25-
MOD_VERSION=${GITHUB_SHA:0:7}
25+
MOD_VERSION="2.7.1"
2626
echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_OUTPUT
2727
outputs:
2828
GITHUB_REPO: ${{ steps.outputs.outputs.GITHUB_REPO }}

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
## Buildstage ##
44
FROM ghcr.io/linuxserver/baseimage-alpine:3.20 as buildstage
5-
65
ARG MOD_VERSION
76

87
# copy local files
@@ -17,11 +16,14 @@ RUN \
1716

1817
## Single layer deployed image ##
1918
FROM scratch
19+
ARG MOD_VERSION
2020

21-
LABEL org.opencontainers.image.source=https://github.com/TheCaptain989/radarr-striptracks
21+
LABEL org.opencontainers.image.title=radarr-striptracks
2222
LABEL org.opencontainers.image.description="A Docker Mod to Radarr/Sonarr to automatically strip out unwanted audio and subtitle streams"
23-
LABEL org.opencontainers.image.licenses=GPL-3.0-only
23+
LABEL org.opencontainers.image.version="${MOD_VERSION}"
24+
LABEL org.opencontainers.image.source="https://github.com/TheCaptain989/radarr-striptracks"
2425
LABEL org.opencontainers.image.authors="TheCaptain989 <thecaptain989@protonmail.com>"
26+
LABEL org.opencontainers.image.licenses=GPL-3.0-only
2527

2628
# Add files from buildstage
2729
COPY --from=buildstage /root-layer/ /

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# About
22
A [Docker Mod](https://github.com/linuxserver/docker-mods) for the LinuxServer.io Radarr/Sonarr v3 or higher Docker containers that adds a script to automatically strip out unwanted audio and subtitle tracks, keeping only the desired languages.
33

4-
**Beginning with version 2.0 of this mod, it only supports v3 or later of Radarr/Sonarr. For legacy Radarr/Sonarr v2 please use mod release 1.3 or earlier**
4+
**NEW!** There is a now an installer for **hotio** containers! See the [HOTIO.md](./hotio/HOTIO.md) file for more details.
55

66
**This unified script works in both Radarr and Sonarr. Use this mod in either container!**
77
>**NOTE:** This mod supports Linux OSes only.
8-
8+
<!-- markdownlint-disable -->
99
Production Container info: ![Docker Image Size](https://img.shields.io/docker/image-size/linuxserver/mods/radarr-striptracks "Container Size")
1010
[![linuxserver/docker-mods/mods/radarr-striptracks](https://img.shields.io/badge/dynamic/json?logo=github&url=https%3A%2F%2Fraw.githubusercontent.com%2Fthecaptain989%2Fghcr-pulls%2Fmaster%2Findex.json&query=%24%5B%3F(%40.owner%3D%3D%22linuxserver%22%20%26%26%20%40.repo%3D%3D%22docker-mods%22%20%26%26%20%40.image%3D%3D%22mods%22%20%26%26%20%40.tag%3D%3D%22radarr-striptracks%22)%5D.pulls&label=ghcr%20pulls&color=1572A4)](https://github.com/linuxserver/docker-mods/pkgs/container/mods)
1111
Development Container info:
1212
![Docker Image Size](https://img.shields.io/docker/image-size/thecaptain989/radarr-striptracks "Container Size")
1313
![Docker Pulls](https://img.shields.io/docker/pulls/thecaptain989/radarr-striptracks?logo=docker "Container Pulls")
1414
[![GitHub Super-Linter](https://github.com/TheCaptain989/radarr-striptracks/actions/workflows/linter.yml/badge.svg)](https://github.com/TheCaptain989/radarr-striptracks/actions/workflows/linter.yml "Linter Job")
15+
<!-- markdownlint-restore -->
1516

1617
# Installation
1718
1. Pull your selected container ([linuxserver/radarr](https://hub.docker.com/r/linuxserver/radarr "LinuxServer.io's Radarr container") or [linuxserver/sonarr](https://hub.docker.com/r/linuxserver/sonarr "LinuxServer.io's Sonarr container")) from GitHub Container Registry or Docker Hub:
@@ -337,5 +338,8 @@ This would not be possible without the following:
337338
The AWK script parsing mkvmerge output is adapted from Endoro's post on [VideoHelp](https://forum.videohelp.com/threads/343271-BULK-remove-non-English-tracks-from-MKV-container#post2292889).
338339
Icons made by [Freepik](https://www.freepik.com) from [Flaticon](https://www.flaticon.com/)
339340

341+
## Legacy Change Notes
342+
Beginning with version 2.0 of this mod, it only supports v3 or later of Radarr/Sonarr. For legacy Radarr/Sonarr v2 please use mod release 1.3 or earlier.
343+
340344
[warning]: .assets/warning.png "Warning"
341345
[danger]: .assets/danger.png "Danger"

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Only the latest major and minor version are supported.
66

77
| Version | Supported |
88
| ------- | ------------------ |
9-
| 2.6.x | :heavy_check_mark: |
10-
| < 2.6 | :x: |
9+
| 2.7.x | :heavy_check_mark: |
10+
| < 2.7 | :x: |
1111

1212
## Reporting a Vulnerability
1313

hotio/99-striptracks.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/command/with-contenv bash
2+
# shellcheck shell=bash
3+
4+
# Custom script to install Striptracks Mod meant for Radarr or Sonarr Docker containers
5+
# WARNING: Minimal error handling!
6+
7+
# Pre-set LSIO Docker Mod variables
8+
DOCKER_MODS=linuxserver/mods:radarr-striptracks
9+
#DOCKER_MODS_DEBUG=true
10+
export DOCKER_MODS
11+
export DOCKER_MODS_DEBUG
12+
[ "$DOCKER_MODS_DEBUG" = "true" ] && echo "[mod-install] DOCKER_MODS: $DOCKER_MODS" && echo "[mod-install] DOCKER_MODS_DEBUG: $DOCKER_MODS_DEBUG"
13+
echo "[mod-install] installing $DOCKER_MODS mod"
14+
15+
# Steal the current docker-mods version from the source
16+
MODS_VERSION=$(curl -s --fail-with-body "https://raw.githubusercontent.com/linuxserver/docker-baseimage-alpine/master/Dockerfile" | sed -nr 's/^ARG MODS_VERSION="?([^"]+)"?/\1/p')
17+
[ "$DOCKER_MODS_DEBUG" = "true" ] && echo "[mod-install] MODS_VERSION: $MODS_VERSION"
18+
19+
# Download and execute the main docker-mods script to install the mod
20+
# Very well thought out code, this. Why reinvent?
21+
curl -s --fail-with-body -o /docker-mods "https://raw.githubusercontent.com/linuxserver/docker-mods/mod-scripts/docker-mods.${MODS_VERSION}"
22+
ret=$?
23+
[ $ret -ne 0 ] && echo "[mod-install] unable to download docker-mods: Exit code: $ret. Exiting." && exit 1
24+
25+
chmod +x /docker-mods
26+
27+
. /docker-mods
28+
[ $ret -ne 0 ] && echo "[mod-install] docker-mods installation error: $ret. Exiting." && exit 1
29+
30+
# Get script version from installed mod
31+
VERSION=$(sed -nr 's/^export striptracks_ver="?([^"]+)"?/\1/p' /usr/local/bin/striptracks.sh)
32+
[ "$DOCKER_MODS_DEBUG" = "true" ] && echo "[mod-install] striptracks.sh version: $VERSION"
33+
34+
# Remaining setup that is normally done with s6-overlay init scripts, but that rely on a lot of Docker Mods dependencies
35+
cat <<EOF
36+
----------------
37+
>>> Striptracks Mod by TheCaptain989 <<<
38+
Repos:
39+
Dev/test: https://github.com/TheCaptain989/radarr-striptracks
40+
Prod: https://github.com/linuxserver/docker-mods/tree/radarr-striptracks
41+
42+
Version: ${VERSION}
43+
----------------
44+
EOF
45+
46+
# Determine if setup is needed
47+
if [ ! -f /usr/bin/mkvmerge ]; then
48+
echo "[mod-install] Running first time setup."
49+
50+
if [ -f /usr/bin/apt ]; then
51+
# Ubuntu
52+
echo "[mod-install] Installing MKVToolNix using apt-get"
53+
apt-get update && \
54+
apt-get -y install mkvtoolnix && \
55+
rm -rf /var/lib/apt/lists/*
56+
elif [ -f /sbin/apk ]; then
57+
# Alpine
58+
echo "[mod-install] Installing MKVToolNix using apk"
59+
apk upgrade --no-cache && \
60+
apk add --no-cache mkvtoolnix && \
61+
rm -rf /var/lib/apt/lists/*
62+
else
63+
# Unknown
64+
echo "[mod-install] Unknown package manager. Attempting to install MKVToolNix using apt-get"
65+
apt-get update && \
66+
apt-get -y install mkvtoolnix && \
67+
rm -rf /var/lib/apt/lists/*
68+
fi
69+
fi
70+
71+
# Check ownership and attributes on each script file
72+
[ -z "$PUID" ] && owner_user="root" || owner_user="$PUID"
73+
[ -z "$PGID" ] && owner_group="root" || owner_group="$PGID"
74+
for file in /usr/local/bin/striptracks*.sh
75+
do
76+
# Change ownership
77+
if [ "$(stat -c '%G' "$file")" != "$owner_group" ]; then
78+
echo "[mod-install] Changing ownership on $file script to $owner_user:$owner_group."
79+
chown "$owner_user":"$owner_group" "$file"
80+
fi
81+
82+
# Make executable
83+
if [ ! -x "$file" ]; then
84+
echo "[mod-install] Making $file script executable."
85+
chmod +x "$file"
86+
fi
87+
done

hotio/HOTIO.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# About
2+
This mod can now be used with [hotio](https://hotio.dev/) containers by using the method described in the hotio [FAQ](https://hotio.dev/faq/#:~:text=I%20would%20like%20to%20execute%20my%20own%20scripts%20on%20startup%2C%20how%20would%20I%20do%20this%3F) to install it.
3+
(This method relies on s6-overlay v2 behavior still working, though v3 is the current version.)
4+
5+
>This is a quick and dirty script with minimal testing or error checking. Note that it only runs *inside* the hotio container.
6+
7+
# Installation
8+
1. Download the **[99-striptracks.sh](./99-striptracks.sh)** install script and save it somewhere that can be mounted by your container.
9+
10+
*Example location:* `/volume1/docker/99-striptracks.sh`
11+
12+
*Example curl line to download the installation script:*
13+
14+
```shell
15+
curl -s https://raw.githubusercontent.com/TheCaptain989/radarr-striptracks/master/hotio/99-striptracks.sh >/volume1/docker/99-striptracks.sh
16+
```
17+
18+
2. Make it executable:
19+
20+
```shell
21+
chmod +x /volume1/docker/99-striptracks.sh
22+
```
23+
24+
3. Pull your selected container ([hotio/radarr](https://github.com/orgs/hotio/packages/container/package/radarr "hotio's Radarr container") or [hotio/sonarr](https://github.com/orgs/hotio/packages/container/package/sonarr "hotio.io's Sonarr container")) from GitHub Container Registry or Docker Hub:
25+
`docker pull ghcr.io/hotio/radarr:latest` OR
26+
`docker pull ghcr.io/hotio/sonarr:latest`
27+
28+
4. Configure the Docker container with all the port, volume, and environment settings from the *original container documentation* here:
29+
**[hotio/radarr](https://hotio.dev/containers/radarr/ "Radarr Docker container")**
30+
**[hotio/sonarr](https://hotio.dev/containers/sonarr/ "Sonarr Docker container")**
31+
32+
>**Note:** Notice that no environment variables are used in this setup. That is a specific feature of LSIO containers and is not applicable to hotio containers.
33+
34+
1. Add the **99-striptracks.sh** file path as a mount point in your `compose.yml` file or `docker run` command.
35+
>**Note:** The `/etc/cont-init.d/99-striptracks` path below is important; don't change it!
36+
37+
*Example Docker Compose YAML Configuration*
38+
39+
```yaml
40+
services:
41+
sonarr:
42+
container_name: sonarr
43+
image: ghcr.io/hotio/sonarr
44+
ports:
45+
- "8989:8989"
46+
environment:
47+
- PUID=1000
48+
- PGID=1000
49+
- UMASK=002
50+
- TZ=Etc/UTC
51+
volumes:
52+
- /<host_folder_config>:/config
53+
- /<host_folder_data>:/data
54+
- /volume1/docker/99-striptracks.sh:/etc/cont-init.d/99-striptracks
55+
```
56+
57+
*Example Docker Run Command*
58+
59+
```shell
60+
docker run --rm \
61+
--name sonarr \
62+
-p 8989:8989 \
63+
-e PUID=1000 \
64+
-e PGID=1000 \
65+
-e UMASK=002 \
66+
-e TZ="Etc/UTC" \
67+
-v /<host_folder_config>:/config \
68+
-v /<host_folder_data>:/data \
69+
-v /volume1/docker/99-striptracks.sh:/etc/cont-init.d/99-striptracks \
70+
ghcr.io/hotio/sonarr
71+
```
72+
73+
*Example Synology Configuration*
74+
![striptracks hotio](../.assets/hotio-striptracks-synology.png "Synology container settings")
75+
76+
>**Note:** Please be sure that your mount points for `/config` and `/data` above do not overlap with the newly added mount point!
77+
78+
2. Start the container.
79+
80+
5. After the container has fully started, continue with Installation step 3 in the previous [README](../README.md#installation).
81+
82+
## Requirements
83+
You must have the **bash** shell available in your host path. You *might* attempt editing the [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) in the 99-striptracks.sh script to get around this, but that is beyond the scope of this document.
84+
85+
## Known Problems
86+
On at least *some* Synology hosts that use the ash shell, this script will cause the container to abort and not start. If this happens, ***check your container logs*** for hints as to what may be wrong.

root/usr/local/bin/striptracks.sh

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,63 @@ function check_compat {
809809
[ $striptracks_debug -ge 1 ] && echo "Debug|Feature $1 is $([ $striptracks_return -eq 1 ] && echo "not ")compatible with ${striptracks_type^} v${striptracks_arr_version}." | log
810810
return $striptracks_return
811811
}
812+
# Get media management configuration
813+
function get_media_config {
814+
local url="$striptracks_api_url/config/mediamanagement"
815+
[ $striptracks_debug -ge 1 ] && echo "Debug|Getting ${striptracks_type^} configuration. Calling ${striptracks_type^} API using GET and URL '$url'" | log
816+
unset striptracks_result
817+
striptracks_result=$(curl -s --fail-with-body -H "X-Api-Key: $striptracks_apikey" \
818+
-H "Content-Type: application/json" \
819+
-H "Accept: application/json" \
820+
--get "$url")
821+
local striptracks_curlret=$?; [ $striptracks_curlret -ne 0 ] && {
822+
local striptracks_message=$(echo -e "[$striptracks_curlret] curl error when calling: \"$url\"\nWeb server returned: $(echo $striptracks_result | jq -jcrM .message?)" | awk '{print "Error|"$0}')
823+
echo "$striptracks_message" | log
824+
echo "$striptracks_message" >&2
825+
}
826+
[ $striptracks_debug -ge 2 ] && echo "API returned: $striptracks_result" | awk '{print "Debug|"$0}' | log
827+
if [ "$(echo $striptracks_result | jq -crM '.id?')" != "null" ] && [ "$(echo $striptracks_result | jq -crM '.id?')" != "" ]; then
828+
local striptracks_return=0
829+
else
830+
local striptracks_return=1
831+
fi
832+
return $striptracks_return
833+
}
834+
# Update file metadata in Radarr/Sonarr
835+
function set_video_info {
836+
local url="$striptracks_api_url/$striptracks_video_api/$striptracks_video_id"
837+
local data="$(echo $striptracks_videoinfo | jq -crM .monitored='true')"
838+
local i=0
839+
for ((i=1; i <= 5; i++)); do
840+
[ $striptracks_debug -ge 1 ] && echo "Debug|Updating monitored to 'true'. Calling ${striptracks_type^} API using PUT and URL '$url' with data $data" | log
841+
unset striptracks_result
842+
striptracks_result=$(curl -s --fail-with-body -H "X-Api-Key: $striptracks_apikey" \
843+
-H "Content-Type: application/json" \
844+
-H "Accept: application/json" \
845+
-d "$data" \
846+
-X PUT "$url")
847+
local striptracks_curlret=$?; [ $striptracks_curlret -ne 0 ] && {
848+
local striptracks_message=$(echo -e "[$striptracks_curlret] curl error when calling: \"$url\" with data $data\nWeb server returned: $(echo $striptracks_result | jq -jcrM .message?)" | awk '{print "Error|"$0}')
849+
echo "$striptracks_message" | log
850+
echo "$striptracks_message" >&2
851+
}
852+
[ $striptracks_debug -ge 2 ] && echo "Debug|API returned ${#striptracks_result} bytes." | log
853+
[ $striptracks_debug -ge 3 ] && echo "API returned: $striptracks_result" | awk '{print "Debug|"$0}' | log
854+
# Exit loop if database is not locked, else wait 1 minute
855+
if [[ ! "$(echo $striptracks_result | jq -jcrM .message?)" =~ database\ is\ locked ]]; then
856+
break
857+
else
858+
echo "Warn|Database is locked; system is likely overloaded. Sleeping 1 minute." | log
859+
sleep 60
860+
fi
861+
done
862+
if [ $striptracks_curlret -eq 0 -a "${#striptracks_result}" != 0 ]; then
863+
local striptracks_return=0
864+
else
865+
local striptracks_return=1
866+
fi
867+
return $striptracks_return
868+
}
812869
# Exit program
813870
function end_script {
814871
# Cool bash feature
@@ -1140,6 +1197,20 @@ elif [ -n "$striptracks_api_url" ]; then
11401197
echo "$striptracks_message" >&2
11411198
striptracks_exitstatus=17
11421199
fi
1200+
# Check if Radarr/Sonarr are configured to unmonitor deleted videos
1201+
get_media_config
1202+
striptracks_return=$?; [ $striptracks_return -ne 0 ] && {
1203+
# No '.id' in returned JSON
1204+
striptracks_message="Warn|The Media Management Config API returned no id."
1205+
echo "$striptracks_message" | log
1206+
echo "$striptracks_message" >&2
1207+
striptracks_exitstatus=17
1208+
}
1209+
if [ "$(echo "$striptracks_result" | jq -crM ".autoUnmonitorPreviouslyDownloaded${striptracks_video_api^}s")" = "true" ]; then
1210+
striptracks_conf_unmonitor=1
1211+
striptracks_message="Warn|Will compensate for ${striptracks_type^} configuration to unmonitor deleted ${striptracks_video_api}s."
1212+
echo "$striptracks_message" | log
1213+
fi
11431214
else
11441215
# No URL means we can't call the API
11451216
striptracks_message="Warn|Unable to determine ${striptracks_type^} API URL."
@@ -1518,8 +1589,18 @@ elif [ -n "$striptracks_api_url" ]; then
15181589

15191590
# Get new video file id
15201591
if get_video_info; then
1521-
striptracks_videofile_id="$(echo $striptracks_result | jq -crM .${striptracks_json_quality_root}.id)"
1592+
striptracks_videoinfo="$striptracks_result"
1593+
striptracks_videofile_id="$(echo $striptracks_videoinfo | jq -crM .${striptracks_json_quality_root}.id)"
15221594
[ $striptracks_debug -ge 1 ] && echo "Debug|Using new video file id '$striptracks_videofile_id'" | log
1595+
1596+
# Check if video is unmonitored after the delete/import
1597+
if [ $striptracks_conf_unmonitor -eq 1 -a "$(echo "$striptracks_videoinfo" | jq -crM ".monitored")" = "false" ]; then
1598+
striptracks_message="Warn|'$striptracks_title' is unmonitored after deleting the original video. Compensating for ${striptracks_type^} configuration."
1599+
echo "$striptracks_message" | log
1600+
# Set video to monitored again
1601+
set_video_info
1602+
fi
1603+
15231604
# Get new video file info
15241605
if get_videofile_info; then
15251606
striptracks_videofile_info="$striptracks_result"

0 commit comments

Comments
 (0)