-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·56 lines (45 loc) · 1.83 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
clear
# Get the absolute path to the root directory
ROOT_DIR=$(dirname "$(readlink -f "$0")")
# Set environment variables using relative paths
export USER_MANAGER_SCRIPT="$ROOT_DIR/resources/scripts/user_manager.sh"
export SURVIVAL_RATE_SCRIPT="$ROOT_DIR/resources/scripts/survival_rate.sh"
export SEARCH_COUNTRIES_SCRIPT="$ROOT_DIR/resources/scripts/search_country.sh"
export AUTH_SCRIPT="$ROOT_DIR/resources/scripts/auth.sh"
export REGISTER_SCRIPT="$ROOT_DIR/resources/scripts/register.sh"
export USER_STORE_PATH="$ROOT_DIR/resources/data/user-store.txt"
export LIFE_EXPECTANCY_PATH="$ROOT_DIR/resources/data/life-expectancy.csv"
export PATIENT_DATA_PATH="$ROOT_DIR/downloads/patient_data.csv"
export PATIENT_STATS_PATH="$ROOT_DIR/downloads/patient_statistics.csv"
export ICALENDAR="$ROOT_DIR/downloads/life_expectancy.ics"
# Make all relevant scripts executable
chmod +x "$USER_MANAGER_SCRIPT"
chmod +x "$SURVIVAL_RATE_SCRIPT"
chmod +x "$AUTH_SCRIPT"
chmod +x "$REGISTER_SCRIPT"
chmod +x "$SEARCH_COUNTRIES_SCRIPT"
# Fixed the /bin/bash^M problem
sed -i 's/\r$//' "$USER_MANAGER_SCRIPT"
sed -i 's/\r$//' "$SURVIVAL_RATE_SCRIPT"
sed -i 's/\r$//' "$AUTH_SCRIPT"
sed -i 's/\r$//' "$REGISTER_SCRIPT"
sed -i 's/\r$//' "$SEARCH_COUNTRIES_SCRIPT"
echo "Environment variables set and scripts are now executable."
echo "Building your application...."
# Find all .java files in the src directory
JAVA_FILES=$(find "$ROOT_DIR/src" -name "*.java")
# Compile Java files, output to the bin directory
javac -d "$ROOT_DIR/bin" $JAVA_FILES
# Check if compilation was successful
if [ $? -eq 0 ]; then
echo "Build Complete!."
echo "Launching app...."
# Wait for 3 seconds before launching
sleep 3
clear
# Run the Java application
java -cp "$ROOT_DIR/bin" Main
else
echo "Build failed. Please check the errors above and fix them."
fi