Skip to content

Commit 71c8d9e

Browse files
committedOct 18, 2024··
use different loginctl flags depending on version
1 parent 2cf3ce4 commit 71c8d9e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎packaging/linux/postinstall

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ ensure_line "nav/NAV_Sub_CA.crt" "/etc/ca-certificates.conf"
1818

1919
update-ca-certificates
2020

21-
# Assert just _one_ logged-in user
22-
user_accounts=$(loginctl list-users -j | jq '[.[] | select(.uid >= 1000)]')
21+
systemd_version="$(systemctl --version | head -n 1 | grep -o '[0-9]+' | head -n 1)"
22+
if [[ $systemd_version -gt 255 ]]; then
23+
user_accounts=$(loginctl list-users -j | jq '[.[] | select(.uid >= 1000)]')
24+
else
25+
user_accounts=$(loginctl list-users --output json | jq '[.[] | select(.uid >= 1000)]')
26+
fi
27+
echo $user_accounts
28+
2329
if echo "$user_accounts" | jq -e 'length != 1' >/dev/null; then
2430
printf "\nMore than 1 user account logged in! naisdevice only permits _one_ user account!\n"
2531
exit 1

0 commit comments

Comments
 (0)
Please sign in to comment.