#!/bin/bash

REPO_DIR="install"
INSTALL_DIR="pychat"
BASE_URL="https://git.de-roo.org/ben/pychat/raw/branch/main"

echo "Thanks for using PyChat!"

# python check
if ! command -v python3 &> /dev/null; then
    echo "Error: python3 is not installed."
    exit 1
fi

# downloader check
if command -v curl &> /dev/null; then
    DL="curl -L -o"
elif command -v wget &> /dev/null; then
    DL="wget -O"
else
    echo "Error: curl or wget required."
    exit 1
fi

mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR" || exit 1

# bestanden downloaden
$DL server.py        "$BASE_URL/server.py"
$DL client.py        "$BASE_URL/client.py"
$DL clientBeta.py    "$BASE_URL/clientBeta.py"
$DL clientWin.py     "$BASE_URL/clientWin.py"
$DL passwd.json      "$BASE_URL/passwd.json"

echo
echo "Don't forget to change IP/port in client.py."
echo "Installation complete."
echo "Start server: python3 server.py"
echo "Start client: python3 client.py"
echo "Start beta: python3 clientBeta.py"