i dont think there is a snap command to get the managed state (there is "snap known system-user" but that seems to only work if the user was actually created with an assertion)
if you actually want shell instead of a simple python http query:
root@pi4:~# cat is-managed.sh #! /bin/sh
query_snapd() { RET="$(/bin/echo -e 'GET /v2/'"$1"' HTTP/1.0\r\n\r\n' | \ nc -U /var/run/snapd.socket -q0 2>&1 | \ grep -oP '(^.*"'"$2"'":)[^,]*' | \ grep -o '[^:]*$')" echo "$RET" | sed 's/\]//g;s/\}//g;s/\"//g' }
echo "System is managed: $(query_snapd system-info managed)" echo "By user: $(query_snapd users email)" root@pi4:~# ./is-managed.sh System is managed: true By user: <email address hidden>
i dont think there is a snap command to get the managed state (there is "snap known system-user" but that seems to only work if the user was actually created with an assertion)
if you actually want shell instead of a simple python http query:
root@pi4:~# cat is-managed.sh
#! /bin/sh
query_snapd() { snapd.socket -q0 2>&1 | \ "$2"'": )[^,]*' | \ g;s/\}/ /g;s/\" //g'
RET="$(/bin/echo -e 'GET /v2/'"$1"' HTTP/1.0\r\n\r\n' | \
nc -U /var/run/
grep -oP '(^.*"'
grep -o '[^:]*$')"
echo "$RET" | sed 's/\]//
}
echo "System is managed: $(query_snapd system-info managed)"
echo "By user: $(query_snapd users email)"
root@pi4:~# ./is-managed.sh
System is managed: true
By user: <email address hidden>