default_version="15.1v3"

echo "Please enter version number (default ${default_version}):"
read version

if [ -z "$version" ]; then
  version=${default_version}
fi
vnum="${version%%v*}"
# echo "Version num:${vnum}"

read -p "Make sure the installer is located at '~/Downloads/Nuke${version}-linux-x86_64.run'. Press Enter to continue, or n to cancel..." answer

case $answer in
[Nn]*)
  echo "Installation cancelled"
  exit 0
  ;;
*)
  echo "Running installer..."
  ;;
esac

echo "Creating dirs..."
sudo mkdir /usr/bin/Nuke/
sudo cp nuke.png /usr/bin/Nuke/nuke.png

echo "Installing libraries..."
cd ~/Downloads/
sudo yum install mesa-libGLU.x86_64 -y
sudo dnf install libxcrypt-compat -y

echo "Moving application..."
sudo ./Nuke${version}-linux-x86_64.run --accept-foundry-eula
sudo mv ./Nuke${version} /usr/bin/Nuke/

echo "Creating Application shortcut..."
sudo mkdir -p ~/.local/share/applications/
sudo chmod -R 777 ~/.local/share/applications/
cd ~/.local/share/applications/
echo "#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=Nuke ${vnum}
Exec=/usr/bin/Nuke/Nuke${version}/Nuke${vnum} --indie
Icon=/usr/bin/Nuke/nuke.png" >nuke${version}.desktop
