#!/bin/bash

echo "starting installation process"
if [ "$EUID" -ne 0 ]; then
    echo "please run this script as root: sudo ./install.sh"
    exit 1
fi

echo "installing dependecies"
apt-get update
apt-get install -y libqt6core6 libqt6gui6 libqt6widgets6 libgl1

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

echo "copying files to /usr/local/bin"
if [ -f "$DIR/calc" ] && [ -f "$DIR/stddev" ]; then
    cp "$DIR/calc" /usr/local/bin/xsogorcalc
    cp "$DIR/stddev" /usr/local/bin/xsogorstddev

    chmod +x /usr/local/bin/xsogorcalc
    chmod +x /usr/local/bin/xsogorstddev

    echo "installation complete"
    echo "for the calculator, run: xsogorcalc"
    echo "for the profiler, run: xsogorstddev"
else
    echo "error: calc and stddev binaries not found in the current directory"
    exit 1
fi