#!/bin/sh
POSTURI="https://service.hr.nl/hr/aptupdate/post.php"

TMPFILE=$(mktemp)

hostname -f >>"$TMPFILE"
uname -r >>"$TMPFILE"

if [ -f /etc/debian_version ] ; then
	DIST='debian';
elif [ -f /etc/SuSE-release ] ; then
	DIST='suse';
fi
echo "$DIST" >>"$TMPFILE"

case "$DIST" in
	debian)
		VERSION=$(cat /etc/debian_version)
		;;
	suse)
		VERSION=$(grep -E "(VERSION|PATCHLEVEL) = " /etc/SuSE-release  |cut -f 3 -d " " |tr "\n" .|cut -f 1-2 -d .)
		;;
	*)
		VERSION="unknown"
		;;
esac
echo "$VERSION" >>"$TMPFILE"

case "$DIST" in
	debian)
		dpkg -l |grep ^ii >>"$TMPFILE"
		;;
	suse)
		/bin/rpm -qa --qf "%{NAME}\t%{VERSION}-%{RELEASE}\t%{INSTALLTIME}\t%{ARCH}\n" >>"$TMPFILE"
		;;
esac
wget --no-check-certificate --timeout=30 --tries=1 --post-file="$TMPFILE" -O - -q "$POSTURI"
rm "$TMPFILE"
exit 0
	
