#!/bin/bash

if ! [ -n "$1" ]; then
  echo "Usage: $0 <directory>"
  exit
fi

if [ -e $1 ]; then
  echo $1 already exists.
  exit
fi

mkdir $1

source=$(cd $1; pwd)
target=$(pwd)

common_part=$source
back=
while [ "${target#$common_part}" = "${target}" ]; do
  common_part=$(dirname $common_part)
  back="../${back}"
done

cp presentation.tex $1/$(basename $1).tex

links="Makefile beamerthemelumc.sty logos"
cd $1
for i in $links; do
  ln -s ${back}${target#$common_part/}/${i}
done
