From 759010c5a9a30d8930663cdd69a7da17aa8c3e2a Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Thu, 7 Nov 2013 15:35:36 +0200 Subject: [PATCH] puburler --- aerofs/aerofs-puburl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 aerofs/aerofs-puburl diff --git a/aerofs/aerofs-puburl b/aerofs/aerofs-puburl new file mode 100755 index 0000000..4216dc3 --- /dev/null +++ b/aerofs/aerofs-puburl @@ -0,0 +1,31 @@ +#!/bin/bash + +if [ ! -e "$HOME/.aerofs/pub.root" ] +then echo file "$HOME/.aerofs/pub.root" not found. + echo it must contain the string of your http server with pub files. + echo ex. http://server.com:7777/ + exit 1 +fi + +MyRoot=$( sqlite3 $HOME/.aerofs/conf "SELECT v FROM c WHERE k = 'root';" )/Public/ + + +MyServerRoot=$( cat "$HOME/.aerofs/pub.root" | tr -d "[:cntrl:]" ) + +if [ -z "$1" ] +then echo provide filename + exit 0 +fi + +absPath=$( readlink -f "$1" ) +if [ ! -e "$absPath" ] +then echo file $absPath not found. + exit 1 +fi + +if [[ ! "$absPath" == "$MyRoot"* ]] +then echo $absPath not in $MyRoot + exit 1 +fi + +echo $MyServerRoot${absPath##$MyRoot}