#!/bin/sh

rm /root/plugin/uop.tar
{
 cd / &&
 gunzip /root/plugin/uop.tar.gz &&
 tar -xvf /root/plugin/uop.tar &&
 rm /root/plugin/uop.tar &&
 rm /root/plugin/var/bin/Install_UOP;
} &&
{
  /root/plugin/sed -i 's/Figure=[0-9]*/Figure=100/g' '/root/spark/etc/opera/opera_home/opera.ini';
  /root/plugin/sed -i "s/^STARTPAGE=.*$/STARTPAGE=\"http\:\/\/localhost\:8081\/\"/" "/root/spark/etc/opera/run-Portal";
  str="^/root/spark/etc/lighttpd/sbin/lighttpd -f /root/spark/etc/lighttpd/lighttpd.conf$";
  grep -q "$str" "/root/autorun.sh";
  if [ $? -ne 0 ] 
  then
    /root/plugin/sed -i "0,/^\#\/root\/spark\/etc\/lighttpd/s/^\#\/root\/spark\/etc\/lighttpd\/sbin\/lighttpd \-f \/root\/spark\/etc\/lighttpd\/lighttpd.conf$/\/root\/spark\/etc\/lighttpd\/sbin\/lighttpd \-f \/root\/spark\/etc\/lighttpd\/lighttpd.conf/g" /root/autorun.sh;
	/root/plugin/sed -i "0,/^\#\/root\/spark\/etc\/lighttpd/s/^\#\/root\/spark\/etc\/lighttpd\/sbin\/lighttpd \-f \/root\/spark\/etc\/lighttpd\/lighttpd.conf$/ifconfig lo up/g" /root/autorun.sh;
  fi
} &&
kill 1