Skip to content

Commit a8f4153

Browse files
Mic92Qubasa
andcommitted
Use fixed log file location
- Use fixed location ~/.nixos-anywhere.log instead of mktemp - Compute log file path from remoteHomeDir - Add proper debug output handling in importFacts Co-authored-by: Qubasa <consulting@qube.email>
1 parent 1d4d60d commit a8f4153

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/get-facts.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ hasWget=$(has wget)
2020
hasCurl=$(has curl)
2121
hasSetsid=$(has setsid)
2222
hasNixOSFacter=$(command -v nixos-facter >/dev/null && echo "y" || echo "n")
23+
remoteHomeDir=$HOME
2324
FACTS

src/nixos-anywhere.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ hasWget=
5858
hasCurl=
5959
hasSetsid=
6060
hasNixOSFacter=
61+
remoteHomeDir=
6162

6263
tempDir=$(mktemp -d)
6364
trap 'rm -rf "$tempDir"' EXIT
@@ -571,23 +572,34 @@ importFacts() {
571572
if ! facts=$(runSsh -o ConnectTimeout=10 enableDebug=$enableDebug sh -- <"$here"/get-facts.sh); then
572573
exit 1
573574
fi
574-
filteredFacts=$(echo "$facts" | grep -E '^(has|is)[A-Za-z0-9_]+=\S+')
575+
filteredFacts=$(echo "$facts" | grep -E '^(has|is|remote)[A-Za-z0-9_]+=\S+')
575576
if [[ -z $filteredFacts ]]; then
576577
abort "Retrieving host facts via SSH failed. Check with --debug for the root cause, unless you have done so already"
577578
fi
579+
580+
# disable debug output temporarily to prevent log spam
581+
set +x
582+
578583
# make facts available in script
579584
# shellcheck disable=SC2046
580585
export $(echo "$filteredFacts" | xargs)
581586

582587
# Necessary to prevent Bash erroring before printing out which fact had an issue
583588
set +u
584-
for var in isOs isArch isInstaller isContainer isRoot hasIpv6Only hasTar hasCpio hasSudo hasDoas hasWget hasCurl hasSetsid; do
589+
for var in isOs isArch isInstaller isContainer isRoot hasIpv6Only hasTar hasCpio hasSudo hasDoas hasWget hasCurl hasSetsid remoteHomeDir; do
585590
if [[ -z ${!var} ]]; then
586591
abort "Failed to retrieve fact $var from host"
587592
fi
588593
done
589594
set -u
590595

596+
# Compute the log file path from the home directory
597+
remoteLogFile="${remoteHomeDir}/.nixos-anywhere.log"
598+
599+
if [[ -n ${enableDebug} ]]; then
600+
set -x
601+
fi
602+
591603
if [[ ${isRoot} == "y" ]]; then
592604
maybeSudo=
593605
elif [[ ${hasSudo} == "y" ]]; then

0 commit comments

Comments
 (0)