|
|
|
@ -26,6 +26,9 @@ NETCAT=netcat |
|
|
|
|
OPREFIX=/tmp/outf_ |
|
|
|
|
IPREFIX=/tmp/inf_ |
|
|
|
|
|
|
|
|
|
DEBUG= |
|
|
|
|
##DEBUG=yes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## function |
|
|
|
|
cleanup(){ |
|
|
|
@ -67,7 +70,7 @@ fi |
|
|
|
|
## function |
|
|
|
|
invalid_selector(){ |
|
|
|
|
sel="$1" |
|
|
|
|
echo "iInvalid selector: \"$sel\"" |
|
|
|
|
echo "3Error: Invalid selector: \"$sel\"" |
|
|
|
|
echo "." |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
@ -77,7 +80,6 @@ serve_selector(){ |
|
|
|
|
sel="$1" |
|
|
|
|
|
|
|
|
|
cat "${sel}" |
|
|
|
|
echo "." |
|
|
|
|
exit 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -101,6 +103,7 @@ serve_index(){ |
|
|
|
|
echo $line |
|
|
|
|
esac |
|
|
|
|
done < $IDX |
|
|
|
|
printf ".\r\n" |
|
|
|
|
exit 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -112,16 +115,19 @@ read selector |
|
|
|
|
|
|
|
|
|
selector=$(echo $selector | sed -r 's:\r::g' ) |
|
|
|
|
|
|
|
|
|
[ -n "$DEBUG" ] && { |
|
|
|
|
echo "iGOPHERDIR: ${GOPHERDIR}" |
|
|
|
|
echo "iselector: \"${selector}\"" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case $selector in |
|
|
|
|
/*|"") |
|
|
|
|
RP1=$(realpath "${GOPHERDIR}"/"${selector}" || "") |
|
|
|
|
RP2=$(realpath "${GOPHERDIR}")"${selector}" |
|
|
|
|
RP2=$(realpath $(realpath "${GOPHERDIR}")"${selector}") |
|
|
|
|
[ -n "$DEBUG" ] && { |
|
|
|
|
echo "iRP1: ${RP1}" |
|
|
|
|
echo "iRP2: ${RP2}" |
|
|
|
|
#echo "." |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if [ "${RP1}" = "${RP2}" ]; then |
|
|
|
|
if [ -f "${RP1}" ]; then |
|
|
|
@ -129,14 +135,13 @@ case $selector in |
|
|
|
|
elif [ -d "${RP1}" ]; then |
|
|
|
|
[ -f "${RP1}/gophermap" ] && serve_selector "${RP1}/gophermap" |
|
|
|
|
[ -f "${RP1}/index.gph" ] && serve_index "${RP1}/index.gph" |
|
|
|
|
else |
|
|
|
|
echo "3Err Unable to find file ${selector}" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
invalid_selector "$selector" |
|
|
|
|
;; |
|
|
|
|
*) |
|
|
|
|
[ -f "${GOPHERDIR}/gophermap" ] && cat "${GOPHERDIR}/gophermap" && echo "." && exit 0 |
|
|
|
|
[ -f "${GOPHERDIR}/gophermap" ] && serve_selector "${GOPHERDIR}/gophermap" |
|
|
|
|
[ -f "${GOPHERDIR}/index.gph" ] && serve_index "${GOPHERDIR}/index.gph" |
|
|
|
|
invalid_selector "/" |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|