#!/bin/sh

# check update xu4 - Ultima IV
if [ -f "/mnt/hd/user/xu4-v43.tar.gz" ]; then
	if [ -d "/mnt/hd/user/xu4" ]; then
 		echo "removing previous installation of xu4 - Ultima IV"
		rm -rf /mnt/hd/user/xu4/bin/*
		rmdir /mnt/hd/user/xu4/bin
	fi
 	echo "installing version of xu4 - Ultima IV for iStation V43"
 	cd /mnt/hd/user
	tar xzvf xu4-v43.tar.gz
	rm -f xu4-v43.tar.gz

	if [ ! -f "/mnt/hd/user/lib/libxml2.so.2.6.24" ]; then
 		echo "installing libxml2 for iStation V43"
		cp /mnt/hd/user/xu4/lib/libxml2.so.2.6.24 /mnt/hd/user/lib/libxml2.so.2.6.24
		ln -s /mnt/hd/user/lib/libxml2.so.2.6.24 /usr/lib/libxml2.so.2
		ln -s /usr/lib/libxml2.so.2 /usr/lib/libxml2.so
	fi
	rm -f /mnt/hd/user/xu4/lib/libxml2.so.2.6.24
	rmdir /mnt/hd/user/xu4/lib

fi

export HOME=/mnt/hd/user/xu4
cd /mnt/hd/user/xu4/bin
./u4 > /mnt/hd/user/xu4/bin/xu4.log
exit 65
