#!/bin/bash


# We're going to run this in the MacTeXDVD working directory...
WORK=`pwd`

echo "Removing old file tree at ${WORK}/root"
rm -rf ${WORK}/root

mkdir -p ${WORK}/root
echo "Changing permissions"
chmod -R a+r ${WORK}/root



# Ensure target directories we need for applications are present
mkdir -p ${WORK}/root/Applications/TeX
chmod 775 ${WORK}/root/Applications
chmod 755 ${WORK}/root
chmod 775 ${WORK}/root/Applications/TeX
chgrp admin ${WORK}/root/Applications
chgrp wheel ${WORK}/root
chgrp admin ${WORK}/root/Applications/TeX


# Get  TeXShop
echo "Getting TeXShop"
ditto ${WORK}/apps/"TeXShop.app" ${WORK}/root/Applications/TeX/"TeXShop.app"

# Get  LaTeXiT
echo "Getting LaTeXiT"
ditto ${WORK}/apps/"LaTeXiT.app" ${WORK}/root/Applications/TeX/"LaTeXiT.app"

# Get BibDesk
echo "Getting BibDesk"
ditto ${WORK}/apps/"BibDesk.app" ${WORK}/root/Applications/TeX/"BibDesk.app"

# Get TeX Live Utility
echo "Getting TeX Live Utility"
ditto ${WORK}/apps/"TeX Live Utility.app" ${WORK}/root/Applications/TeX/"TeX Live Utility.app"

# Get Doc and Spelling
echo "Getting Docs and Spell Utilities"
ditto ${WORK}/apps/"Docs and Spell Utilities"/ ${WORK}/root/Applications/TeX/"Docs and Spell Utilities"/

 
 # Changing Groups
 chgrp -R admin ${WORK}/root/Applications/TeX/*


