-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathinstall-forefire.sh
More file actions
79 lines (65 loc) · 1.99 KB
/
install-forefire.sh
File metadata and controls
79 lines (65 loc) · 1.99 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -e
IFS=$'\n\t'
# --- parse flags
AUTO_ANS=0
while [[ $# -gt 0 ]]; do
case "$1" in
-y|--yes)
AUTO_ANS=1
shift
;;
*)
echo "Usage: $0 [-y|--yes]" >&2
exit 1
;;
esac
done
echo -e "\n========= FOREFIRE INSTALLER ========"
PROJECT_ROOT="$(pwd)"
echo "Project Root detected as: $PROJECT_ROOT"
echo -e "\n======== UNIX REQUIREMENTS ==========\n"
apt-get update
apt install build-essential -y
apt install libnetcdf-c++4-dev -y
apt install cmake -y
echo -e "\n======= BUILD WITH CMAKE ==========\n"
# Determine the absolute path to the bin directory.
BIN_PATH="$PROJECT_ROOT/bin"
mkdir -p build
cd build
cmake ../
make -j"$(nproc)"
echo -e "\n=== ForeFire has been installed to $BIN_PATH ===\n"
# Determine which shell configuration file to update.
# If the script is run via sudo, use the SUDO_USER's home directory.
if [ -n "${SUDO_USER:-}" ]; then
CONFIG_FILE="/home/$SUDO_USER/.bashrc"
else
CONFIG_FILE="$HOME/.bashrc"
fi
PATH_LINE="export PATH=\"$BIN_PATH:\$PATH\""
FOREFIREHOME_LINE="export FOREFIREHOME=\"$PROJECT_ROOT\""
# Check if we've already updated the PATH in this file.
if grep -qF "$BIN_PATH" "$CONFIG_FILE"; then
echo "ForeFire already appears in your PATH in $CONFIG_FILE."
else
if (( AUTO_ANS )); then
ans=y
else
read -p "Do you want to add ForeFire to your PATH permanently in $CONFIG_FILE? (y/n): " ans
fi
if echo "$ans" | grep -qi '^y'; then
# Append a blank line, a comment, and the export line.
echo "" >> "$CONFIG_FILE"
echo "# Add ForeFire to PATH" >> "$CONFIG_FILE"
echo "$PATH_LINE" >> "$CONFIG_FILE"
echo "$FOREFIREHOME_LINE" >> "$CONFIG_FILE"
echo "ForeFire has been added to your PATH in $CONFIG_FILE."
echo "Please run 'source $CONFIG_FILE' or restart your terminal to update your PATH."
else
echo "No changes made. Please add the following line manually to your shell configuration file:"
echo "$PATH_LINE"
fi
fi
echo -e "\n=== ForeFire installation completed ===\n"