#!/bin/bash
set -e

Action=$1

LIBDIR=/usr/lib/loongarch64-linux-gnu/gtgpu-gt6910

LDCONF=/etc/ld.so.conf.d/0-gtgpu.conf

ISGT=`lspci -d 1FF8:* -n |wc -l`

XORG_FILE=/usr/bin/Xorg



#clean /etc/ld.so.conf.d
function remove_ldconf() {
	if [ -f ${LDCONF} ];then
		rm -r ${LDCONF}
	fi
}

function update_ldconf() {
	if [ x${ISGT} != "x0" ] && [ -d "${LIBDIR}" ]; then
		echo ${LIBDIR} > ${LDCONF}
	else
		remove_ldconf
	fi
	ldconfig
}


case $Action in
	update)
		update_ldconf
		;;
	remove)
		remove_ldconf
		;;
	*)
		exit 0
		;;
esac

exit 0
