Ludii Forum
Bash script for launching and updating Ludii - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: General (https://ludii.games/forums/forumdisplay.php?fid=1)
+--- Forum: Discussion (https://ludii.games/forums/forumdisplay.php?fid=4)
+--- Thread: Bash script for launching and updating Ludii (/showthread.php?tid=599)



Bash script for launching and updating Ludii - fbarbe - 06-07-2021

Hi,

I don't know if this is the right place to share this but I made a small bash script that automatically downloads the latest Ludii version, makes it executable and launches it.

It requires curl (and java to run Ludii) and should work on Mac and Linux.
The forum doesn't allow me to add it as an attachment, so here's the code:

Code:
#!/bin/sh
LUDII_SERVER_VERSION=$(curl -s -N https://ludii.games/download.php | grep -o -m 1 "Ludii.*\.jar")
if [ "${LUDII_SERVER_VERSION}" = "" ]; then
    echo "Unable to determine latest Ludii version"
fi
LUDII_LOCAL_VERSION=$(ls | grep -o -m 1 "Ludii.*\.jar")
if [ "${LUDII_SERVER_VERSION}" != "${LUDII_LOCAL_VERSION}" ]; then
    echo "Found newer version of Ludii: $LUDII_SERVER_VERSION";
    echo "Downloading newer version..."
    wget -q "https://ludii.games/downloads/$LUDII_SERVER_VERSION";
    if [ $? -eq 0 ]; then
        echo "Removing old version..."
        rm -f "$LUDII_LOCAL_VERSION";
    else
        echo "Unable to retrieve from server (code $?)"
    fi
else
    echo "Your version is up to date"
fi
LUDII_LOCAL_VERSION=$(ls | grep -o -m 1 "Ludii.*\.jar")
if [ "${LUDII_LOCAL_VERSION}" != "" ]; then
    echo "Launching $LUDII_LOCAL_VERSION"
    chmod +x "$LUDII_LOCAL_VERSION";
    java -jar "$LUDII_LOCAL_VERSION" > /dev/null &
else
    echo "No ludii file found"
fi

This can be saved as a bash file (e.g. Ludii.sh) and ran through the terminal ( `sh Ludii.sh` ).
Let me know if you have any comments.


Best,
Fabio


RE: Bash script for launching and updating Ludii - slimy_asparagus - 06-11-2021

I find myself switching between versions quite a lot. I do use a bash script but it is much less ambitious. I just edit the version number as an when needed.



Code:
#!/bin/bash
clear
java -XX:+HeapDumpOnOutOfMemoryError -jar Ludii-1.2.1.jar



RE: Bash script for launching and updating Ludii - slimy_asparagus - 07-03-2021

(07-03-2021, 01:16 PM)Bugaevsky_Sergey Wrote: How can I play games on this site with other users?

Not on this site as such. You download the JAva program and connect to users with that. I tried to explain in more detail here:

https://boardgamegeek.com/thread/2658936/article/37801637#37801637


RE: Bash script for launching and updating Ludii - fbarbe - 08-18-2021

Here's an updated version of the script that also takes connectivity into account, and has a visual output with zenity.
Code:
#!/bin/sh
LUDII_PATH=./ #change this to the directory where you want to run Ludii
LUDII_SERVER_VERSION=$(curl -s -N https://ludii.games/download.php | grep -o -m 1 "Ludii.*\.jar")
LUDII_LOCAL_VERSION=$(ls $LUDII_PATH | grep -o -m 1 "Ludii.*\.jar")
if [ "${LUDII_SERVER_VERSION}" = "" ]; then
    echo "Unable to determine latest Ludii version"
else if [ "${LUDII_SERVER_VERSION}" != "${LUDII_LOCAL_VERSION}" ]; then
    echo "Found newer version of Ludii: $LUDII_SERVER_VERSION";
    echo "Downloading newer version..."
    wget --progress=bar:force -q "https://ludii.games/downloads/$LUDII_SERVER_VERSION" -P $LUDII_PATH | zenity --title="Downloading $LUDII_SERVER_VERSION" --progress;
    if [ $? -eq 0 ]; then
        echo "Removing old version..."
        rm -f "$LUDII_PATH$LUDII_LOCAL_VERSION";
    else
        echo "Unable to retrieve from server (code $?)"
    fi
else
    echo "Your version is up to date"
fi
fi
LUDII_LOCAL_VERSION=$(ls $LUDII_PATH | grep -o -m 1 "Ludii.*\.jar")
if [ "${LUDII_LOCAL_VERSION}" != "" ]; then
    echo "Launching $LUDII_LOCAL_VERSION"
    chmod +x "$LUDII_PATH$LUDII_LOCAL_VERSION";
    cd $LUDII_PATH;
    java -jar "$LUDII_LOCAL_VERSION" > /dev/null &
else
    echo "No ludii file found"
fi


To turn this script into an application that can be placed on the desktop and integrated in the system, you can create the following ludii.desktop file
Code:
[Desktop Entry]
Type=Application
Exec=sh Ludii.sh
StartupNotify=true
GenericName=Ludii
Icon=ludii.png
Name[en_GB]=Ludii


Change Ludii.sh to the absolute path of your Ludii script and ludii.png to the absolute path of the Ludii icon (which can be downloaded here)


You can then make the desktop script executable either with chmod +x ludii.desktop or by right clicking and place it in your desktop and /usr/share/applications .
Enjoy!


RE: Bash script for launching and updating Ludii - Eric Piette - 01-02-2022

Hi,

The script of Fabio is just in Shell.
Ludii is in Java.

Regards,
Eric