Added debugging flags. Added debugging information.
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
# SCRIPT SETTINGS
|
||||||
|
DEBUG="true"
|
||||||
|
|
||||||
#TARGET SETTINGS
|
#TARGET SETTINGS
|
||||||
export TARGET_HOST="192.168.1.10"
|
export TARGET_HOST="192.168.1.10"
|
||||||
export REMOTE_PASS="example"
|
export REMOTE_PASS="example"
|
||||||
|
|||||||
@@ -384,22 +384,23 @@ services_generation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo -e "\n ✅ Writing configuration files for the selected homelab services..."
|
echo -e "\n ✅ Writing configuration files for the selected homelab services..."
|
||||||
cp -avu templates/nix-config/configuration.nix final-nix-config/etc/nixos/configuration.nix
|
cp -${FILES_COPY_FLAGS} templates/nix-config/configuration.nix final-nix-config/etc/nixos/configuration.nix
|
||||||
cp -avu templates/nix-config/podman/traefik.nix final-nix-config/etc/nixos/podman/traefik.nix
|
cp -${FILES_COPY_FLAGS} templates/nix-config/podman/traefik.nix final-nix-config/etc/nixos/podman/traefik.nix
|
||||||
envsubst < templates/podman-config/traefik/traefik.yaml > final-nix-config/mnt/config/traefik/traefik.yaml
|
envsubst < templates/podman-config/traefik/traefik.yaml > final-nix-config/mnt/config/traefik/traefik.yaml
|
||||||
|
|
||||||
j=1
|
j=1
|
||||||
for service in "${SELECTED_SERVICES[@]}"; do
|
for service in "${SELECTED_SERVICES[@]}"; do
|
||||||
[[ "${service}" != "virtualization" ]] && cp -avu templates/nix-config/podman/"${service}".nix final-nix-config/etc/nixos/podman/"${service}".nix
|
[[ "${service}" == "frigate" ]] && continue
|
||||||
|
[[ "${service}" != "virtualization" ]] && cp -${FILES_COPY_FLAGS} templates/nix-config/podman/"${service}".nix final-nix-config/etc/nixos/podman/"${service}".nix
|
||||||
SERVICES_NETWORK_IDS+=("${j},$(( ${j} + 1 )):${service}")
|
SERVICES_NETWORK_IDS+=("${j},$(( ${j} + 1 )):${service}")
|
||||||
PODMAN_NETWORKS+=" sudo -u numbus-admin podman network exists \"${service}_frontend\" || sudo -u numbus-admin podman network create --driver=\"bridge\" --subnet=\"172.16.${j}.0/24\" --ip-range=\"172.16.${j}.0/24\" --gateway=\"172.16.${j}.254\" \"${service}_frontend\""$'\n'
|
PODMAN_NETWORKS+=" sudo -u numbus-admin podman network exists \"${service}_frontend\" || sudo -u numbus-admin podman network create --driver=\"bridge\" --subnet=\"172.16.${j}.0/24\" --ip-range=\"172.16.${j}.0/24\" --gateway=\"172.16.${j}.254\" \"${service}_frontend\""$'\n'
|
||||||
((j++))
|
|
||||||
PODMAN_NETWORKS+=" sudo -u numbus-admin podman network exists \"${service}_backend\" || sudo -u numbus-admin podman network create --driver=\"bridge\" --subnet=\"172.16.${j}.0/24\" --ip-range=\"172.16.${j}.0/24\" --gateway=\"172.16.${j}.254\" \"${service}_backend\""$'\n'
|
|
||||||
TRAEFIK_NETWORKS+=" ${service}_frontend:"$'\n'
|
TRAEFIK_NETWORKS+=" ${service}_frontend:"$'\n'
|
||||||
TRAEFIK_NETWORKS+=" ipv4_address: 172.16.${j}.253"$'\n'
|
TRAEFIK_NETWORKS+=" ipv4_address: 172.16.${j}.253"$'\n'
|
||||||
TRAEFIK_REF_NETWORKS+=" ${service}_frontend:"$'\n'
|
TRAEFIK_REF_NETWORKS+=" ${service}_frontend:"$'\n'
|
||||||
TRAEFIK_REF_NETWORKS+=" external: true"$'\n'
|
TRAEFIK_REF_NETWORKS+=" external: true"$'\n'
|
||||||
((j++))
|
((j++))
|
||||||
|
PODMAN_NETWORKS+=" sudo -u numbus-admin podman network exists \"${service}_backend\" || sudo -u numbus-admin podman network create --driver=\"bridge\" --subnet=\"172.16.${j}.0/24\" --ip-range=\"172.16.${j}.0/24\" --gateway=\"172.16.${j}.254\" \"${service}_backend\""$'\n'
|
||||||
|
((j++))
|
||||||
done
|
done
|
||||||
|
|
||||||
for service in "${SELECTED_SERVICES[@]}"; do
|
for service in "${SELECTED_SERVICES[@]}"; do
|
||||||
@@ -410,7 +411,7 @@ j=1
|
|||||||
if [[ "${TARGET_PCIE_CORAL}" == "true" ]]; then
|
if [[ "${TARGET_PCIE_CORAL}" == "true" ]]; then
|
||||||
FRIGATE_DEVICES_BLOCK+=" - /dev/apex_0:/dev/apex_0\n"
|
FRIGATE_DEVICES_BLOCK+=" - /dev/apex_0:/dev/apex_0\n"
|
||||||
sed -i "s|# ./pcie-coral/coral.nix| ./pcie-coral/coral.nix|" final-nix-config/etc/nixos/configuration.nix
|
sed -i "s|# ./pcie-coral/coral.nix| ./pcie-coral/coral.nix|" final-nix-config/etc/nixos/configuration.nix
|
||||||
cp -avu templates/nix-config/pcie-coral/* final-nix-config/etc/nixos/pcie-coral/
|
cp -${FILES_COPY_FLAGS} templates/nix-config/pcie-coral/* final-nix-config/etc/nixos/pcie-coral/
|
||||||
fi
|
fi
|
||||||
if [[ -n "${FRIGATE_DEVICES_BLOCK}" ]]; then
|
if [[ -n "${FRIGATE_DEVICES_BLOCK}" ]]; then
|
||||||
local REPLACEMENT="devices:\n${FRIGATE_DEVICES_BLOCK%\\n}"
|
local REPLACEMENT="devices:\n${FRIGATE_DEVICES_BLOCK%\\n}"
|
||||||
@@ -540,7 +541,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ -n "${SPINDOWN_DISKS_ID[@]}" ]]; then
|
if [[ -n "${SPINDOWN_DISKS_ID[@]}" ]]; then
|
||||||
cp -avu templates/nix-config/disks/spindown.nix final-nix-config/etc/nixos/disks/
|
cp -${FILES_COPY_FLAGS} templates/nix-config/disks/spindown.nix final-nix-config/etc/nixos/disks/
|
||||||
local FORMATTED_DISKS=""
|
local FORMATTED_DISKS=""
|
||||||
for disk in "${SPINDOWN_DISKS_ID[@]}"; do
|
for disk in "${SPINDOWN_DISKS_ID[@]}"; do
|
||||||
FORMATTED_DISKS+=" \"$disk\"\n"
|
FORMATTED_DISKS+=" \"$disk\"\n"
|
||||||
@@ -598,8 +599,8 @@ EOF
|
|||||||
|
|
||||||
nix_generation() {
|
nix_generation() {
|
||||||
echo -e "\n ✅ Copying the configuration to the new machine..."
|
echo -e "\n ✅ Copying the configuration to the new machine..."
|
||||||
cp -avu templates/nix-config/flake.nix final-nix-config/etc/nixos/
|
cp -${FILES_COPY_FLAGS} templates/nix-config/flake.nix final-nix-config/etc/nixos/
|
||||||
cp -avu templates/nix-config/misc/* final-nix-config/etc/nixos/misc/
|
cp -${FILES_COPY_FLAGS} templates/nix-config/misc/* final-nix-config/etc/nixos/misc/
|
||||||
|
|
||||||
echo "${SERVER_OWNER_NAME:-User}" > final-nix-config/etc/numbus-server/owner
|
echo "${SERVER_OWNER_NAME:-User}" > final-nix-config/etc/numbus-server/owner
|
||||||
echo -e "\n ✅ Writing correct ips to configuration.nix..."
|
echo -e "\n ✅ Writing correct ips to configuration.nix..."
|
||||||
@@ -617,7 +618,7 @@ nix_generation() {
|
|||||||
sed -i "s|# ./disks/pcr-check.nix| ./disks/pcr-check.nix|" final-nix-config/etc/nixos/configuration.nix
|
sed -i "s|# ./disks/pcr-check.nix| ./disks/pcr-check.nix|" final-nix-config/etc/nixos/configuration.nix
|
||||||
sed -i "s|# boot.initrd.systemd.tpm2.enable = true;| boot.initrd.systemd.tpm2.enable = true;|" final-nix-config/etc/nixos/configuration.nix
|
sed -i "s|# boot.initrd.systemd.tpm2.enable = true;| boot.initrd.systemd.tpm2.enable = true;|" final-nix-config/etc/nixos/configuration.nix
|
||||||
sed -i "s|# systemIdentity.enable = true;| systemIdentity.enable = true;|" /etc/nixos/configuration.nix
|
sed -i "s|# systemIdentity.enable = true;| systemIdentity.enable = true;|" /etc/nixos/configuration.nix
|
||||||
cp -avu templates/nix-config/disks/pcr-check.nix final-nix-config/etc/nixos/disks/
|
cp -${FILES_COPY_FLAGS} templates/nix-config/disks/pcr-check.nix final-nix-config/etc/nixos/disks/
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,7 +780,7 @@ export_configuration() {
|
|||||||
local CONFIG_EXPORT_DIR="final-nix-config/etc/numbus-server/"
|
local CONFIG_EXPORT_DIR="final-nix-config/etc/numbus-server/"
|
||||||
local CONFIG_EXPORT_FILE="${CONFIG_EXPORT_DIR}/numbus-server.conf"
|
local CONFIG_EXPORT_FILE="${CONFIG_EXPORT_DIR}/numbus-server.conf"
|
||||||
|
|
||||||
cp -avu templates/post-install/numbus-server.sh "$CONFIG_EXPORT_DIR"
|
cp -${FILES_COPY_FLAGS} templates/post-install/numbus-server.sh "$CONFIG_EXPORT_DIR"
|
||||||
|
|
||||||
echo "export TARGET_INTERFACE=\"${TARGET_INTERFACE}\"" >> $CONFIG_EXPORT_FILE
|
echo "export TARGET_INTERFACE=\"${TARGET_INTERFACE}\"" >> $CONFIG_EXPORT_FILE
|
||||||
echo -e "\n# SERVER SETTINGS" >> $CONFIG_EXPORT_FILE
|
echo -e "\n# SERVER SETTINGS" >> $CONFIG_EXPORT_FILE
|
||||||
@@ -934,6 +935,14 @@ EOF
|
|||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
if [[ "${DEBUG:-false}" == "true" ]]; then
|
||||||
|
DIR_COPY_FLAGS="ravu"
|
||||||
|
FILES_COPY_FLAGS="avu"
|
||||||
|
else
|
||||||
|
DIR_COPY_FLAGS="rau"
|
||||||
|
FILES_COPY_FLAGS="au"
|
||||||
|
fi
|
||||||
|
|
||||||
# Choose the action
|
# Choose the action
|
||||||
ACTION_ANSWER=$(gum choose "[1] 🌐 Deploy NixOS on a remote machine" "[2] 💽 Deploy NixOS on a remote machine with a file configuration" "[3] 🛠️ Update a NixOS remote machine")
|
ACTION_ANSWER=$(gum choose "[1] 🌐 Deploy NixOS on a remote machine" "[2] 💽 Deploy NixOS on a remote machine with a file configuration" "[3] 🛠️ Update a NixOS remote machine")
|
||||||
|
|
||||||
|
|||||||
@@ -14,20 +14,26 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [[ -e /home/numbus-admin/.numbus-server/activated.true ]]; then
|
if [[ -e /home/numbus-admin/.numbus-server/activated.true ]]; then
|
||||||
|
echo "Already activated"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Creating directories with correct permissions..."
|
||||||
mkdir -p /mnt/config/ /mnt/data/ /mnt/data/nextcloud/
|
mkdir -p /mnt/config/ /mnt/data/ /mnt/data/nextcloud/
|
||||||
mkdir -p /home/numbus-admin/.numbus-server/
|
mkdir -p /home/numbus-admin/.numbus-server/
|
||||||
chown -R numbus-admin:users /mnt/config/
|
chown -R numbus-admin:users /mnt/config/
|
||||||
chown -R numbus-admin:users /mnt/data/
|
chown -R numbus-admin:users /mnt/data/
|
||||||
chown -R 100032:users /mnt/data/nextcloud/
|
chown -R 100032:users /mnt/data/nextcloud/
|
||||||
|
|
||||||
|
echo "Creating podman networks..."
|
||||||
|
export PATH=$PATH:/run/wrappers/bin
|
||||||
|
|
||||||
PODMAN_NETWORKS
|
PODMAN_NETWORKS
|
||||||
|
|
||||||
mkdir -p /home/numbus-admin/.numbus-server/
|
mkdir -p /home/numbus-admin/.numbus-server/
|
||||||
touch /home/numbus-admin/.numbus-server/activated.true
|
touch /home/numbus-admin/.numbus-server/activated.true
|
||||||
chown -R numbus-admin:users /home/numbus-admin/.numbus-server/
|
chown -R numbus-admin:users /home/numbus-admin/.numbus-server/
|
||||||
|
echo "Activated successfully !"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,16 +58,18 @@ PODMAN_NETWORKS
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
if [[ -e /home/numbus-admin/.numbus-server/quirked.true ]]; then
|
if [[ -e /home/numbus-admin/.numbus-server/quirked.true ]]; then
|
||||||
|
echo "Quirks already applied"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DOMAIN_NAME="$(cat /run/secrets/domain_name)"
|
DOMAIN_NAME="$(cat /run/secrets/domain_name)"
|
||||||
|
|
||||||
|
echo "Applying Pi-Hole quirks..."
|
||||||
if [[ -e /etc/nixos/podman/pi-hole.nix ]]; then
|
if [[ -e /etc/nixos/podman/pi-hole.nix ]]; then
|
||||||
mkdir -p /mnt/config/pi-hole/
|
mkdir -p /mnt/config/pi-hole/
|
||||||
chown -R numbus-admin:users /mnt/config/pi-hole/
|
chown -R numbus-admin:users /mnt/config/pi-hole/
|
||||||
|
echo "Waiting for Pi-hole to be ready..."
|
||||||
until [[ -e /mnt/config/pi-hole/pihole-FTL.db ]]; do
|
until [[ -e /mnt/config/pi-hole/pihole-FTL.db ]]; do
|
||||||
echo "Waiting for Pi-hole to be ready..."
|
|
||||||
sleep 15
|
sleep 15
|
||||||
done
|
done
|
||||||
sleep 60
|
sleep 60
|
||||||
@@ -71,11 +79,12 @@ PODMAN_NETWORKS
|
|||||||
echo "Pi-Hole quirk applied and service ready !"
|
echo "Pi-Hole quirk applied and service ready !"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Applying Home Assistant quirks..."
|
||||||
if [[ -e /etc/nixos/podman/home-assistant.nix ]]; then
|
if [[ -e /etc/nixos/podman/home-assistant.nix ]]; then
|
||||||
mkdir -p /mnt/config/home-assistant/
|
mkdir -p /mnt/config/home-assistant/
|
||||||
chown -R numbus-admin:users /mnt/config/home-assistant/
|
chown -R numbus-admin:users /mnt/config/home-assistant/
|
||||||
|
echo "Waiting for Home Assistant to be ready..."
|
||||||
until [[ -e /mnt/config/home-assistant/configuration.yaml ]]; do
|
until [[ -e /mnt/config/home-assistant/configuration.yaml ]]; do
|
||||||
echo "Waiting for Home Assistant to be ready..."
|
|
||||||
sleep 15
|
sleep 15
|
||||||
done
|
done
|
||||||
sleep 180
|
sleep 180
|
||||||
@@ -92,11 +101,12 @@ EOF
|
|||||||
echo "Home Assistant quirk applied and service ready !"
|
echo "Home Assistant quirk applied and service ready !"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Applying Frigate quirks..."
|
||||||
if [[ -e /etc/nixos/podman/frigate.nix ]]; then
|
if [[ -e /etc/nixos/podman/frigate.nix ]]; then
|
||||||
mkdir -p /mnt/config/frigate/
|
mkdir -p /mnt/config/frigate/
|
||||||
chown -R numbus-admin:users /mnt/config/frigate/
|
chown -R numbus-admin:users /mnt/config/frigate/
|
||||||
|
echo "Waiting for Frigate to be ready..."
|
||||||
until [[ -e /mnt/config/frigate/config.yaml ]]; do
|
until [[ -e /mnt/config/frigate/config.yaml ]]; do
|
||||||
echo "Waiting for Frigate to be ready..."
|
|
||||||
sleep 15
|
sleep 15
|
||||||
done
|
done
|
||||||
sleep 180
|
sleep 180
|
||||||
@@ -113,6 +123,7 @@ EOF
|
|||||||
mkdir -p /home/numbus-admin/.numbus-server/
|
mkdir -p /home/numbus-admin/.numbus-server/
|
||||||
touch /home/numbus-admin/.numbus-server/quirked.true
|
touch /home/numbus-admin/.numbus-server/quirked.true
|
||||||
chown -R numbus-admin:users /home/numbus-admin/.numbus-server/
|
chown -R numbus-admin:users /home/numbus-admin/.numbus-server/
|
||||||
|
echo "Quirks applied successfully !"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user