Hello Mafia,
I had been looking for a bash script to do this task and I have yet to find one that is up-to date and or uses GitHub to not slam the mafia servers.
Maybe I'm blind or didn't look enough but I made this. The script is a little crude but if anyone has any suggestions, please let me know.
Updated the script to rm old version numbers. Updated again to remove cut in place for awk+grep. Sort "should" help with it never breaking due to the version number being six digits.
https://github.com/xaix1999/general-scripts/blob/main/KoLmafia.sh
I had been looking for a bash script to do this task and I have yet to find one that is up-to date and or uses GitHub to not slam the mafia servers.
Maybe I'm blind or didn't look enough but I made this. The script is a little crude but if anyone has any suggestions, please let me know.
Updated the script to rm old version numbers. Updated again to remove cut in place for awk+grep. Sort "should" help with it never breaking due to the version number being six digits.
https://github.com/xaix1999/general-scripts/blob/main/KoLmafia.sh
Bash:
#! /bin/bash
Ver=$(curl -s https://api.github.com/repos/kolmafia/kolmafia/releases/latest | grep --color=never tag_name | grep --color=never -o '[0-9]\+')
#
## echo $Ver
re='^[0-9]+$'
if ! [[ $Ver =~ $re ]] ; then
echo "error: Version is not a number" >&2; exit 1
fi
#
ArA='KoLmafia*'
for i in $ArA
do
if ! [[ $i =~ "KoLmafia-"$Ver".jar" ]] ; then
rm $i
fi
done
#
if ! [[ -f "KoLmafia-"$Ver".jar" ]] ; then
wget -q https://github.com/kolmafia/kolmafia/releases/download/r$Ver/KoLmafia-$Ver.jar
fi
#
java -jar KoLmafia-$Ver.jar &>/dev/null &disown
Last edited: