#!/bin/bash

if [ ! -e vfu/vfu ]; then
  echo "vfu/vfu cannot be found, try to build it first..."
  exit;
fi

# this is not completely correct, it should check for all rx_* tools
if [ ! -e rx/rx_auto ]; then
  echo "rx/rx_* cannot be found, check distribution/docs..."
  exit;
fi

echo "Press ENTER to install vfu in /usr/local/bin and rx_* in /usr/libexec/vfu"
echo "Or press Ctrl+C to cancel"
read

cp vfu/vfu /usr/local/bin
mkdir /usr/libexec/vfu
cp rx/rx_* /usr/libexec/vfu

cp vfu.1 /usr/local/man/man1

cp vfu.conf /usr/libexec/vfu

cd /usr/local/bin
chmod 755 vfu

cd /usr/libexec/vfu
chmod 755 rx_*

echo "done."

