#!/bin/sh

# The uninstall process leaves behind an empty directory, let's clean that up

rm -rf /usr/local/natinst/atomiczynqk

if ! rm -rf /var/lib/compactrio; then
	echo "ERROR: Failed to remove the /var/lib/compactrio folder"
	exit -2
fi

# Clearing INI tokens. Previously located in the CDF under a MergeINI entry
if ! /usr/local/natinst/bin/nirtcfg --file /etc/natinst/share/ni-rt.ini --clear section="LVRT",token="ELVPingTimeout"; then
	echo "ERROR: Failed to execute /usr/local/natinst/bin/nirtcfg --file /etc/natinst/share/ni-rt.ini --clear section='LVRT',token='ELVPingTimeout'"
	exit -3
fi

if ! /usr/local/natinst/bin/nirtcfg --file /usr/local/natinst/share/NI-RIO/Plugins/atomiczynq.ini --clear section="EnumeratorPlugin",token="Path" --rm-if-empty; then
	echo "ERROR: Failed to execute /usr/local/natinst/bin/nirtcfg --file /usr/local/natinst/share/NI-RIO/Plugins/atomiczynq.ini --clear section='EnumeratorPlugin',token='Path' --rm-if-empty"
	exit -4
fi

if ! /usr/local/natinst/bin/nirtcfg --file /usr/local/natinst/share/NI-RIO/Plugins/atomiczynq.ini --clear section="EnumeratorPlugin",token="Path64" --rm-if-empty; then
	echo "ERROR: Failed to execute /usr/local/natinst/bin/nirtcfg --file /usr/local/natinst/share/NI-RIO/Plugins/atomiczynq.ini --clear section='EnumeratorPlugin',token='Path64' --rm-if-empty"
	exit -5
fi

