#!/bin/bash
#
# Cleanup Cloud Shell
# Remove previous installed Admin Tools
#

if [ "$OCI_CLI_CLOUD_SHELL" = "True" ]; then
	tool="setup-tools"
	resstr=`which "$tool" 2>/dev/null | sed 's|^no '$tool' in .*||'`
	if [ "$resstr" != "" ]; then
		setup-tools remove
	fi

	if [ -f "${HOME}/.bashrc.old" ] ; then
		mv -f "${HOME}/.bashrc.old" "${HOME}/.bashrc"
	fi
	
	for file in .admintools setup-tools.log; do
		if [ -f "${HOME}/$file" ]; then
			rm -f "${HOME}/$file"
		fi
	done
	
	for dir in .config/rclone .local/lib .local/share/templates .oci .packer.d .psm .terraform.d; do
		if [ -d "${HOME}/$dir" ]; then
			rm -fR "${HOME}/$dir"
		fi
	done
	
	mandb ${mantarget} >/dev/null 2>&1
else
	echo "No Cloud Shell - nothing to do."
fi

