2011-05-20 17:46:59 +02:00
#!/bin/bash
2009-11-13 18:05:59 +01:00
ROOT_DIR = $( cd ` dirname $0 ` ; pwd )
2009-11-13 18:14:14 +01:00
LOCAL_CFG_DIR = $ROOT_DIR /config.local
2009-11-13 18:05:59 +01:00
# Import config
2009-11-13 18:14:14 +01:00
if [ ! -f $LOCAL_CFG_DIR /local.sh ]
2009-11-13 18:05:59 +01:00
then
echo "Error : You don't have create your own local.sh file in config.local directory. You could rely on the local.sh.example file to create your version."
exit 1
fi
2009-11-13 18:14:14 +01:00
source $LOCAL_CFG_DIR /local.sh
2009-11-13 18:05:59 +01:00
if [ ! -n " $EXPORT_DOC_DIR " ]
then
echo "The EXPORT_DOC_DIR variable is not define. Export doc is disabled."
exit 0
fi
2009-11-13 18:19:30 +01:00
if [ ! -d " $EXPORT_DOC_DIR " ]
then
echo " Error : Export directory $EXPORT_DOC_DIR does not exist ! "
exit 2
fi
2009-11-13 18:05:59 +01:00
DOC_DIR = $ROOT_DIR /doc
TMP_DIR = ` mktemp -d`
ERROR = 0
2009-11-13 18:14:14 +01:00
echo " -> Export documentation in $EXPORT_DOC_DIR : "
2009-11-13 18:05:59 +01:00
# PDF
if [ -n " $PDF " ]
then
echo -en "\t- PDF : "
# PDF
cp -f $DOC_DIR /exports/pdf/LdapSaisie.pdf $EXPORT_DOC_DIR /LdapSaisie.pdf
if [ $? -ne 0 ]
then
2009-11-13 18:47:28 +01:00
echo -e "\n-> Error"
2009-11-13 18:05:59 +01:00
ERROR = 1
else
echo Ok
fi
fi
# ALL-IN-ONE
if [ -n " $ALL_IN_ONE " ]
then
echo -en "\t- All-In-One : "
rm -fr $TMP_DIR /$ALL_IN_ONE
mkdir $TMP_DIR /$ALL_IN_ONE
cp $DOC_DIR /exports/html/all-in-one/LdapSaisie.html $TMP_DIR /$ALL_IN_ONE /
sed -i 's/\.\.\/\.\.\/\.\.\///g' $TMP_DIR /$ALL_IN_ONE /LdapSaisie.html
# IMAGES
cp -fr $IMAGES $TMP_DIR /$ALL_IN_ONE /images
mkdir $TMP_DIR /$ALL_IN_ONE /styles
cp $CSS $TMP_DIR /$ALL_IN_ONE /styles/
2009-11-13 18:14:14 +01:00
echo "done. Build archive and move it later ..."
2009-11-13 18:05:59 +01:00
fi
# ONLINE
if [ -n " $ONLINE " ]
then
echo -en "\t- On-line : "
rm -fr $TMP_DIR /$ONLINE
mkdir $TMP_DIR /$ONLINE
cp -fr $DOC_DIR /exports/html/online/*.html $TMP_DIR /$ONLINE
sed -i 's/\.\.\/\.\.\/\.\.\///g' $TMP_DIR /$ONLINE /*
# IMAGES
cp -fr $IMAGES $TMP_DIR /$ONLINE /images
mkdir $TMP_DIR /$ONLINE /styles
cp $CSS $TMP_DIR /$ONLINE /styles/
2009-11-13 18:14:14 +01:00
echo "done. Build archive and move it later ..."
2009-11-13 18:05:59 +01:00
fi
# DOCBOOK
if [ -n " $DOCBOOK " ]
then
echo -en "\t- Docbook : "
rm -fr $TMP_DIR /$DOCBOOK
mkdir $TMP_DIR /$DOCBOOK
cd $DOC_DIR
for i in ` find -type d| grep -v 'export' `
do
2009-11-13 18:47:28 +01:00
mkdir -p $TMP_DIR /$DOCBOOK /$i
2009-11-13 18:05:59 +01:00
done
2009-11-13 18:47:28 +01:00
for i in ` find -type f| egrep -v '(Makefile|^./export)' `
2009-11-13 18:05:59 +01:00
do
2009-11-13 18:47:28 +01:00
cp $i $TMP_DIR /$DOCBOOK /$i
2009-11-13 18:05:59 +01:00
done
2009-11-13 18:14:14 +01:00
echo "done. Build archive and move it later ..."
2009-11-13 18:05:59 +01:00
fi
2009-11-13 18:14:14 +01:00
echo "-> Build archives and move all in export directory :"
2009-11-13 18:05:59 +01:00
cd $TMP_DIR /
for i in $ALL_IN_ONE $ONLINE $DOCBOOK
do
echo -e " \t $i : "
echo -en "\t\t+ Archive : "
2009-11-13 18:47:28 +01:00
tar -cjf LdapSaisie--Doc--$i .tar.bz2 $i && mv LdapSaisie--Doc--$i .tar.bz2 $EXPORT_DOC_DIR /
2009-11-13 18:05:59 +01:00
if [ $? -eq 0 ]
then
echo Ok
else
2009-11-13 18:47:28 +01:00
echo -e "\n-> Error"
2009-11-13 18:05:59 +01:00
ERROR = 1
fi
echo -en "\t\t+ Web dir : "
2009-11-13 18:47:28 +01:00
[ ! -d " $EXPORT_DOC_DIR / $i " ] && echo " you must create export $i directory manualy before run this script. (path : $EXPORT_DOC_DIR / $i ) " && continue
rm -fr $EXPORT_DOC_DIR /$i /* && cp -fr $i /* $EXPORT_DOC_DIR /$i / && rm -fr $i
2009-11-13 18:05:59 +01:00
if [ $? -eq 0 ]
then
echo Ok
else
2009-11-13 18:47:28 +01:00
echo -e "\n-> Error"
2009-11-13 18:05:59 +01:00
ERROR = 1
fi
done
if [ -n " $LAST_UPDATE_FILE " ]
then
2009-11-13 18:14:14 +01:00
echo -n "-> Create last-update file : "
2009-11-13 18:05:59 +01:00
echo "Last update :" > $LAST_UPDATE_FILE
date >> $LAST_UPDATE_FILE
2010-04-21 11:50:30 +02:00
cd $ROOT_DIR
git log| head -n 1 >> $LAST_UPDATE_FILE
2009-11-13 18:05:59 +01:00
echo >> $LAST_UPDATE_FILE
echo done .
fi
rm -fr $TMP_DIR
2009-11-13 18:47:28 +01:00
exit $ERROR