#!/bin/env sh

SCRIPTPATH="$(
  cd -- "$(dirname "$0")" >/dev/null 2>&1
  pwd -P
)"
EXECUTORS_PATH="$SCRIPTPATH/executors"

export TARGET_MODE=$1

echo "=> Setup ${TARGET_MODE}..."

while IFS= read -r file; do
  if [[ -x "$file" && ! "$file" =~ "##" && ! "$file" =~ ~$ && ! "$file" =~ ".bak" ]]; then
    $file
  fi
done < <(find -L "$EXECUTORS_PATH" -type f | sort)
