#!/usr/bin/with-contenv bash

cat <<EOF
----------------
>>> Flac2MP3 Mod by TheCaptain989 <<<
Repos:
  Dev/test: https://github.com/TheCaptain989/lidarr-flac2mp3
  Prod: https://github.com/linuxserver/docker-mods/tree/lidarr-flac2mp3

Version: {{VERSION}}
----------------
EOF

# Determine if setup is needed
if [ ! -f /usr/bin/ffmpeg ]; then
  echo "**** Adding ffmpeg to package install list ****"
  echo "ffmpeg" >> /mod-repo-packages-to-install.list
else
  echo "**** flac2mp3 deps already installed, skipping ****"
fi

# Check ownership and attributes on each script file
for file in /usr/local/bin/flac2mp3*.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
