#!/bin/bash # # Purpose : Download latest VARA HF, FM and Terminal zips from winlink.org BASE_URL="https://downloads.winlink.org" DOWNLOAD_DIR="/tmp/windowsapps" mkdir -p "$DOWNLOAD_DIR" echo "Fetching VARA Products page..." PAGE=$(curl -s "$BASE_URL/VARA%20Products/") if [ -z "$PAGE" ]; then echo "Error: could not fetch VARA Products page." exit 1 fi # Download and extract a VARA product by pattern download_vara() { local pattern="$1" # Match against URL encoded pattern local encoded_pattern=$(echo "$pattern" | sed 's| |%20|g') ENCODED=$(echo "$PAGE" | grep -oP 'HREF="\K[^"]+' | grep -i "$encoded_pattern") if [ -z "$ENCODED" ]; then echo "Error: could not find $pattern on page." return 1 fi # Decode %20 to spaces for local filename FILENAME=$(echo "$ENCODED" | sed 's|.*/||; s|%20| |g') # Extract version number VERSION=$(echo "$FILENAME" | grep -oP '\d+\.\d+[\.\d]*') if [ -z "$VERSION" ]; then echo "Error: could not determine version from filename: $FILENAME" return 1 fi echo "Found $pattern version: $VERSION" echo "Filename: $FILENAME" local DOWNLOAD_URL="$BASE_URL$ENCODED" local FILEPATH="$DOWNLOAD_DIR/$FILENAME" local EXTRACT_DIR="$DOWNLOAD_DIR/$(echo "$pattern" | sed 's| |_|g')" echo "Downloading $FILENAME..." wget -q "$DOWNLOAD_URL" -O "$FILEPATH" if [ $? -ne 0 ]; then echo "Error: download of $FILENAME failed." return 1 fi echo "Extracting to $EXTRACT_DIR..." rm -rf "$EXTRACT_DIR" mkdir -p "$EXTRACT_DIR" unzip -q "$FILEPATH" -d "$EXTRACT_DIR" if [ $? -eq 0 ]; then echo "Extracted $pattern version $VERSION to $EXTRACT_DIR" rm -f "$FILEPATH" else echo "Error: extraction of $FILENAME failed." return 1 fi } # Install a VARA product using Wine install_vara() { local pattern="$1" local wine_dir="$2" local extract_dir="$DOWNLOAD_DIR/$(echo "$pattern" | sed 's| |_|g')" # Check if already installed if [ -d "$wine_dir" ]; then echo " $pattern is already installed, skipping." return 0 fi if [ ! -d "$extract_dir" ]; then echo "Error: directory $extract_dir not found, skipping." return 1 fi # Find the VARA exe file in the extracted directory local exe exe=$(find "$extract_dir" -maxdepth 1 -iname "VARA*.exe" | head -n1) if [ -z "$exe" ]; then echo "Error: no VARA*.exe found in $extract_dir, skipping." return 1 fi local exe_name=$(basename "$exe") echo "" echo "=== Installing $exe_name ===" echo "Please complete the installation in the Wine window." echo "The script will continue once the installer is closed." echo "" wine "$exe" echo "$exe_name installation complete." } # Download all VARA products download_vara "VARA HF" download_vara "VARA FM" download_vara "VARA Terminal" # Update Wine registry to disable window decorations USER_REG="$HOME/.wine/user.reg" if [ ! -f "$USER_REG" ]; then echo "Warning: $USER_REG not found, skipping registry update." else echo "Updating Wine registry..." sed -i 's/"Decorated"="Y"/"Decorated"="N"/' "$USER_REG" echo "Set Decorated=N in $USER_REG" fi echo "" echo "All VARA products downloaded and extracted to $DOWNLOAD_DIR" # Install Wine dependencies echo "" echo "Installing Wine dependencies..." winetricks -q vb6run pdh_nt4 sound=alsa if [ $? -ne 0 ]; then echo "Error: winetricks failed, aborting." exit 1 fi echo "Wine dependencies installed successfully." # Install all VARA products echo "" echo "Starting VARA installations..." install_vara "VARA HF" "$HOME/.wine/drive_c/VARA" install_vara "VARA FM" "$HOME/.wine/drive_c/VARA FM" install_vara "VARA Terminal" "$HOME/.wine/drive_c/VARA" echo "" echo "Updating desktop database..." update-desktop-database "$HOME/.local/share/applications/" echo "" echo "All VARA installations complete."