#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"

function error {
  echo -e "\\e[91m$1\\e[39m"
  exit 1
}

if [ ! -z "$(file "$(readlink -f "/sbin/init")" | grep 64)" ];then
  #COMMANDS TO UNINSTALL 64BIT
  "${DIRECTORY}/purge-installed" "$(dirname "$0")" || exit 1
  
elif [ ! -z "$(file "$(readlink -f "/sbin/init")" | grep 32)" ];then
  #COMMANDS TO UNINSTALL 32BIT
  sudo apt purge remarkable -y || error "Failed to purge remarkable package!"
  sudo apt autoremove -y
  
else
  error "Failed to detect OS CPU architecture! Something is very wrong."
fi
