-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_init.sh
executable file
·51 lines (41 loc) · 1.52 KB
/
run_init.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
#!/bin/bash -x
# BASE IMAGE: any (including unsupported)
# This script tries to automatically detect and init/configure the host platform.
# TODO consider logging errors to STDERR?
. prelude.sh
LOG_PATH="$(pwd)/Logs/$(date '+%Y%m%d_%H%M%S').log"
readonly LOG_PATH
mkdir -p "$(dirname "${LOG_PATH}")"
function try_platform
{
pushd "$1" || exit "${EXIT_FILE_IO_ERROR}"
time ./run_all.sh "$2" 2>&1 | tee "${LOG_PATH}"
local STATUS="${PIPESTATUS[0]}"
if [[ "${STATUS}" == "0" ]]; then
echo -e "${GREEN}run_init.sh: All configuration scripts run successfully.${NC}" \
| tee --append "${LOG_PATH}"
else
echo -e "${RED}run_init.sh: Error - exit code ${STATUS}${NC}" \
| tee --append "${LOG_PATH}"
fi
if [[ "${STATUS}" != "${EXIT_INCORRECT_PLATFORM}" ]]; then
exit "${STATUS}"
fi
popd || exit "${EXIT_FILE_IO_ERROR}"
}
# TODO set timezone before running anything...
# TODO fix
# see: https://linuxize.com/post/how-to-set-or-change-timezone-on-debian-10/
# see: https://chatgpt.com/share/e001132e-2bfc-4b68-ab99-8697da44ccc2
# timedatectl set-timezone Europe/Vienna
# TODO rationalize parameter passing
try_platform "UbuntuCLI" "$1"
try_platform "DebianCLI" "$1"
try_platform "KaliCLI" "$1"
try_platform "Ubuntu_22.04" "$1"
try_platform "PopOS_22.04" "$1"
try_platform "Android_13" "$1"
echo -e "${RED}run_init.sh: Fatal error - Unsupported platform " \
"- no supported platform detected.${NC}" \
| tee --append "${LOG_PATH}"
exit "${EXIT_INCORRECT_PLATFORM}"