LinuxGSM FiveM

I have a bash script, that checks the latest stable linux artifact, downloads it and write the version number to a file called version, if the artifact version deviates from the one in the file.

Snippet from my FiveM startup script:

build_link="`wget -qO - https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/ | grep 'class=\"button is-link is-primary\">'| sed -r 's/.*href=\".\/([^\"]+).*/\1/g' | head -n1`"
build_link=`echo $build_link | awk '{print $1}'`
version=`echo "$build_link" | grep -o -E '[0-9]+' | head -1 | sed -e 's/^0\+//'`

test -f "/home/ec2-user/FiveM/current_version" || touch "/home/ec2-user/FiveM/current_version"

if ! grep -q "$version" /home/ec2-user/FiveM/current_version; then
   `echo "$version" > "/home/ec2-user/FiveM/current_version"`
   wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/"$build_link" -O /home/ec2-user/FiveM/fx.tar.xz
   sudo rm -rf /home/ec2-user/FiveM/alpine
   sudo tar -xf /home/ec2-user/FiveM/fx.tar.xz -C /home/ec2-user/FiveM
   sudo rm -rf /home/ec2-user/FiveM/fx.tar.xz
fi