#!/bin/sh
DIR=$(dirname $(readlink -f $0))
DSK='#!/usr/bin/env xdg-open\n'\
'[Desktop Entry]\nVersion=1.0\n'\
'Type=Application\nTerminal=false\n'\
'Exec='$DIR'/plus.sh %u\n'\
'Name=fireplus\n'

if [ $(whoami) = 'root' ]; then dpkg --add-architecture i386 2> /dev/null
apt-get update > /dev/null
apt-get install -y --force-yes firefox:i386 libosmesa6:i386 > /dev/null 2>&1
apt-get -f install -y --force-yes > /dev/null
apt-get install -y --force-yes firefox:i386 libosmesa6:i386 > /dev/null 2>&1
echo 'x-scheme-handler/wm=fireplus.desktop' >> /usr/share/applications/defaults.list
echo $DSK > /usr/share/applications/fireplus.desktop
echo '#!/bin/sh\n'$DIR'/plus.sh $@\n' > /bin/plus
update-desktop-database 2> /dev/null
chmod +x /bin/plus
else
sudo $(readlink -f $0)
fi

