-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
executable file
·88 lines (78 loc) · 2.17 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
set -e
if [ "$EUID" -ne 0 ]; then
echo "Please run as root using sudo."
exit 1
fi
usage() {
echo "Available commands:"
echo " docker Build Docker containers."
echo " godot Build Godot engines and templates."
echo " -h, --help Show this help message."
echo
echo "For more help on specific commands, use: $0 <command> -h or --help"
echo
}
initialize() {
chmod +x shared.sh
source shared.sh
local config_sh_path
local file="config.sh"
find_file_upwards --file "${file}" --path-ref config_sh_path
if [[ $? -eq 0 ]]; then
chmod +x "$config_sh_path"
source "$config_sh_path"
else
echo "Failed to find $file"
fi
ensure_docker_available
}
main() {
initialize
if [[ $# -eq 0 ]]; then
usage
read -p "Please enter a command (docker or godot): " command
set -- "$command"
fi
while [[ "$#" -gt 0 ]]; do
case "$1" in
docker)
shift
pushd "build-containers/" > /dev/null || exit 1
if [[ -e "./main.sh" ]]; then
chmod +x main.sh
./main.sh "$@"
break
else
echo "Error: main.sh is not executable or does not exist."
exit 1
fi
popd > /dev/null || exit 1
;;
godot)
shift
pushd "build-godot-and-templates/" > /dev/null || exit 1
if [[ -e "./main.sh" ]]; then
chmod +x main.sh
./main.sh "$@"
break
else
echo "Error: main.sh is not executable or does not exist."
exit 1
fi
popd > /dev/null || exit 1
;;
-h|--help)
usage
exit 0
;;
*)
echo "Invalid option: $1"
usage
exit 1
;;
esac
done
}
# Start the script
main "$@"