Update install/script.sh
This commit is contained in:
@@ -1,19 +1,37 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
DEFAULT_REPO="https://git.de-roo.org/ben/Finalpychat.git"
|
DEFAULT_REPO="https://git.de-roo.org/ben/pychat.git"
|
||||||
echo "dankje voor het gebruiken van bens pychat!"
|
echo "Thanks for using PyChat!"
|
||||||
|
|
||||||
|
# Gebruik eerste argument als repo, anders default
|
||||||
REPO_URL="${1:-$DEFAULT_REPO}"
|
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
|
# Controleer of git beschikbaar is
|
||||||
echo "Error: Geen Git repository opgegeven."
|
if ! command -v git &> /dev/null; then
|
||||||
|
echo "Error: git is not installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$DIR_NAME" ]; then
|
# Controleer of python beschikbaar is
|
||||||
git clone "$REPO_URL"
|
if ! command -v python3 &> /dev/null; then
|
||||||
else
|
echo "Error: python3 is not installed."
|
||||||
git clone "$REPO_URL" "$DIR_NAME"
|
exit 1
|
||||||
fi
|
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