#!/usr/bin/env bash
# Install Tunnels plug-ins into user-scope folders.
set -euo pipefail

src="$(cd "$(dirname "$0")" && pwd)"
vst3_dest="$HOME/.vst3"
clap_dest="$HOME/.clap"

[[ -d "$src/Tunnels.vst3" || -f "$src/Tunnels.clap" ]] || {
    echo "No Tunnels plug-ins found next to this script" >&2
    exit 1
}

if [[ -d "$src/Tunnels.vst3" ]]; then
    mkdir -p "$vst3_dest"
    rm -rf "$vst3_dest/Tunnels.vst3"
    cp -R "$src/Tunnels.vst3" "$vst3_dest/"
    echo "Installed $vst3_dest/Tunnels.vst3"
fi

if [[ -f "$src/Tunnels.clap" ]]; then
    mkdir -p "$clap_dest"
    rm -rf "$clap_dest/Tunnels.clap"
    cp "$src/Tunnels.clap" "$clap_dest/"
    echo "Installed $clap_dest/Tunnels.clap"
fi

echo "Done. Restart your DAW to scan."
