Vara attempt

Removed autoremoval of source directories
This commit is contained in:
tb14
2022-11-05 12:41:10 -05:00
parent 3ef1eab0c2
commit 66ac1e6fb3
3 changed files with 112 additions and 270 deletions
+81 -240
View File
@@ -3,271 +3,112 @@
################################################################################
####################### AmRRON Vara Setup #########################
####################### Created by TB-14 #########################
####################### 04 NOV 2022 #########################
####################### 05 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
### Using guidance and tools from TK-05, KM4ACK, 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"
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)
VARAFMLINK=$(curl -s https://rosmodem.wordpress.com/ | grep -oP '(?=https://mega.nz).*?(?=" target="_blank" rel="noopener noreferrer">VARA FM v)')
VARAHFLINK=$(curl -s https://rosmodem.wordpress.com/ | grep -oP '(?=https://mega.nz).*?(?=" target="_blank" rel="noopener noreferrer">VARA HF v)')
VARACHATLINK=$(curl -s https://rosmodem.wordpress.com/ | grep -oP '(?=https://mega.nz).*?(?=" target="_blank" rel="noopener noreferrer">VARA Chat v)')
# 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_mint21() {
if hash wine 2>/dev/null; then
echo "Wine appears to already be installed. Click OK to continue to the next step" | yad \
--text-info --image=$DIR/images/corps-icon.png --center --wrap \
--button="No:0" --button="OK:2" \
--title "Wine Installation." \
${r} ${c}
rc=$?
if [[ $rc -eq 2 ]]; then
echo "Wine already installed"
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
function usergroups() {
clear;echo
echo "adding user to tty, dialout, & audio groups"
sleep 1
MYUSER=$(whoami)
CHK_DIALOUT=$(id -nG | grep dialout)
CHK_TTY=$(id -nG | grep tty)
CHK_AUDIO=$(id -nG | grep audio)
if [ -z "$CHK_DIALOUT" ]; then
echo "Adding user to dialout group"
sudo usermod -a -G dialout $MYUSER
else
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; }
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
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 -y libc6-i386 && sudo apt install -y libasound2-plugins:i386 && sudo apt upgrade -y ||
{ ERRCODE="Failed to install dependencies"; 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
echo "User already in dialout group"
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
if [ -z "$CHK_TTY" ]; then
echo "Adding user to tty group"
sudo usermod -a -G tty $MYUSER
else
echo "User already in tty group"
fi
bash $DIR/Files/Debian-Ubuntu_x64.sh vara_only
if [ -z "$CHK_AUDIO" ]; then
echo "Adding user to audio group"
sudo usermod -a -G audio $MYUSER
else
echo "User already in audio group"
fi
}
function install_wine() {
export WINEARCH=win32
#install dependencies
sudo apt install -y wine-stable winetricks
#install with wintricks
winetricks winxp
winetricks sound=pulse
winetricks vb6run
winetricks -q vcrun2015
#Install Driver
cd $HOME/Downloads
wget http://files.k6eta.com/pdh.dll.zip
unzip pdh.dll.zip && rm pdh.dll.zip
mv pdh.dll $HOME/.wine/drive_c/windows/system32
}
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; }
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 installvara() {
#download/install VARA HF/FM
sudo apt install -y megatools curl p7zip-full
mkdir -P $USERDIR/VARA && cd $USERDIR/VARA
megadl $VARAHFLINK
megadl $VARAFMLINK
megadl $VARACHATLINK
echo "unzipping VARA files"
sleep 1
unzip VARA\ FM\ $VARAFMVER\ Setup.zip
unzip VARA\ HF\ $VARAHFVER\ Setup.zip
unzip VARA\ Chat\ $VARACHATVER\ Setup.zip
rm VARA\ FM\ $VARAFMVER\ Setup.zip VARA\ HF\ $VARAHFVER\ Setup.zip VARA\ Chat\ $VARACHATVER\ Setup.zip
#install VARA FM with wine
/usr/bin/wine VARA\ FM\ setup\ \(Run\ as\ Administrator\).exe
#install VARA with wine
/usr/bin/wine VARA\ setup\ \(Run\ as\ Administrator\).exe
}
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
}
function install_vara () {
if [[ $OSCN = vanessa ]]; then
install_vara_mint21
elif [[ $OSCN = una ]]; then
install_vara_mint20.3
elif [[ $OSCN = bullseye ]] && [[ $(uname -m) = aarch64 ]]; then
install_vara_pi64
elif [[ $OSCN = bullseye ]] && [[ $(uname -m) = armv7l ]]; then
install_vara_pi_bullseye
elif [[ $OSCN = buster ]]; then
install_vara_pi_buster
fi
function installrmsexpress() {
mkdir -P $USERDIR/Winlink && cd $USERDIR/Winlink
wget -q -r -l1 -np -nd -A "Winlink_Express_install_*.zip" https://downloads.winlink.org/User%20Programs
unzip Winlink_Express_install*.zip
/usr/bin/wine Winlink_Express_install.exe
}
## Run the script
set_screen_size
determine_os
install_vara
failure_handling
echo $VARAHFVER $VARAFMVER $VARACHATVER
megadl $VARAHFLINK
megadl $VARAFMLINK
megadl $VARACHATLINK
wget -q -r -l1 -np -nd -A "Winlink_Express_install_*.zip" https://downloads.winlink.org/User%20Programs
#usergroups
#install_wine
#installvara
#installrmsexpress