Added a compatibility check
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p bash nano coreutils gnused gum fastfetch xkcdpass sops ssh-to-age age sshpass envsubst pciutils usbutils mosquitto curl jq yq python3
|
||||
|
||||
|
||||
|
||||
# --- MAIN FUNCTIONS LOGIC --->
|
||||
echod() {
|
||||
MESSAGE=${1}
|
||||
|
||||
if [[ ${DEBUG} -eq 1 ]]; then
|
||||
echo -e ${MESSAGE}
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -${DIR_RM_FLAGS} /run/numbus/logs
|
||||
rm -${DIR_RM_FLAGS} /run/numbus/web
|
||||
@@ -9,13 +20,38 @@ cleanup() {
|
||||
kill ${BRIDGE_PID}
|
||||
}
|
||||
|
||||
compatibility_check() {
|
||||
TEST_FAIL=0
|
||||
|
||||
if [[ -r /etc/os-release && grep -qi '^ID=nixos\b' /etc/os-release ]]; then
|
||||
echod "\n ✅ NixOS system detected."
|
||||
else
|
||||
((TEST_FAIL++))
|
||||
echo "\n ❌ You are not on a NixOS based system. This is required to continue."
|
||||
fi
|
||||
|
||||
if [[ "$(uname -m)" != "x86_64" ]]; then
|
||||
echod "\n ✅ x86_64 system detected."
|
||||
else
|
||||
((TEST_FAIL++))
|
||||
echo "\n ❌ You are not on a x86_64 based system. This is required to continue."
|
||||
fi
|
||||
|
||||
if [[ ${TEST_FAIL} -gt 0 ]]; then
|
||||
COMPATIBILITY_OVERRIDE=$(gum choose --header "Some compatibility checks failed. The installation will very likely fail. Continue ?" \
|
||||
"No" \
|
||||
"Yes, I know what I am doing")
|
||||
[[ "${COMPATIBILITY_OVERRIDE}" == "No" ]] && exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
launch_configurator() {
|
||||
echo -e "\n 🚀 Launching Numbus Configurator..."
|
||||
python3 "${BRIDGE_SCRIPT}" > /dev/null 2>&1 &
|
||||
export BRIDGE_PID=$!
|
||||
|
||||
echo -e "\n ➡️ Open your browser at: $(gum style --foreground 212 "http://localhost:${PORT}")"
|
||||
xdg-open "http://localhost:${PORT}" 2>/dev/null || open "http://localhost:${PORT}" 2>/dev/null || true
|
||||
echo -e "\n ➡️ Open your browser at: $(gum style --foreground 212 "http://localhost:${WEBSERVER_PORT}")"
|
||||
xdg-open "http://localhost:${WEBSERVER_PORT}" 2>/dev/null || open "http://localhost:${WEBSERVER_PORT}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
preparation() {
|
||||
@@ -41,7 +77,7 @@ preparation() {
|
||||
echo -e "\n Is this URL correct [y/n] ? ${IMPORTED_CONFIG_URL}"
|
||||
read URL
|
||||
|
||||
if [[ "${URL^^}" == "N" ]];
|
||||
if [[ "${URL^^}" == "N" ]]; then
|
||||
git_url
|
||||
fi
|
||||
|
||||
@@ -798,14 +834,9 @@ nix_update() {
|
||||
nixos-rebuild --target-host numbus-admin@${LIVE_TARGET_IP} \
|
||||
--use-remote-sudo switch --flake ${EXTRA_FILES_PATH}/etc/nixos#numbus-server
|
||||
}
|
||||
# --- MAIN FUNCTIONS LOGIC ---<
|
||||
|
||||
echod() {
|
||||
MESSAGE=${1}
|
||||
|
||||
if [[ ${DEBUG} -eq 1 ]]; then
|
||||
echo -e ${MESSAGE}
|
||||
fi
|
||||
}
|
||||
|
||||
# --- DEFAULTS --->
|
||||
WEBSERVER_PORT=${WEBSERVER_PORT:-8088}
|
||||
@@ -836,13 +867,19 @@ else
|
||||
fi
|
||||
# --- DEFAULTS ---<
|
||||
|
||||
# --- MAIN PART ---
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
# --- PRE MAIN LOGIC --->
|
||||
set -euo pipefail
|
||||
clear
|
||||
|
||||
compatibility_check
|
||||
trap cleanup EXIT
|
||||
# --- PRE MAIN LOGIC ---<
|
||||
|
||||
|
||||
|
||||
# --- MAIN LOGIC --->
|
||||
echo """
|
||||
_ ____ ____ ______ __ ______
|
||||
/ |/ / / / / |/ / _ )/ / / / __/
|
||||
@@ -853,7 +890,7 @@ echo """
|
||||
|
||||
DEPLOY_MODE=$(gum choose --header "Choose your preferred configuration interface :" "Through my browser (Recommended for beginners)" "Through my terminal (TUI)")
|
||||
|
||||
if [[ "$DEPLOY_MODE" == "Through my terminal" ]]; then
|
||||
if [[ "$DEPLOY_MODE" == "Through my terminal (TUI)" ]]; then
|
||||
preparation
|
||||
hierarchy_preparation
|
||||
setup_ssh
|
||||
@@ -881,6 +918,8 @@ else
|
||||
|
||||
fi
|
||||
|
||||
# --- MAIN LOGIC ---<
|
||||
|
||||
|
||||
# 3. Load Credentials and run Discovery
|
||||
|
||||
|
||||
Reference in New Issue
Block a user