#!/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
}

rm -rf ~/scratch2
git clone https://github.com/Botspot/scratch2 || error "Failed to clone repository!"

echo "Copying libpepflashplayer.so to /usr/lib/chromium-browser..."
sudo cp -af ~/scratch2/libpepflashplayer.so /usr/lib/chromium-browser/libpepflashplayer.so || error "Failed to copy libpepflashplayer.so"

echo "Installing scratch2 package..."
sudo apt install -yf ~/scratch2/scratch2_0.25_armhf.deb || error "Failed to install scratch2 package"

rm -rf ~/scratch2
