Created
January 16, 2025 19:42
-
-
Save Chewt/eab8f68355343a3020d0d72c9c32d911 to your computer and use it in GitHub Desktop.
Ogatak installation script (linux)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install script to make installing ogatak easier | |
REPO_URL="https://api.github.com/repos/rooklift/ogatak/releases/latest" | |
CONFIG_URL="https://raw.githubusercontent.com/sanderland/katrain/refs/heads/master/katrain/KataGo/analysis_config.cfg" | |
# Use curl to fetch the JSON data for the latest release | |
RELEASE_DATA=$(curl -s -H "Accept: application/json" "$REPO_URL" 2>/dev/null) | |
# Extract the URL of the latest release using jq | |
LATEST_RELEASE_URL=$(jq -r '.assets[0].browser_download_url' <<< "$RELEASE_DATA") | |
# Check each release URL to find one that contains 'linux' | |
for RELEASE in $ALL_RELEASES; do | |
if [[ $RELEASE =~ linux ]]; then | |
echo "Latest release is for Linux" | |
LATEST_RELEASE_URL=$RELEASE | |
break | |
fi | |
done | |
if [ -z "$LATEST_RELEASE_URL" ]; then | |
echo "Error: No release contains 'linux' in the URL" | |
exit | |
fi | |
echo "$LATEST_RELEASE_URL" | |
# Check if katago exists in PATH | |
if command -v katago &> /dev/null; then | |
KATAGO_PATH=$(which katago) | |
echo "Katago found at: $KATAGO_PATH" | |
else | |
echo "Error: Katago not found in PATH. Please install katago, or add it to PATH" | |
exit | |
fi | |
# check for model files | |
MODEL_FILE=$(find /usr/share/katago/networks -name 'latest*.bin.gz' 2>/dev/null) | |
if [ -n "$MODEL_FILE" ]; then | |
echo "Model file found: $MODEL_FILE" | |
else | |
echo "No model file found. Manually add it in ogatak." | |
fi | |
# Setup config files | |
mkdir -p $HOME/.config/Ogatak | |
cd $HOME/.config/Ogatak | |
curl -o katrain_config.cfg $CONFIG_URL 2>/dev/null | |
touch config.json | |
cat > config.json <<EOF | |
{ | |
"engine": "${KATAGO_PATH}", | |
"engineconfig": "${HOME}/.config/Ogatak/katrain_config.cfg", | |
"weights": "${MODEL_FILE}" | |
} | |
EOF | |
# Download ogatak latest release | |
cd /tmp | |
wget -O release.zip "$LATEST_RELEASE_URL" 2>/dev/null && unzip -q -o release.zip | |
# Install ogatak | |
echo "installing ogatak..." | |
sudo bash <<EOF | |
mkdir -p /opt/ogatak && rm -rf /opt/ogatak/* | |
mv --force /tmp/$(basename -s .zip $LATEST_RELEASE_URL)/* /opt/ogatak | |
chmod a+rx /opt/ogatak/ogatak | |
ln -f -s /opt/ogatak/ogatak /usr/bin/ogatak | |
EOF | |
if [ $? -ne 0 ]; then | |
echo "Failed to install." | |
exit 1 | |
fi | |
# add desktop entry for ogatak | |
mkdir -p $HOME/.local/share/applications && touch $HOME/.local/share/applications/ogatak.desktop | |
cat > $HOME/.local/share/applications/ogatak.desktop <<EOF | |
[Desktop Entry] | |
Name=Ogatak | |
Comment=KataGo analysis GUI and SGF editor | |
Exec=/usr/bin/ogatak --no-sandbox | |
Terminal=false | |
Type=Application | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment