Corrected exit statuses in chertex.sh to zero for success and one otherwise.

master
Taha Ahmed 9 years ago
parent 97e446e480
commit 1e6ce316f1

1
.gitignore vendored

@ -5,3 +5,4 @@ PlotDigitizer.jar
jpeglib.h jpeglib.h
nbconvert/ nbconvert/
sketch/ sketch/
nohup.out

@ -5,15 +5,15 @@
#################################################### ####################################################
# For now, MAKE SURE that the argument consists of # For now, MAKE SURE that the argument consists of
# a complete filename, with extension, and # a complete filename, with extension, and
# in the directory of the Rnw file # in the directory of the Rnw file
#################################################### ####################################################
clear clear
echo "-----------------------------------------------------------------------" echo "-----------------------------------------------------------------------"
echo "cheRTeX -- a script for processing R--Sweave/knitr--LaTeX/TikZ projects" echo "cheRTeX -- a script for processing R--Sweave/knitr--LaTeX/TikZ projects"
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo "MMXIV -- taha.ahmed@kemi.uu.se -- CHEPEC doctoral degree project" echo "MMXVI -- taha@chepec.se -- CHEPEC doctoral degree project"
echo "-----------------------------------------------------------------------" echo "-----------------------------------------------------------------------"
## If the file .latexmkrc exists in the current directory, ## If the file .latexmkrc exists in the current directory,
@ -59,28 +59,28 @@ if [ $# -eq 1 ]; then
fi fi
# Introducing a short delay to enable on-screen reading of previous echo # Introducing a short delay to enable on-screen reading of previous echo
/home/taha/chepec/chetex/common/bash/simpledelay.sh 2 simpledelay.sh 2
echo "Delay completed" echo "Delay completed"
#### Special treatment for sample-matrix.Rnw #### Special treatment for sample-matrix.Rnw
# If $jobname is sample-matrix, restart Shiny and term this script # If $jobname is sample-matrix, restart Shiny and term this script
if [[ $jobname == "sample-matrix" ]]; then if [[ $jobname == "sample-matrix" ]]; then
echo "<cheRTeX> -------------------------------" echo "<cheRTeX> -------------------------------"
echo "<cheRTeX> sample-matrix: restarting Shiny" echo "<cheRTeX> sample-matrix: restarting Shiny"
echo "<cheRTeX> -------------------------------" echo "<cheRTeX> -------------------------------"
# kill Shiny # kill Shiny
pkill -f "shiny::runApp" pkill -f "shiny::runApp"
# start Shiny # start Shiny
bash -c "/home/taha/chepec/chetex/common/bash/shiny-matrix.sh" & bash -c "/home/taha/chepec/chetex/common/bash/shiny-matrix.sh" &
# terminate this script # terminate this script
echo "<cheRTeX> Terminating..." echo "<cheRTeX> Terminating..."
/home/taha/chepec/chetex/common/bash/simpledelay.sh 4 simpledelay.sh 4
exit 1 exit 0
fi fi
## Handle knitr or pgfSweave jobs (each requires separate treatment) ## Handle knitr or pgfSweave jobs (each requires separate treatment)
## But how should we tell the difference between them? ## But how should we tell the difference between them?
## There is no obvious way to tell the difference (apart from reading the *.Rnw file) ## There is no obvious way to tell the difference (apart from reading the *.Rnw file)
@ -92,51 +92,51 @@ if [ $# -eq 1 ]; then
# Run knitr commands for this job # Run knitr commands for this job
echo "<cheRTeX> -----------------------" echo "<cheRTeX> -----------------------"
echo "<cheRTeX> This is a job for knitr" echo "<cheRTeX> This is a job for knitr"
echo "<cheRTeX> -----------------------" echo "<cheRTeX> -----------------------"
# Knit # Knit
echo "<cheRTeX> Knitting..." echo "<cheRTeX> Knitting..."
Rscript -e "library(knitr); library(methods); knit('$jobname.$jobfiletype')" Rscript -e "library(knitr); library(methods); knit('$jobname.$jobfiletype')"
# Introduce delay to give time to read Rscript exit status # Introduce delay to give time to read Rscript exit status
echo "<cheRTeX> -----------------------" echo "<cheRTeX> -----------------------"
echo "<cheRTeX> Rscript knitr completed" echo "<cheRTeX> Rscript knitr completed"
echo "<cheRTeX> -----------------------" echo "<cheRTeX> -----------------------"
/home/taha/chepec/chetex/common/bash/simpledelay.sh 4 simpledelay.sh 4
else else
# Run pgfSweave commands # Run pgfSweave commands
echo "<cheRTeX> ---------------------------" echo "<cheRTeX> ---------------------------"
echo "<cheRTeX> This is a job for pgfSweave" echo "<cheRTeX> This is a job for pgfSweave"
echo "<cheRTeX> ---------------------------" echo "<cheRTeX> ---------------------------"
# Tangle # Tangle
echo "<cheRTeX> Tangling..." echo "<cheRTeX> Tangling..."
R CMD Stangle $jobname.$jobfiletype R CMD Stangle $jobname.$jobfiletype
# Weave # Weave
echo "<cheRTeX> Weaving..." echo "<cheRTeX> Weaving..."
R CMD pgfsweave --graphics-only $jobname.$jobfiletype R CMD pgfsweave --graphics-only $jobname.$jobfiletype
# Introduce delay to give time to read R CMD exit status # Introduce delay to give time to read R CMD exit status
echo "<cheRTeX> -------------------------" echo "<cheRTeX> -------------------------"
echo "<cheRTeX> R CMD pgfsweave completed" echo "<cheRTeX> R CMD pgfsweave completed"
echo "<cheRTeX> -------------------------" echo "<cheRTeX> -------------------------"
/home/taha/chepec/chetex/common/bash/simpledelay.sh 4 simpledelay.sh 4
fi fi
# Run vc script if vc exists in working directory # Run vc script if vc exists in working directory
echo "<cheRTeX> Running vc script" echo "<cheRTeX> Running vc script"
if [ -f vc ]; then if [ -f vc ]; then
./vc ./vc
fi fi
# Run pdflatex, bibtex, and company # Run pdflatex, bibtex, and company
if $ltxmkrc; then if $ltxmkrc; then
echo "<cheRTeX> Calling LaTeXMK with RC file" echo "<cheRTeX> Calling LaTeXMK with RC file"
/home/taha/chepec/chetex/common/bash/simpledelay.sh 2 simpledelay.sh 2
latexmk -r .latexmkrc -pdf -bibtex $jobname latexmk -r .latexmkrc -pdf -bibtex $jobname
else else
echo "<cheRTeX> Calling LaTeXMK" echo "<cheRTeX> Calling LaTeXMK"
/home/taha/chepec/chetex/common/bash/simpledelay.sh 2 simpledelay.sh 2
latexmk -pdf -bibtex $jobname latexmk -pdf -bibtex $jobname
fi fi
@ -150,7 +150,7 @@ else
echo "<3> 'wipe-dir' -- Remove all non-essential files and subdirectories" echo "<3> 'wipe-dir' -- Remove all non-essential files and subdirectories"
echo "Any other input exits the program" echo "Any other input exits the program"
read usrchoice read usrchoice
## Determine number of .Rnw files in current directory ## Determine number of .Rnw files in current directory
#Rnwfileno=$(ls -1 $Rnwfiles | wc -l) #Rnwfileno=$(ls -1 $Rnwfiles | wc -l)
#echo "No of .Rnw files: $Rnwfileno" #echo "No of .Rnw files: $Rnwfileno"
@ -158,7 +158,7 @@ else
## Check if number of .Rnw files larger than one ## Check if number of .Rnw files larger than one
#if [ $Rnwfileno -gt 1 ]; then #if [ $Rnwfileno -gt 1 ]; then
# # If larger than one, ask for user input # # If larger than one, ask for user input
# # Indicates more than one Rnw file in current directory. # # Indicates more than one Rnw file in current directory.
# # This introduces a naming ambiguity. # # This introduces a naming ambiguity.
# # Resolve by asking user for current jobname # # Resolve by asking user for current jobname
# echo "Found $Rnwfileno .Rnw files in current directory" # echo "Found $Rnwfileno .Rnw files in current directory"
@ -177,17 +177,17 @@ else
#fi #fi
# #
#echo "Jobname set to: $jobname" #echo "Jobname set to: $jobname"
if [[ $usrchoice == "pdf-all" || $usrchoice == "1" ]]; then if [[ $usrchoice == "pdf-all" || $usrchoice == "1" ]]; then
echo "<1> 'pdf-all' chosen" echo "<1> 'pdf-all' chosen"
# This for loop ONLY USED to determine number of *.tikz files in directory # This for loop ONLY USED to determine number of *.tikz files in directory
for tikzfiles in "$tikzfiles"; do tikzfilenumber=${#tikzfiles}; done for tikzfiles in "$tikzfiles"; do tikzfilenumber=${#tikzfiles}; done
echo "cheRTeX detected $tikzfilenumber TikZ files for processing" echo "cheRTeX detected $tikzfilenumber TikZ files for processing"
echo "Starting TikZ file processing..." echo "Starting TikZ file processing..."
/home/taha/chepec/chetex/common/bash/simpledelay.sh 2 simpledelay.sh 2
for tikzfilename in $tikzfiles; do for tikzfilename in $tikzfiles; do
# Call tikz2pdf # Call tikz2pdf
echo "<Executing> tikz2pdf $tikzfilename" echo "<Executing> tikz2pdf $tikzfilename"
tikz2pdf --once $tikzfilename tikz2pdf --once $tikzfilename
done done
@ -199,7 +199,7 @@ else
rm $auxfiles rm $auxfiles
# Still, a rather crude way of cleaning up... # Still, a rather crude way of cleaning up...
fi fi
if [[ $usrchoice == "wipe-dir" || $usrchoice == "3" ]]; then if [[ $usrchoice == "wipe-dir" || $usrchoice == "3" ]]; then
echo "<3> 'wipe-dir' chosen" echo "<3> 'wipe-dir' chosen"
## Remove all but non-essential files ## Remove all but non-essential files
@ -226,38 +226,38 @@ else
## The use of conditionals is mainly to avoid annoying "file does not exist" messages... ## The use of conditionals is mainly to avoid annoying "file does not exist" messages...
# Return *.Rproj file (removal is unnecessary and makes RStudio less useful) # Return *.Rproj file (removal is unnecessary and makes RStudio less useful)
Rprojfiles=`ls -1 /home/taha/chepec/tmp/$tmpdirname/*.Rproj 2>/dev/null | wc -l` Rprojfiles=`ls -1 /home/taha/chepec/tmp/$tmpdirname/*.Rproj 2>/dev/null | wc -l`
if [ $Rprojfiles != 0 ]; then if [ $Rprojfiles != 0 ]; then
cp /home/taha/chepec/tmp/$tmpdirname/*.Rproj . cp /home/taha/chepec/tmp/$tmpdirname/*.Rproj .
fi fi
# Return *.rda files (considering peak-data files, which "cost" a lot to create) # Return *.rda files (considering peak-data files, which "cost" a lot to create)
rdafiles=`ls -1 /home/taha/chepec/tmp/$tmpdirname/*.rda 2>/dev/null | wc -l` rdafiles=`ls -1 /home/taha/chepec/tmp/$tmpdirname/*.rda 2>/dev/null | wc -l`
if [ $rdafiles != 0 ]; then if [ $rdafiles != 0 ]; then
cp /home/taha/chepec/tmp/$tmpdirname/*.rda . cp /home/taha/chepec/tmp/$tmpdirname/*.rda .
fi fi
# Return *.Rmd files (R markdown source files) # Return *.Rmd files (R markdown source files)
Rmdfiles=`ls -1 /home/taha/chepec/tmp/$tmpdirname/*.Rmd 2>/dev/null | wc -l` Rmdfiles=`ls -1 /home/taha/chepec/tmp/$tmpdirname/*.Rmd 2>/dev/null | wc -l`
if [ $Rmdfiles != 0 ]; then if [ $Rmdfiles != 0 ]; then
cp /home/taha/chepec/tmp/$tmpdirname/*.Rmd . cp /home/taha/chepec/tmp/$tmpdirname/*.Rmd .
fi fi
# Return *.css files (css files) [for sample-matrix] # Return *.css files (css files) [for sample-matrix]
cssfiles=`ls -1 /home/taha/chepec/tmp/$tmpdirname/*.css 2>/dev/null | wc -l` cssfiles=`ls -1 /home/taha/chepec/tmp/$tmpdirname/*.css 2>/dev/null | wc -l`
if [ $cssfiles != 0 ]; then if [ $cssfiles != 0 ]; then
cp /home/taha/chepec/tmp/$tmpdirname/*.css . cp /home/taha/chepec/tmp/$tmpdirname/*.css .
fi fi
# Return .knitme file [empty file used to indicate knitr jobs] # Return .knitme file [empty file used to indicate knitr jobs]
knitmefile=`ls -1 /home/taha/chepec/tmp/$tmpdirname/.knitme 2>/dev/null | wc -l` knitmefile=`ls -1 /home/taha/chepec/tmp/$tmpdirname/.knitme 2>/dev/null | wc -l`
if [ $knitmefile != 0 ]; then if [ $knitmefile != 0 ]; then
cp /home/taha/chepec/tmp/$tmpdirname/.knitme . cp /home/taha/chepec/tmp/$tmpdirname/.knitme .
fi fi
fi fi
echo "Terminating..." echo "Terminating..."
exit 1 exit 0
fi fi
## Here is the wild land of more than one *.Rnw file in current directory ## Here is the wild land of more than one *.Rnw file in current directory
echo "<cheRTeX> This script can be run with one argument is process mode," echo "<cheRTeX> This script can be run with one argument is process mode,"
echo "<cheRTeX> or with zero arguments in post-processing mode." echo "<cheRTeX> or with zero arguments in post-processing mode."
echo "<cheRTeX> Terminating..." echo "<cheRTeX> Terminating..."
@ -266,9 +266,9 @@ fi
echo "------------------------------------" echo "------------------------------------"
echo "=== sample-matrix.sh completed ===" echo "=== chertex.sh completed ==="
echo "=== $(date) ===" echo "=== $(date) ==="
echo "------------------------------------" echo "------------------------------------"
/home/taha/chepec/chetex/common/bash/simpledelay.sh 10 simpledelay.sh 10
exit 1 exit 0

@ -3,16 +3,19 @@
## Written Oct 12, 2013 ## Written Oct 12, 2013
## Taha Ahmed ## Taha Ahmed
a="https://mail.google.com" # a="https://mail.google.com"
b="https://rememberthemilk.com" b="https://www.rememberthemilk.com"
c="https://chepec.timetask.com" c="https://asks.timetask.com"
d="https://keep.google.com/keep/" d="https://keep.google.com/keep/"
e="https://luxor.chepec.se/tagspaces/"
f="https://shiny.chepec.se"
# open shiny sample-matrix # start the local http server for serving PDF reports (used in Shiny sample matrix)
# find current port number by reading shiny.port file cd /home/taha/chepec
PORT=$(</home/taha/chepec/chetex/sample-matrix/shinyapp/shiny.port) # server runs on port 8000 (default) in the working directory
s="http://localhost:$PORT" python /home/taha/chepec/chetex/common/bash/shiny-python-localhost.py &
google-chrome $a $b $c $d $s # start Chrome
google-chrome $b $c $d $e $f
exit 1 exit 1

@ -1,115 +0,0 @@
#!/bin/bash
function show_help {
echo "Usage: jekyll-chepec.sh [OPTION]..."
echo "Update, sync and rebuild jekyll blog on damietta"
echo ""
echo "Give no arguments at all to make this script run everything"
echo "-c convert *.Rmd files in _knitr/ to *.md files in _posts/"
echo "-o overwrite existing *.md files if necessary"
echo "-s sync the jekyll directories locally and on damietta"
echo "-b build the live jekyll site on damietta"
echo "-h show this help"
}
# Three cases:
# 1. convert new/existing *.Rmd to *.md, with option to overwrite existing *.md
# 2. sync the jekyll website directory (for that, we use unison)
# 3. build the site (on the server)
# Note that the actions must be done in order, so if the user chooses case 2., 1. is executed first, then 2.
# Likewise, if the user chooses case 3., 1. and 2. are executed first.
# A POSIX variable
# Reset in case getopts has been used previously in the shell.
OPTIND=1
# initialise flags here
# convert new *.Rmd --> *.md?
convert=false
# convert existing *.md files as well?
overwrite_md=false
# sync jekyll directory?
unison_sync=false
# build jekyll site?
buildsite=false
# To do everything, the user could set all the flags (commmand-line options),
# but to make life a little easier, this script will interpret _no arguments_
# as "run everything"
if [ $# -eq 0 ] ; then
convert=true
overwrite_md=true
unison_sync=true
buildsite=true
fi
while getopts "h?cosb" opt; do
case $opt in
c)
convert=true
;;
o)
overwrite_md=true
;;
s)
unison_sync=true
;;
b)
buildsite=true
;;
h|\?)
show_help
exit 0
esac
done
shift $((OPTIND-1))
#### 1. convert new/existing *.Rmd to *.md
# use the function KnitPost() from the R-script render_post
if [ "$convert" = true ] ; then
echo ">>>> jc: Converting RMarkdown to Markdown (overwrite = $overwrite_md)"
if [ "$overwrite_md" = true ] ; then
Rscript -e "source('/home/taha/jekyll/chepec/_knitr/render_post.R'); KnitPost(overwrite=TRUE)"
else
Rscript -e "source('/home/taha/jekyll/chepec/_knitr/render_post.R'); KnitPost()"
fi
fi
#### 2. sync the jekyll website directory
# sync local jekyll folder with damietta
if [ "$unison_sync" = true ] ; then
echo ">>>> jc: Syncing jekyll folder"
unison jekyll-chepec -auto
fi
#### 3. build the site (on the server)
if [ "$buildsite" = true ] ; then
echo ">>>> jc: Building site on damietta"
# runs the build-jchepec.sh script (note that the path is local on damietta)
# this line is fubar and needs to be fixed or circumvented
ssh damietta bash --login -c /home/taha/jekyll/build-jchepec.sh
fi
# give the user a summary
# -- good idea, but do it better
#if [ "$buildsite" = true ] ; then
# echo ">>>> jc: Synced and built jekyll site (overwrite = $overwrite)"
#else
# echo ">>>> jc: Synced jekyll folder (overwrite = $overwrite)"
#fi

@ -0,0 +1,38 @@
#!/bin/bash
## Start Rstudio server in Firefox through an encrypted SSH tunnel
## Written Dec 15, 2014
## Taha Ahmed
# ssh port number
PORT=9996 # matches the port set in firefox profile about:config
# the firefox profile "rstudioserver" has been configured
# using about:config to route all traffic (including DNS requests)
# over the socks proxy
# network.proxy.socks : 127.0.0.1
# network.proxy.socks_port : 9996
# network.proxy.socks.remote_dns : true
# network.proxy.socks_version : 5
# network.proxy.type : 1
# network.proxy.no_proxies_on : localhost, 127.0.0.1
# -f forks the process into the background
# when firefox stops using the tunnel, then
# the ssh client exits (having completed the sleep command)
# -N tells ssh that no commands will be sent (-f complains otherwise)
#ssh -D $PORT -f luxor sleep 10;
firefox -P "rstudioserver" "http://luxor.chepec.se/rstudio"
# (the tunnel is setup using autossh in a startup application)
# Notes:
# proxy flag does not work in Chrome:
# google-chrome --proxy-server="socks5://127.0.0.1:9995" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE 127.0.0.1"
# but does work in Chromium, which unfortunately is not supported by Rstudio server
# chromium-browser --proxy-server="socks5://127.0.0.1:9995" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE 127.0.0.1"
# See also:
# http://askubuntu.com/questions/469582/how-do-i-set-up-a-local-socks-proxy-that-tunnels-traffic-through-ssh
# http://kb.mozillazine.org/Command_line_arguments
# http://www.chromium.org/developers/design-documents/network-stack/socks-proxy
# http://www.g-loaded.eu/2006/11/24/auto-closing-ssh-tunnels/

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
## Convert TIFF images into PNG images and create an aggregated PDF ## Convert TIFF images into PNG images and create an aggregated PDF
## Written August 20, 2010 ## Written August 20, 2010
## Edited March 21, 2015
## Taha Ahmed ## Taha Ahmed
@ -19,4 +20,12 @@ do
done done
## dump TIF tags to file
for f in *.tif
do
echo "Printing TIFF tags of $f"
tiffinfo $f > ${f%.*}.txt
done
exit 1 exit 1

@ -0,0 +1,11 @@
#!/usr/bin/python
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "Serving at port", PORT
httpd.serve_forever()
Loading…
Cancel
Save