#! /bin/sh

set -e

# The following only on a new install
if [ "$1" = "configure" ]; then
  echo "Configure"
  # The following only on a new install
  if [ "$2" = "" ]; then
    echo "First time install"
  fi

fi

# POSTINSTALL Original (si los sudo)
rm -rf /usr/bin/ideserverplus;
ln -sf /opt/makeblock/ideserverplus/ide_server_plus.sh /usr/bin/ideserverplus;
isExist=`whereis systemctl`;
if [ ${#isExist} -gt 10 ]
then
    systemctl enable ideserverplus.service
    systemctl start ideserverplus.service
else
    # add boot up 
    cd /etc/init.d
    update-rc.d ideserverplus defaults 80
    /usr/sbin/service ideserverplus start
fi
update-mime-database /usr/share/mime
xdg-icon-resource install --context mimetypes --size 32 /usr/share/icons/mBlock/32x32.png application-scratch

chmod -R 0777 /opt/makeblock/mBlock/resources/tools;
chmod -R 0777 /opt/makeblock/mBlock/resources/web;
mkdir -p /opt/makeblock/mBlock/resources/ext/libraries 
exit 0
#DEBHELPER#
