Corrected exit statuses in chertex.sh to zero for success and one otherwise.
parent
97e446e480
commit
1e6ce316f1
@ -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/
|
@ -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…
Reference in New Issue