#!/bin/bash

version=5.5.0

wget -O /var/cache/pi-apps/Geekbench5.tar.gz https://cdn.geekbench.com/Geekbench-${version}-LinuxARMPreview.tar.gz
tar -xf /var/cache/pi-apps/Geekbench5.tar.gz -C /var/cache/pi-apps || error "Failed to extract files!"
rm -f /var/cache/pi-apps/Geekbench5.tar.gz ./Geekbench5.tar.gz
sudo mv -f /var/cache/pi-apps/Geekbench-${version}-LinuxARMPreview /opt/geekbench5 || error "Failed to move source folder to /opt!"

# Remove deprecated folder/binary names
sudo rm -rf /opt/geekbench /usr/local/bin/geekbench

# Create symbolic link
sudo ln -sf /opt/geekbench5/geekbench_aarch64 /usr/local/bin/geekbench5 || error "Failed to create symbolic link to /usr/local/bin!"
