Flash Update Script (AMD64 only) interactive version

Hi there, here is a script I put together to install/update adobes Flash on Q4OS but it can be used for Debian (and derivatives) too.

#!/bin/bash

##### Clear the screen when the script starts
clear

##### reset variables when script starts/restarts
required=""
num_required=0

##### Simple yes/no menu to confirm you want to run the script
read -n1 -p "This script will install Adobe Flash, Continue? [y[Y],n[N]]" runme
case $runme in
y|Y) echo ""
echo ""
echo "Running the script..."
echo ""
;;
n|N) echo ""
echo ""
echo "Ok, I will exit now."
echo "Please run the script again if you change your mind."
echo ""
exit 0
;;
*) echo ""
echo ""
echo "Err... Hmmm... yes or no too difficult for you?"
echo ""
exit 1
;;
esac

##### This script pulls in the x86_64 version of Flash Player so we must check machine architecture
arch=`lscpu | grep Architecture | awk '{print $2}'`
if [ "$arch" != "x86_64" ]; then
echo ""
echo "Sorry, this script is only designed to run on an x86_64 system"
echo ""
exit 2
else
echo "x86_64 cpu detected, continue..."
fi

##### These packages are required to run the script so we must check they
##### are installed and offer to install anything that is missing
declare -a req=("libnghttp2-14" "libcurl3" "lynx" "ghostscript")
for i in "${req[@]}"
do
package=`apt-cache policy "$i" | grep Installed | awk '{print $2}'`
if [ "$package" == "(none)" ]; then
required+="$i "
fi
done
num_required=$(echo $required | wc -w)
if [ $num_required != 0 ]; then
echo "There are $num_required uninstalled package(s) that are required,"
echo ""
echo "$required"
echo ""
read -n1 -p "Do you want me to install them for you? [y[Y],n[N]]" inst
case $inst in
y|Y) echo ""
echo ""
echo "This script will restart after installation."
echo ""
sleep 2
sudo apt -y install $required
exec "$(basename $0)"
;;
n|N) echo ""
echo ""
echo "Ok, this script cannot run without the required software."
echo "Please run the script again if you change your mind."
echo ""
exit 3
;;
*) echo ""
echo ""
echo "Err... Hmmm... yes or no too difficult for you?"
echo ""
exit 4
;;
esac
fi

##### This is the location of the Shared Object file, it can be changed if you know where you need it to be.
flash_file="/usr/lib/mozilla/plugins/libflashplayer.so"

##### If flash file exists we check the version number
if [ -e $flash_file ]; then
instver=$(strings "$flash_file" | grep "LNX" | awk '{print $2}')
instver=${instver//,/.}
fi

##### We get the latest version from the Adobe website
newver=`lynx -dump https://get.adobe.com/flashplayer/about/ | grep "Linux" | awk '{print $5}'`

##### We check the version numbers and install new version if required.
if [[ "$instver" == "$newver" ]]; then
echo ""
echo "Flash is the latest version"
echo ""
exit 0
elif [[ "$instver" == "" ]]; then
echo "Flash is not installed, need to install now..."
elif [[ "$instver" < "$newver" ]]; then
echo "Instver needs updating, updating now..."
else
echo ""
echo "Sorry I cannot determine versions correctly"
echo ""
exit 5
fi

##### Change to /tmp as working directory
cd /tmp

##### Download archive file from Adobe
echo "Downloading tar file from adobe website..."
wget https://fpdownload.adobe.com/get/flashplayer/pdc/$newver/flash_player_npapi_linux.x86_64.tar.gz

##### Short delay to ensure file is written correctly
sleep 2

##### Check we have the downloaded file
if [ -e /tmp/flash_player_npapi_linux.x86_64.tar.gz ]; then
echo "Flash file downloaded..."
else
echo ""
echo "ERROR: file not downloaded!"
echo ""
exit 6
fi

##### Extract the shared object file (it's all we need from the archive)
echo "Unpacking tar file..."
tar -zxvf /tmp/flash_player_npapi_linux.x86_64.tar.gz libflashplayer.so

##### Check file extracted correctly
if [ -e /tmp/libflashplayer.so ]; then
echo "Shared object extracted..."
else
echo ""
echo "ERROR: File not extracted!"
echo ""
exit 7
fi

##### Move the shared object file to it's correct location
echo "Moving shared object file..."
sudo mv libflashplayer.so "$flash_file"
if [ -e "$flash_file" ]; then
echo "File moved..."
else
echo ""
echo "ERROR: File not moved!"
echo ""
exit 8
fi

##### Remove the archive even though it is not strictly needed as /tmp gets cleaned at reboot
echo "Cleaning up..."
if [ -e "flash_player_npapi_linux.x86_64.tar.gz" ]; then
rm flash_player_npapi_linux.x86_64.tar.gz
fi

##### Confirm to user everything completed successfully and offer Adobes test page link
echo ""
echo "I have finished installing Flash,"
echo "to check please visit"
echo "https://helpx.adobe.com/flash-player.html"
echo ""

I have added comments to explain what everything is doing but if you want/need any further explanation please let me know in my forum and I will try to better explain and maybe update the comments to make it easier for others