Testing vara setup

This commit is contained in:
tb14
2022-11-04 15:34:58 -05:00
parent bcbba2b11d
commit 080961d211
+261
View File
@@ -0,0 +1,261 @@
#!/bin/bash
################################################################################
################################################################################
####################### AmRRON Vara Setup #########################
####################### Created by TB-14 #########################
####################### 04 NOV 2022 #########################
################################################################################
################################################################################
### This script will perform basic setup for VARA.
### Tested on Mint 21
### Using guidance and tools from TK-05 and ptitSeb, Box86, and KI7POL
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}"
}
function determine_os() {
#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
}
# 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"
# 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/vara-failures ]]; then
rm /tmp/vara-failures
fi
}
trap finish EXIT
### clean up from previous attemps
if [[ -f /tmp/vara_failures ]]; then
echo "/tmp/failures file previously exists. Moving to /tmp/failures.bak"
mv /tmp/vara_failures /tmp/vara_failures.bak
fi
# Create a error function to make life easier later on
function errors() {
echo "${ERRCODE}" >> /tmp/vara_failures
}
function install_vara () {
if [[ OSCN = vanessa ]]; then
install install_vara_mint21
elif [[ OSCN = vanessa ]]; then
install install_vara_mint20.3
elif [[ OSCN = bullseye ]] && [[ $(uname -m) = aarch64 ]]; then
install install_vara_pi64
elif [[ OSCN = bullseye ]] && [[ $(uname -m) = armv7l ]]; then
install install_vara_pi_bullseye
elif [[ OSCN = buster ]]; then
install install_vara_pi_buster
fi
}
function install_vara_mint21() {
echo "Wine needs to be installed in order to run VARA on Linux. Would you like me to attempt to do this now?" | yad \
--text-info --image=$DIR/images/corps-icon.png --center --wrap \
--button="No:0" --button="Install Wine:2" \
--title "Wine Installation." \
${r} ${c}
rc=$?
if [[ $rc -eq 2 ]]; then
echo "Installing Wine" | sudo apt-get install -y wine ||
{ ERRCODE="Failed to install wine"; errors; }
else
elif [[ $rc == 0 ]]; then
yad --image=$DIR/images/corps-icon.png --center --button="gtk-ok:0" --title "Exit Selected" --text "Exiting installer now" ${r} ${c}
exit 1
fi
echo "Now we will install the dependencies required" | yad \
--text-info --image=$DIR/images/corps-icon.png --center --wrap \
--button="No:0" --button="Install Dependencies:2" \
--title "Dependency Installation." \
${r} ${c}
rc=$?
if [[ $rc -eq 2 ]]; then
echo "Installing Dependencies" | sudo dpkg --add-architecture i386 && sudo apt update && sudo apt install libc6-i386 && sudo apt install libasound2-plugins:i386 && sudo apt upgrade ||
{ ERRCODE="Failed to install dependencies"; errors; }
else
elif [[ $rc == 0 ]]; then
yad --image=$DIR/images/corps-icon.png --center --button="gtk-ok:0" --title "Exit Selected" --text "Exiting installer now" ${r} ${c}
exit 1
fi
echo "Now we will download, modify, and run the WheezyE installer script." | yad \
--text-info --image=$DIR/images/corps-icon.png --center --wrap \
--button="No:0" --button="Install WheezyE script:2" \
--title "WheezyE Vara Installation." \
${r} ${c}
rc=$?
if [[ $rc -eq 2 ]]; then
echo "Downloading script, modifing for Pulse Audio and running." | wget -P $DIR/Files -N https://raw.githubusercontent.com/WheezyE/Winelink/main/docs/experiments/x86-64_Linux_distros/Debian-Ubuntu_x64.sh && sed -i 's/alsa/pulse/g' $DIR/Files/Debian-Ubuntu_x64.sh ||
{ ERRCODE="Failed to pull WheezyE Debian script and modify for pulse audio"; errors; }
elif [[ $rc == 0 ]]; then
yad --image=$DIR/images/corps-icon.png --center --button="gtk-ok:0" --title "Exit Selected" --text "Exiting installer now" ${r} ${c}
exit 1
fi
bash $DIR/Files/Debian-Ubuntu_x64.sh
}
function install_vara_pi64() {
if [[ OSCN = Linuxmint ]]; then
echo "Wine needs to be installed in order to run VARA on Linux. Would you like me to attempt to do this now?" | yad \
--text-info --image=$DIR/images/corps-icon.png --center --wrap \
--button="No:0" --button="Install Wine:2" \
--title "Wine Installation." \
${r} ${c}
rc=$?
if [[ $rc -eq 2 ]]; then
echo "Installing Wine" | sudo apt-get install -y wine ||
{ ERRCODE="Failed to install wine"; errors; }
else
elif [[ $rc == 0 ]]; then
yad --image=$DIR/images/corps-icon.png --center --button="gtk-ok:0" --title "Exit Selected" --text "Exiting installer now" ${r} ${c}
exit 1
fi
fi
}
function failure_handling() {
FAIL=$(cat /tmp/failures) || echo "No failures recorded"
if [[ -f /tmp/failures ]]; then
yad --image=$DIR/images/corps-icon.png --center --button="Save Log:2" --button="gtk-ok:0" \
--title "Failures" \
--text "The following failures occured during installation:\n\n$FAIL" ${r} ${c} exit=$?
if [[ $? == 2 ]]; then
ERRORLOG=$HOME/AmRRON-Vara-Setup-failures
if [[ -e $ERRORLOG.log ]]; then
i=1
while [[ -e $ERRORLOG-$i.log ]] ; do
let i++
done
ERRORLOG=$ERRORLOG-$i
fi
cp /tmp/failures $ERRORLOG.log
yad --center --button="gtk-ok:0" \
--image=$DIR/images/corps-icon.png \
--title "Failure Log Saved" \
--text "A copy of the failure log was saved at $ERRORLOG.log" ${r} ${c}
fi
fi
}
## Run the script
set_screen_size
determine_os
install_vara
failure_handling