Skip to content

Commit

Permalink
Linux Konventionen
Browse files Browse the repository at this point in the history
  • Loading branch information
eskopp committed Nov 22, 2023
1 parent 736ca1e commit 644d250
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The commands for Java are platform independent. Therefore, it doesn't matter if
- Linux
```bash
dos2unix makefile.sh
chmod +x makefile.sh
sudo sh makefile.sh
```
- Windows
Expand Down
30 changes: 27 additions & 3 deletions makefile.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
#!/bin/bash

# Function to print error message in red
print_error() {
echo -e "\e[91m$1\e[0m"
}

# Function to prompt the user with [Y/n] and return true for Y, false for n
prompt_user() {
read -p "$1 [Y/n]: " response
case "$response" in
[yY]|"") return 0 ;; # Accept "Yes" if no input is given
*) print_error "Aborted. Exiting..."; exit 1 ;;
esac
}

# Check and install missing dependencies
check_dependency() {
if ! command -v "$1" &> /dev/null; then
echo "$1 is not installed. Installing..."
sudo apt-get update
sudo apt-get install -y "$1"
print_error "$1 is not installed."
if prompt_user "Do you want to install $1?"; then
sudo apt-get update
sudo apt-get install -y "$1"
if [ $? -eq 0 ]; then
echo "$1 has been successfully installed."
else
print_error "Failed to install $1. Please install it manually."
fi
else
print_error "Skipping installation of $1."
fi
else
echo "$1 is already installed."
fi
Expand All @@ -15,6 +38,7 @@ check_dependency "coreutils"
check_dependency "default-jre"
check_dependency "default-jdk"


# Compile the Java code and create the JAR archive
compile_and_create_jar() {
echo "Compiling the Java code..."
Expand Down

0 comments on commit 644d250

Please sign in to comment.