mirror of
https://gitlab.com/amrron/setup-scripts.git
synced 2026-10-17 01:54:00 -04:00
452 lines
15 KiB
Bash
Executable File
452 lines
15 KiB
Bash
Executable File
#!/bin/bash
|
|
################################################################################
|
|
################################################################################
|
|
####################### AmRRON Vara Setup v.0.76 #########################
|
|
####################### Created by TB-14 #########################
|
|
####################### 05 Mar 2024 #########################
|
|
################################################################################
|
|
################################################################################
|
|
|
|
|
|
### This script will perform basic setup for VARA.
|
|
### Tested on Mint 21
|
|
### Using guidance and tools from TK-05, KM4ACK, ptitSeb, Box86, and KI7POL
|
|
# Ask for the administrator password upfront
|
|
clear;echo
|
|
echo "###########################################"
|
|
echo "###########################################"
|
|
echo "╔═╗╔╦╗╦═╗╦═╗╔═╗╔╗╔ ╔═╗╔═╗╦═╗╔═╗╔═╗";
|
|
echo "╠═╣║║║╠╦╝╠╦╝║ ║║║║ ║ ║ ║╠╦╝╠═╝╚═╗";
|
|
echo "╩ ╩╩ ╩╩╚═╩╚═╚═╝╝╚╝ ╚═╝╚═╝╩╚═╩ ╚═╝";
|
|
echo "###########################################"
|
|
echo "###########################################"
|
|
|
|
if $(sudo -n true); then
|
|
return;
|
|
else
|
|
echo "You will be prompted for your sudo password"
|
|
echo "below in order to install vara dependencies."
|
|
echo "###########################################"
|
|
echo "###########################################"
|
|
sudo -v
|
|
|
|
# Keep-alive: update existing `sudo` time stamp until script has finished
|
|
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
|
|
fi
|
|
|
|
#### 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/varafailures
|
|
}
|
|
|
|
#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" ["21.1"]="vera" ["21.2"]="victoria" ["21.3"]="virginia" )
|
|
OSCN=${VER_MAP["${VER}"]}
|
|
|
|
fi
|
|
|
|
case ${PLAT} in
|
|
Raspbian|Debian|Linuxmint)
|
|
case ${OSCN} in
|
|
buster|bullseye|una|vanessa|vera|victoria|virginia)
|
|
;;
|
|
*)
|
|
maybeOS_Support
|
|
;;
|
|
esac
|
|
;;
|
|
*)
|
|
noOS_Support
|
|
;;
|
|
esac
|
|
|
|
|
|
#create a finish trap
|
|
function finish {
|
|
|
|
if [[ -f /tmp/varafailures ]]; then
|
|
rm /tmp/varafailures
|
|
fi
|
|
|
|
}
|
|
trap finish EXIT
|
|
|
|
|
|
##make sure we dont already have a cleanup, mastermenu, or results text file
|
|
|
|
if [[ -f /tmp/varafailures ]]; then
|
|
echo "/tmp/varafailures file previously exists. Moving to /tmp/varafailures.bak"
|
|
mv /tmp/varafailures /tmp/varafailures.bak
|
|
fi
|
|
|
|
function confirm_os() {
|
|
|
|
if [[ $OSCN =~ bullseye|una|vanessa|vera|victoria|virginia ]]; then
|
|
echo "Continuing with install"
|
|
else
|
|
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 Raspberry Pi Bullseye, Mint 20.3 and 21 at this time." ${r} ${c}
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
#################
|
|
echo
|
|
echo "Checking on current versions of VARA HF and FM"
|
|
echo
|
|
|
|
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)
|
|
echo "VARA HF: ${VARAHFVER} available"
|
|
|
|
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)
|
|
echo "VARA FM: ${VARAFMVER} available"
|
|
|
|
#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=https://downloads.winlink.org/VARA%20Products/VARA%20FM%20${VARAFMVER}%20%20setup.zip
|
|
echo "VARA FM URL: ${VARAFMLINK}"
|
|
|
|
VARAHFLINK=https://downloads.winlink.org/VARA%20Products/VARA%20HF%20${VARAHFVER}%20setup.zip
|
|
echo "VARA HF URL: ${VARAHFLINK}"
|
|
|
|
#VARACHATLINK=$(curl -s https://rosmodem.wordpress.com/ | grep -oP '(?=https://mega.nz).*?(?=" target="_blank" rel="noopener noreferrer">VARA Chat v)')
|
|
|
|
function primer_menu() {
|
|
|
|
echo "This program is designed to assist you with installing VARA HF and VARA FM, \
|
|
on your linux machine. The current version has been tested on Raspberry Pi Bullseye 64bit, Mint 20.3, and Mint 21. \
|
|
|
|
Super User (sudo) priveledges are required to perform the apt-get \
|
|
commands.
|
|
|
|
If on Mint, you should have been asked for your password in the terminal to perform some \
|
|
tasks but you should not run the entire program as Root. \
|
|
|
|
You will need to accept agreements and interact with the installers.
|
|
Wine is set to default to pulseaudio. You can modify the winetricks sound=pulse \
|
|
line of this script to alsa if you desire to use alsa instead.
|
|
|
|
This will: \
|
|
check and add user to the dialout, audio, and tty usergroups; \
|
|
install wine and winetricks; download and install VARA HF and FM" | yad \
|
|
--image=$DIR/images/corps-icon.png \
|
|
--text-info \
|
|
--wrap \
|
|
--center \
|
|
--title "Welcome to the AmRRON Vara Installer." \
|
|
${r} ${c} ||
|
|
{ yad --image=$DIR/images/corps-icon.png --center --button="gtk-ok:0" --title "Exit Selected" --text "Exiting installer now" ${r} ${c}; exit 1; }
|
|
|
|
}
|
|
|
|
|
|
|
|
function usergroups() {
|
|
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 ||
|
|
{ ERRCODE="Failed to add user to dialout group"; errors; return; }
|
|
else
|
|
echo "User already in dialout group"
|
|
fi
|
|
|
|
if [ -z "$CHK_TTY" ]; then
|
|
echo "Adding user to tty group"
|
|
sudo usermod -a -G tty $MYUSER ||
|
|
{ ERRCODE="Failed to add user to tty group"; errors; return; }
|
|
else
|
|
echo "User already in tty group"
|
|
fi
|
|
|
|
if [ -z "$CHK_AUDIO" ]; then
|
|
echo "Adding user to audio group"
|
|
sudo usermod -a -G audio $MYUSER ||
|
|
{ ERRCODE="Failed to add user to audio group"; errors; return; }
|
|
else
|
|
echo "User already in audio group"
|
|
fi
|
|
}
|
|
|
|
function install_wine() {
|
|
export WINEARCH=win32
|
|
|
|
#install dependencies
|
|
sudo apt install -y wine-stable winetricks ||
|
|
{ ERRCODE="Failed to install wine-stable and winetricks"; errors; return; }
|
|
|
|
#install with wintricks
|
|
#winetricks winxp ||
|
|
#{ ERRCODE="Failed to set winetricks winxp"; errors; return; }
|
|
#winetricks sound=pulse ||
|
|
#{ ERRCODE="Failed to set winetricks sound=pulse"; errors; return; }
|
|
#winetricks vb6run ||
|
|
#{ ERRCODE="Failed to set winetricks vb6run"; errors; return; }
|
|
#winetricks -q vcrun2015 ||
|
|
#{ ERRCODE="Failed to set winetricks -q vcrun2015"; errors; return; }
|
|
|
|
### Version 2 attempt
|
|
DISPLAY=0 WINEARCH=win32 wine wineboot ||
|
|
{ ERRCODE="Failed to set winearch=win32 and wineboot"; errors; return; }
|
|
winetricks -q dotnet35sp1 win7 sound=pulse ||
|
|
{ ERRCODE="Failed to set winetricks dotnet35sp1 win7 sound=pulse"; errors; return; }
|
|
winetricks -q vb6run win7 sound=pulse || # removed pdh_nt4
|
|
{ ERRCODE="Failed to set winetricks vb6run win7 sound=pulse"; errors; return; }
|
|
|
|
#cleanup cache from installers
|
|
rm -rf ~/.cache/winetricks/ ||
|
|
{ ERRCODE="Failed to remove ~/.cache/winetricks files. These can be removed to free space."; errors; return; }
|
|
|
|
echo "You will need to select your sound system for wine in the following dialog." | yad --image=$DIR/images/corps-icon.png \
|
|
--text-info --wrap \
|
|
--center --button="gtk-ok:0" \
|
|
--title "WINECFG - Select audio." ${r} ${c}
|
|
winecfg
|
|
|
|
}
|
|
|
|
function installvara_mint() {
|
|
#download/install VARA HF/FM
|
|
|
|
if [[ $OSCN = una ]]; then
|
|
sudo apt install -y curl libcurl4-openssl-dev libssl-dev ||
|
|
{ ERRCODE="Failed to install dependencies for pulling vara installation files"; errors; return; }
|
|
|
|
elif [[ $OSCN =~ (vera|vanessa|victoria|virginia) ]]; then
|
|
|
|
sudo apt install -y curl p7zip-full ||
|
|
{ ERRCODE="Failed to install dependencies for pulling vara installation files"; errors; return; }
|
|
|
|
fi
|
|
|
|
cd $HOME/Downloads
|
|
wget ${VARAHFLINK} ||
|
|
{ ERRCODE="Failed to download VARA HF"; errors; return; }
|
|
wget ${VARAFMLINK} ||
|
|
{ ERRCODE="Failed to download VARA FM"; errors; return; }
|
|
|
|
|
|
unzip VARA\ FM\ $VARAFMVER*.zip ||
|
|
{ ERRCODE="Failed to unzip VARA FM"; errors; return; }
|
|
unzip VARA\ HF\ $VARAHFVER*.zip ||
|
|
{ ERRCODE="Failed to unzip VARA HF"; errors; return; }
|
|
#unzip VARA\ Chat\ $VARACHATVER\ Setup.zip ||
|
|
#{ ERRCODE="Failed to unzip VARA Chat"; errors; return; }
|
|
|
|
#rm VARA\ HF\ $VARAHFVER*.zip ||
|
|
rm VARA\ FM\ $VARAFMVER*.zip VARA\ HF\ $VARAHFVER*.zip || #VARA\ Chat\ $VARACHATVER\ Setup.zip ||
|
|
{ ERRCODE="Failed to remove VARA zip files"; errors; return; }
|
|
#install VARA FM with wine
|
|
/usr/bin/wine VARA\ FM\ setup\ \(Run\ as\ Administrator\).exe ||
|
|
{ ERRCODE="Failed to install VARA FM"; errors; return; }
|
|
#install VARA with wine
|
|
/usr/bin/wine VARA\ setup\ \(Run\ as\ Administrator\).exe ||
|
|
{ ERRCODE="Failed to install VARA HF"; errors; return; }
|
|
#install VARA Chat with wine
|
|
#/usr/bin/wine VARA\ Chat\ setup\ \(Run\ as\ Administrator\).exe ||
|
|
#{ ERRCODE="Failed to install VARA Chat"; errors; return; }
|
|
|
|
#Install Driver
|
|
cd $HOME/Downloads && wget http://files.k6eta.com/pdh.dll.zip ||
|
|
{ ERRCODE="Failed to download k6eta pdh.dll drivers"; errors; return; }
|
|
unzip pdh.dll.zip && rm pdh.dll.zip ||
|
|
{ ERRCODE="Failed to unzip k6eta drivers"; errors; return; }
|
|
mv pdh.dll $HOME/.wine/drive_c/windows/system32 ||
|
|
{ ERRCODE="Failed to move drivers to $HOME/.wine/drive_c/windows/system32"; errors; return; }
|
|
|
|
}
|
|
|
|
function installrmsexpress() {
|
|
cd $HOME/Downloads
|
|
wget -q -r -l1 -np -nd -A "Winlink_Express_install_*.zip" https://downloads.winlink.org/User%20Programs ||
|
|
{ ERRCODE="Failed to download Winlink Express"; errors; return; }
|
|
unzip Winlink_Express_install*.zip && rm Winlink_Express_install*.zip ||
|
|
{ ERRCODE="Failed to unzip Winlink Express"; errors; return; }
|
|
/usr/bin/wine Winlink_Express_install.exe ||
|
|
{ ERRCODE="Failed to Install Winlink Express"; errors; return; }
|
|
|
|
}
|
|
|
|
|
|
|
|
function failure_handling() {
|
|
|
|
FAIL=$(cat /tmp/varafailures) || echo "No failures recorded"
|
|
|
|
|
|
if [[ -f /tmp/varafailures ]]; 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/varafailures $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 pi_install() {
|
|
cd $HOME/Downloads && wget https://raw.githubusercontent.com/WheezyE/Winelink/main/install_winelink.sh
|
|
|
|
sed -i 's/alsa/pulse/g' install_winelink.sh
|
|
|
|
bash install_winelink.sh vara_only
|
|
|
|
}
|
|
|
|
function complete() {
|
|
echo "All selected updates have been completed." | yad --image=$DIR/images/donate.png \
|
|
--text-info --center --wrap --button="gtk-ok:0" \
|
|
--title "Complete" ${r} ${c}
|
|
|
|
echo "You will need to set your sound card usage in each program on first use.
|
|
|
|
It is recommended to restart your system before continuing.
|
|
|
|
Would you like to restart now?" | yad --center \
|
|
--text-info --wrap \
|
|
--image=$DIR/images/corps-icon.png \
|
|
--title "Restart" --button="No:1" --button="Restart:2" ${r} ${c}
|
|
rc=$?
|
|
if [[ $rc -eq 2 ]]; then
|
|
sudo shutdown -r now
|
|
elif [[ $rc -eq 1 ]]; then
|
|
echo "Good luck and 73's. If you have any issues or suggestions please contact tb14@protonmail.com or submit a merge request on gitlab." | yad --image=$DIR/images/corps-icon.png \
|
|
--text-info --wrap \
|
|
--center --button="gtk-ok:0" \
|
|
--title "Thank you." ${r} ${c}
|
|
exit 1
|
|
else
|
|
echo "You closed the window without making a selection. Installer exiting."
|
|
|
|
exit 1
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_screen_size
|
|
confirm_os
|
|
primer_menu
|
|
if [[ $PLAT = Linuxmint ]]; then
|
|
usergroups
|
|
install_wine
|
|
installvara_mint
|
|
#installrmsexpress
|
|
else
|
|
pi_install
|
|
fi
|
|
failure_handling
|
|
complete |