From 9ae32ce53817ea6d91f754f862ce8fa11dc85fbf Mon Sep 17 00:00:00 2001 From: tb14 Date: Sat, 5 Nov 2022 12:56:45 -0500 Subject: [PATCH] Mint21 version check vara script --- AmRRON-Vara-setup.sh | 173 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 172 insertions(+), 1 deletion(-) diff --git a/AmRRON-Vara-setup.sh b/AmRRON-Vara-setup.sh index ae98471..793c75f 100755 --- a/AmRRON-Vara-setup.sh +++ b/AmRRON-Vara-setup.sh @@ -11,7 +11,177 @@ ### This script will perform basic setup for VARA. ### Tested on Mint 21 ### Using guidance and tools from TK-05, KM4ACK, ptitSeb, Box86, and KI7POL +#### Program setup functions +# Find out if we have yad and install if not +echo "Yad is used to create the interactive menus this program uses." +echo "If yad is not installed, we will attempt to install it now." +sleep 2 +if ! hash yad 2>/dev/null; then +sudo apt-get -y install yad || +{ echo "Yad install failed. Yad is required to run this installer. Please install yad and try again or check your internet connection."; exit 1; } +fi + +# Find the screen size. Will default to 800x480 if it can not be detected. +function set_screen_size() { +screen_size=$(xdpyinfo | grep dimensions | \ +sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/' | sed s/x/" "/ || echo 800 480) +width=$(echo $screen_size | awk '{print $1}') +height=$(echo $screen_size | awk '{print $2}') +#xdpyinfo | grep 'dimensions:' +# Divide by two so the dialogs take up half of the screen, which looks nice. +rows=$(( height / 2 )) +columns=$(( width / 2 )) +# Unless the screen is tiny +rows=$(( rows < 400 ? 400 : rows )) +columns=$(( columns < 700 ? 700 : columns )) +c="--width=${columns}" +r="--height=${rows}" +} + + + +# Determine location user is running script from. +SOURCE="${BASH_SOURCE[0]}" + # While $SOURCE is a symlink, resolve it + while [ -h "$SOURCE" ]; do + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$( readlink "$SOURCE" )" + # If $SOURCE was a relative symlink (so no "/" as prefix, need to + #resolve it relative to the symlink base directory + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" + done + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + #echo "$DIR" + +#Set image location + + +# Create a error function to make life easier later on +function errors() { +echo "${ERRCODE}" >> /tmp/failures + } + +#Deterimine computer type. +function noOS_Support() { + yad --image=$DIR/images/corps-icon.png --center --no-buttons \ + --title "INVALID OS DETECTED" \ + --text "A valid OS was not detected.\n\nThis installer was designed for \ +Debian based distros; specifically Raspbian Stretch, Linux Mint 18.3 / 19.1 and Ubuntu 18.04." \ + ${r} ${c} + exit 1 + +} + +function maybeOS_Support() { + if (yad --image=$DIR/images/corps-icon.png --center \ + --title "Not Supported OS" \ + --text "Your OS may be compatible with this installer but has not been \ +tested.\n\nThis installer has been tested on Raspberry Pi OS Buster and Bullseye \ +(32bit and 64bit), Linux Mint 20.3 and 21. It should work on most Debian 10 / 11 based distros. \n\nWould you like to continue anyway?" ${r} ${c}) then + yad --image=$DIR/images/corps-icon.png --center \ + --title "Not Supported OS" \ + --text "::: Did not detect perfectly supported OS but,\n\n \ +::: Continuing installation at user's own risk..." ${r} ${c} || + { echo "exiting"; exit 1; } + else + yad --image=$DIR/images/corps-icon.png --center \ + --title "Not Supported OS" \ + --text "::: Exiting due to unsupported OS" ${r} ${c} + exit 1 + fi +} + +# Compatibility check for OS + # if lsb_release command is on their system + if hash lsb_release 2>/dev/null; then + + PLAT=$(lsb_release -si) + OSCN=$(lsb_release -sc) # We want this to be trusty xenial bionic cosmic disco; jessie strech buster; sara serena sonya sylvia tara tessa tina + + else # else get info from os-release + + PLAT=$(grep "^NAME" /etc/os-release | awk -F "=" '{print $2}' | tr -d '"' \ + | awk '{print $1}') + VER=$(grep "VERSION_ID" /etc/os-release | awk -F "=" '{print $2}' | tr -d '"') + declare -A VER_MAP=(["11"]="bullseye" ["10"]="buster" ["9"]="stretch" ["8"]="jessie" ["16.04"]="xenial" \ + ["14.04"]="trusty" ["18.04"]="bionic" ["18.10"]="cosmic" ["19.04"]="disco" ["19.10"]="eoan" ["20.04"]="focal" ["18"]="sara" ["18.1"]="serena" \ + ["18.2"]="sonya" ["18.3"]="sylvia" ["19"]="tara" ["19.1"]="tessa" ["19.2"]="tina" ["19.3"]="tricia" ["20"]="ulyana" ["20.3"]="una" ["21"]="vanessa" ) + OSCN=${VER_MAP["${VER}"]} + + fi + + case ${PLAT} in + Raspbian|Debian|Linuxmint) + case ${OSCN} in + buster|bullseye|una|vanessa) + ;; + *) + maybeOS_Support + ;; + esac + ;; + *) + noOS_Support + ;; + esac + + +#create a finish trap +function finish { + if [[ -f /tmp/results ]]; then +rm /tmp/results +fi + +if [[ -f /tmp/mastermenu ]]; then +rm /tmp/mastermenu +fi + +if [[ -f /tmp/cleanup ]]; then +rm /tmp/cleanup +fi + +if [[ -f /tmp/failures ]]; then +rm /tmp/failures +fi + +} +trap finish EXIT + + +##make sure we dont already have a cleanup, mastermenu, or results text file + +if [[ -f /tmp/results ]]; then + echo "Results file previously exists. Moving to /tmp/results.bak" + mv /tmp/results /tmp/results.bak +fi + +if [[ -f /tmp/mastermenu ]]; then + echo "/tmp/mastermenu file previously exists. Moving to /tmp/mastermenu.bak" + mv /tmp/mastermenu /tmp/mastermenu.bak +fi + +if [[ -f /tmp/cleanup ]]; then + echo "/tmp/cleanup file previously exists. Moving to /tmp/cleanup.bak" + mv /tmp/cleanup /tmp/cleanup.bak +fi + +if [[ -f /tmp/failures ]]; then + echo "/tmp/failures file previously exists. Moving to /tmp/failures.bak" + mv /tmp/failures /tmp/failures.bak +fi + +function confirm_mint21() { + +if [ $OSCN != vanessa ]; then + yad --image=$DIR/images/corps-icon.png --center \ + --title "Not Supported OS" \ + --text "::: Exiting due to unsupported OS. This script has only been tested on Mint 21 at this time." ${r} ${c} + exit 1 +fi +} + +################# VARAHFVER=$(curl -s https://rosmodem.wordpress.com/ | grep -m 1 "VARA HF" | awk -F "VARA HF" '{print $2}' | awk -F " " '{print $1}' | sed s/\ //g) VARAFMVER=$(curl -s https://rosmodem.wordpress.com/ | grep -m 1 "VARA FM" | awk -F "VARA FM" '{print $2}' | awk -F " " '{print $1}' | sed s/\ //g) VARACHATVER=$(curl -s https://rosmodem.wordpress.com/ | grep -m 1 "VARA Chat" | awk -F "VARA Chat" '{print $2}' | awk -F " " '{print $1}' | sed s/\ //g) @@ -102,7 +272,8 @@ unzip Winlink_Express_install*.zip } - +set_screen_size +confirm_mint21 usergroups install_wine installvara