#!/bin/sh
set -e

if [ "$1" = configure ]; then
	if command -v setcap > /dev/null; then
		if setcap cap_net_raw,cap_dac_read_search,cap_sys_ptrace+ep /usr/bin/deepin-system-monitor;then
			chmod u-s /usr/bin/deepin-system-monitor
		else
			echo "Setcap failed, falling back to setuid" >&2
			chmod u+s /usr/bin/deepin-system-monitor
		fi
	else
		echo "Setcap is not installed, falling back to setuid" >&2
		chmod u+s /usr/bin/deepin-system-monitor
	fi  
fi

exit 0
