Skip to content

Commit 5b58cc2

Browse files
authored
Merge pull request #697 from github/djdefi-os-release
Use os-release for host info
2 parents 4b477a6 + 44a59b5 commit 5b58cc2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

bin/ghe-backup

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,11 @@ fi
231231

232232
# Output system information of the backup host
233233

234-
# If /etc/issue.net exists, use it to get the OS version
235-
if [ -f /etc/issue.net ]; then
236-
echo "Running on: $(cat /etc/issue.net)"
234+
# If /etc/os-release exists, use it to get the OS version
235+
if [ -f /etc/os-release ]; then
236+
OS_NAME=$(grep '^NAME' /etc/os-release | cut -d'"' -f2)
237+
VERSION_ID=$(grep '^VERSION_ID' /etc/os-release | cut -d'"' -f2)
238+
echo "Running on: $OS_NAME $VERSION_ID"
237239
else
238240
echo "Running on: Unknown OS"
239241
fi

test/test-ghe-backup.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,9 @@ begin_test "ghe-backup collects information on system where backup-utils is inst
10681068
set -e
10691069

10701070
output=$(ghe-backup)
1071-
echo "$output" | grep "Running on: $(cat /etc/issue.net)"
1071+
OS_NAME=$(grep '^NAME' /etc/os-release | cut -d'"' -f2)
1072+
VERSION_ID=$(grep '^VERSION_ID' /etc/os-release | cut -d'"' -f2)
1073+
echo "$output" | grep "Running on: $OS_NAME $VERSION_ID"
10721074
echo "$output" | grep "CPUs: $(nproc)"
10731075
echo "$output" | grep "Memory total/used/free+share/buff/cache:"
10741076

@@ -1088,4 +1090,4 @@ begin_test "ghe-backup manages progress tracking files properly"
10881090
echo "$output" | grep -v "mkdir: cannot create directory /tmp/backup-utils-progress: File exists"
10891091

10901092
)
1091-
end_test
1093+
end_test

0 commit comments

Comments
 (0)