summaryrefslogtreecommitdiffstats
path: root/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update
blob: 232e5eab55c89914da5a4ecedd495276c2a7ee4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/ash

[ -r "/run/system-uuid" ] || exit 0

. /opt/openslx/config
[ -z "$SLX_REMOTE_LOG" ] && exit 0

UUID=$(cat "/run/system-uuid")

[ -z "$UUID" ] && exit 1

USED=0

for SESSION in $(loginctl | awk '{print $1}'); do
	unset Display Remote State
	eval $(loginctl -p Display -p Remote -p State -p Class show-session "$SESSION")
	if [ -n "$Display" ] && [ "$Remote" = "no" ] && [ "$State" = "active" ] && [ "$Class" = "user" ]; then
		USED=1
		break;
	fi
done

curl -s --data-urlencode "type=~runstate" --data-urlencode "uuid=$UUID" --data-urlencode "used=$USED" \
	"$SLX_REMOTE_LOG" > /dev/null 2>&1