summaryrefslogtreecommitdiffstats
path: root/remote/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update
blob: 9ab77f4f4b486fd23993f924da56cd5ae5e8cfeb (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" -o "$State" = "online" ] && [ "$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