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