diff --git a/script/start.sh b/script/start.sh new file mode 100644 index 0000000..1af64b6 --- /dev/null +++ b/script/start.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Numbus Installer Bootstrap +# This script clones the repository and launches the NixOS deployment script. + +REPO_URL="https://gittea.dev/numbus/numbus.git" +INSTALL_DIR="/tmp/numbus-installer" + +echo "\n ☁️ Initializing Numbus Installer..." + +# 1. Check for Nix +TEST_FAIL=0 + +if [[ -r /etc/os-release ]] && grep -qi '^ID=nixos\b' /etc/os-release; then + echo -e "\n ✅ NixOS system detected." +else + TEST_FAIL=$((TEST_FAIL + 1)) + echo -e "\n ❌ You are not on a NixOS based system. This is required to continue." +fi + +if [[ "$(uname -m)" == "x86_64" ]]; then + echo -e "\n ✅ x86_64 system detected." +else + TEST_FAIL=$((TEST_FAIL + 1)) + echo -e "\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 + echo -e "\n ⚠️ Continuing anyways, this is not supported by Numbus." +fi + +# 2. Clone/Update the repository +if [[ -e ${INSTALL_DIR}/config/* ]]; then + echo " ⚠️ It seems you have already run this script. Previously generated files need to be cleaned up." + OLD_CONFIG_PATH="${INSTALL_DIR}/trash/$(date +"%Y-%m-%d-%Hh%M")" + mkdir -p ${OLD_CONFIG_PATH} + mv ${INSTALL_DIR} ${OLD_CONFIG_PATH} + echo " ✅ Your files have been moved to the ${OLD_CONFIG_PATH} directory. You can retrieve them there if needed." +fi + +git clone "${REPO_URL}" "${INSTALL_DIR}" -q + +# 3. Launch the deployment script +cd "${INSTALL_DIR}/script" +chmod +x deploy.sh +./deploy.sh \ No newline at end of file