#!/usr/bin/env bash
[[ -t 1 ]] && { cG="\e[1;32m"; cR="\e[1;31m"; cB="\e[1;34m"; cW="\e[1;37m"; cY="\e[1;33m"; cG_="\e[0;32m"; cR_="\e[0;31m"; cB_="\e[0;34m"; cW_="\e[0;37m"; cY_="\e[0;33m"; cZ="\e[0m"; export cR cG cB cY cW cR_ cG_ cB_ cY_ cW_ cZ; }
for tool in dirname find readlink sha256sum install; do type $tool > /dev/null 2>&1 || { echo -e "${cR}ERROR:${cZ} couldn't find '$tool' which is required by this script."; exit 1; }; done
pushd $(dirname $0) > /dev/null; CURRABSPATH=$(readlink -nf "$(pwd)"); popd > /dev/null; # Get the directory in which the script resides
[[ -d "$CURRABSPATH/unstripped" ]] && SRCDIR="unstripped"
[[ -d "$CURRABSPATH/stripped" ]] && SRCDIR="stripped"
( cd "$SRCDIR"; set -x; sha256sum -c SHA256SUMS ) || { echo -e "${cR}ERROR:${cZ} failed to validate integrity of the binaries in $(pwd)."; exit 1; }
( set -x; sudo install -g root -o root -m 0755 -p -v -t /usr/local/bin $(find "$CURRABSPATH/$SRCDIR" -type f -executable -printf "$SRCDIR/%P\n") )
