Login Page - Create Account

Support Board


Date/Time: Fri, 22 Nov 2024 11:48:53 +0000



Post From: Linux

[2024-09-12 18:22:50]
d9e5c763 - Posts: 108
my sierrachart upgrade script:

#!/bin/bash

get_versions() {
versions=$(curl -s https://www.sierrachart.com/index.php?page=doc/SCZipInstallerList.php |
grep -oP '(?<=SierraChart)\d+(?=\.zip)' |
sort -rnu |
head -n 10)

echo "Available versions:"
counter=1
while IFS= read -r version; do
echo "$counter) $version"
counter=$((counter + 1))
done <<< "$versions"

read -p "Enter a number (1-10) to select a version, or enter a specific version number: " selection

if [[ "$selection" =~ ^[1-9]$|^10$ ]]; then
selected_version=$(echo "$versions" | sed -n "${selection}p")
elif [[ "$selection" =~ ^[0-9]{4,}$ ]]; then
selected_version=$selection
else
echo "Invalid input. Please enter a number between 1 and 10, or a valid version number (at least 4 digits)."
exit 1
fi

echo "You selected version: $selected_version"
main "$selected_version"
}

main() {
local version=$1
local zip_file="SierraChart$version.zip"
local download_url="https://www.sierrachart.com/downloads/ZipFiles/$zip_file"

echo "Attempting to download $zip_file..."
if ! wget -q --spider "$download_url"; then
echo "Error: Version $version is not available for download. The file does not exist on the server."
exit 1
fi

wget "$download_url"
if [ $? -ne 0 ]; then
echo "Error: Failed to download $zip_file"
exit 1
fi

if [ ! -f "$zip_file" ]; then
echo "Error: $zip_file was not downloaded successfully."
exit 1
fi

mkdir -p "./SierraChart_$version/"
unzip "$zip_file" -d "./SierraChart_$version/"
if [ $? -ne 0 ]; then
echo "Error: Failed to unzip $zip_file"
rm -f "$zip_file"
exit 1
fi

rm -rf AlertSounds ; mv "./SierraChart_$version/AlertSounds" ./
rm -rf Graphics ; mv "./SierraChart_$version/Graphics" ./
cp -rf "./SierraChart_$version/SierraChart_64.exe" ./SierraChart/
cp -rf "./SierraChart_$version/SierraChartStudies_64.dll" ./SierraChart/
cp -rf "./SierraChart_$version/ACS_Source/"* ./ACS_Source/
dos2unix ./ACS_Source/*
rm -rf "./SierraChart_$version"
rm -f "$zip_file"

echo "Update to version $version completed successfully."
}

get_versions