#/bin/sh
REINSTALL=0
if [ $# -eq 1 ] ; then
  #Fedora runs prerm after postinst - reinstall(1), remove(0)
  #Debian in newer versions sometimes has param remove
  if [ "$1" = "1" ] ; then
    REINSTALL=1
  fi
fi

if [ -e /bin/wslinfo ] ; then
  echo "Service Removed... (SystemV-WSL)"
else
  if [ -e /bin/systemctl ] ; then
    if [ $REINSTALL -eq 1 ] ; then
      echo "Service Reinstall... (SystemD)"
    else
      systemctl disable hardinfo2
      echo "Service Removed... (SystemD)"
    fi
  elif [ -e /sbin/chkconfig ] ; then
    chkconfig hardinfo2 off
    chkconfig --del hardinfo2
    echo "Service Removed... (SystemV)"
  else
    update-rc.d hardinfo2 remove
    echo "Service Removed... (SystemV-rc)"
  fi
fi
