if ! [ -e emerald-0.99-linux.tar.gz ]; then
	wget http://www.uio.no/studier/emner/matnat/ifi/INF5510/v15/emerald-0.99-linux.tar.gz
	tar xvf emerald-0.99-linux.tar.gz
	mv emerald-0.99-linux emerald
fi
if ! [ -e emerald ]; then
	echo "Oh noes, no 'emerald' even though the tar.gz exists"
	exit 1
fi

sudo dnf -y install glibc.i686

if ! [ -e bind_public.so ]; then
	wget https://www.uio.no/studier/emner/matnat/ifi/IN5570/v19/bind_public.so
fi

touch .profile
if [ -e .profile.bak ]; then
	cp .profile.bak .profile
else
	cp .profile .profile.bak
fi

cat >> .profile <<EOF
export EMERALDROOT=`pwd`/emerald
export EMERALDARCH='i686mt'
export PATH="\$EMERALDROOT/bin:\$PATH"

export TERM=xterm-256color

alias emx32="LD_PRELOAD=~/bind_public.so emx"
alias ec32="LD_PRELOAD=~/bind_public.so ec"

EOF

echo "OK! Now run 'source ~/.profile'"
