Compare commits
2 Commits
f4b54637aa
...
c3ae959887
Author | SHA1 | Date | |
---|---|---|---|
c3ae959887 | |||
8d51a85454 |
63
run.sh
63
run.sh
@ -5,52 +5,27 @@ NULLPREFIX=" "
|
|||||||
|
|
||||||
echo -e "$ECHOPREFIX Hello, this is \033[31mtexbox\033[0m"
|
echo -e "$ECHOPREFIX Hello, this is \033[31mtexbox\033[0m"
|
||||||
|
|
||||||
if test "$(ls -A /tex)"; then
|
if ! test "$(ls -A /tex)"; then
|
||||||
# Directory not empty - user mounted directory \o/
|
|
||||||
if [ -z "$TARGET" ]; then
|
|
||||||
# target unset.
|
|
||||||
TARGET="*.tex"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build in build dir
|
|
||||||
BUILD=build-$(date | sha256sum | cut -f1 -d' ')
|
|
||||||
mkdir $BUILD
|
|
||||||
cd $BUILD
|
|
||||||
|
|
||||||
echo "$ECHOPREFIX Targetting $TARGET"
|
|
||||||
|
|
||||||
# Build the PDF
|
|
||||||
texi2pdf ../$TARGET
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
if [ "$?" -eq "0" ]; then
|
|
||||||
echo "$ECHOPREFIX Created the PDF!"
|
|
||||||
echo "$NULLPREFIX Here are the results:"
|
|
||||||
ls $BUILD/*.pdf
|
|
||||||
rm ./last-successful 2>/dev/null
|
|
||||||
ln -sf $BUILD ./last-successful
|
|
||||||
else
|
|
||||||
echo "$ECHOPREFIX Build failed."
|
|
||||||
echo "$NULLPREFIX Have a look at the logs:"
|
|
||||||
ls $BUILD/*.log
|
|
||||||
rm ./last-failed 2>/dev/null
|
|
||||||
ln -sf $BUILD ./last-failed
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Delete old symlink
|
|
||||||
rm ./current-build 2>/dev/null
|
|
||||||
|
|
||||||
# Set 'current' symlink
|
|
||||||
ln -sf $BUILD ./current-build
|
|
||||||
|
|
||||||
# Apply the access rights to build folder as found on the target file
|
|
||||||
chmod --reference=$TARGET -R $BUILD ./current-build ./last-successful ./last-failed
|
|
||||||
chmod +x $BUILD
|
|
||||||
chown --reference=$TARGET -R $BUILD ./current-build ./last-successful ./last-failed
|
|
||||||
else
|
|
||||||
# Directory is empty
|
# Directory is empty
|
||||||
echo "$ECHOPREFIX Please mount your directory to /tex"
|
echo "$ECHOPREFIX Please mount your directory to /tex"
|
||||||
echo "$NULLPREFIX See you soon."
|
echo "$NULLPREFIX See you soon."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Directory not empty - user mounted directory \o/
|
||||||
|
if [ -z "$TARGET" ]; then
|
||||||
|
# target unset.
|
||||||
|
TARGET="$(find /tex -iname '*.tex' | head --lines 1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build in build dir
|
||||||
|
BUILD="$(mktemp --directory)"
|
||||||
|
cd "$BUILD"
|
||||||
|
|
||||||
|
echo "$ECHOPREFIX Targetting $TARGET"
|
||||||
|
|
||||||
|
# Build the PDF
|
||||||
|
texi2pdf $TARGET
|
||||||
|
|
||||||
|
# Relocate resulting PDF
|
||||||
|
find "$BUILD" -iname "*.pdf" -exec chmod --silent --reference=$TARGET {} \; -exec chown --silent --reference=$TARGET -R $BUILD {} \; -exec mv {} /tex \;
|
||||||
|
Loading…
Reference in New Issue
Block a user