Update install/script.sh
This commit is contained in:
@@ -1,19 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEFAULT_REPO="https://git.de-roo.org/ben/Finalpychat.git"
|
||||
echo "dankje voor het gebruiken van bens pychat!"
|
||||
DEFAULT_REPO="https://git.de-roo.org/ben/pychat.git"
|
||||
echo "Thanks for using PyChat!"
|
||||
|
||||
# Gebruik eerste argument als repo, anders default
|
||||
REPO_URL="${1:-$DEFAULT_REPO}"
|
||||
|
||||
DIR_NAME="${2:-}"
|
||||
# Gebruik tweede argument als directory naam, anders afleiden van repo
|
||||
DIR_NAME="${2:-$(basename "$REPO_URL" .git)}"
|
||||
|
||||
if [ -z "$REPO_URL" ]; then
|
||||
echo "Error: Geen Git repository opgegeven."
|
||||
# Controleer of git beschikbaar is
|
||||
if ! command -v git &> /dev/null; then
|
||||
echo "Error: git is not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$DIR_NAME" ]; then
|
||||
git clone "$REPO_URL"
|
||||
else
|
||||
git clone "$REPO_URL" "$DIR_NAME"
|
||||
# Controleer of python beschikbaar is
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
echo "Error: python3 is not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check of directory al bestaat
|
||||
if [ -d "$DIR_NAME" ]; then
|
||||
echo "Directory '$DIR_NAME' already exists. Skipping clone."
|
||||
else
|
||||
git clone "$REPO_URL" "$DIR_NAME" || { echo "Git clone failed."; exit 1; }
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Don't forget to change IP/port in client.py to connect to the correct server."
|
||||
echo "Edit client using: nano $DIR_NAME/client.py"
|
||||
echo
|
||||
|
||||
cd "$DIR_NAME" || exit 1
|
||||
python3 server.py
|
||||
Reference in New Issue
Block a user