#!/usr/bin/with-contenv bash

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 "**** Adding striptracks deps to package install list ****"
  echo "mkvtoolnix" >> /mod-repo-packages-to-install.list
else
  echo "**** striptracks deps already installed, skipping ****"
fi

# Check ownership and attributes on each script file
for file in /usr/local/bin/striptracks*.sh
do
  # Change ownership
  if [ $(stat -c '%G' $file) != "abc" ]; then
    echo "Changing ownership on $file script."
    lsiown abc:abc $file
  fi

  # Make executable
  if [ ! -x $file ]; then
    echo "Making $file script executable."
    chmod +x $file
  fi
done
