lars
fda9e3f445
logging greatly improved background problem of initialization solved umount_crypto cleaned automatic style importing for validation
139 lines
3.2 KiB
Bash
Executable file
139 lines
3.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
# parse config file
|
|
. /etc/cryptobox/cryptobox.conf
|
|
|
|
|
|
function get_cgi_param()
|
|
# parse the query string for a parameter
|
|
{
|
|
# thttpd does not set query string if it is empty
|
|
set | grep -q "^QUERY_STRING=" || return 0
|
|
# filter the value
|
|
echo "$QUERY_STRING" | sed 's/&/\n/g' | grep "^$1=" | cut -d '=' -f 2-
|
|
}
|
|
|
|
|
|
function header()
|
|
{
|
|
echo "Content-Type: text/html"
|
|
echo
|
|
echo '<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>CryptoBox</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta http-equiv="pragma" content="no-cache" />
|
|
<meta http-equiv="cache-control" content="no-cache" />
|
|
<meta http-equiv="expires" content="0" />
|
|
</head>
|
|
<body>'
|
|
|
|
echo "<p align=\"right\"><a href=\"$SCRIPT_NAME\">Main page</a></p>"
|
|
|
|
# nav bar
|
|
echo '<div id="groups_generate">'
|
|
list_groups4generate
|
|
echo '</div>'
|
|
echo '<div id="groups_display">'
|
|
list_groups4display
|
|
echo '</div>'
|
|
|
|
echo '<p><hr/></p>'
|
|
|
|
if [ -n "$GROUP" ]
|
|
then echo '<div id="cases" style="float:left">'
|
|
list_cases "$GROUP"
|
|
echo '</div>'
|
|
fi
|
|
|
|
echo '<div id="content">'
|
|
}
|
|
|
|
|
|
function footer()
|
|
{
|
|
echo '</div>'
|
|
echo '</body></html>'
|
|
}
|
|
|
|
|
|
function list_groups4generate()
|
|
{
|
|
echo '<p><b>Generate report: </b>'
|
|
local list=$($VALIDATE_SCRIPT list)
|
|
if [ -z "$list" ]
|
|
then echo 'none'
|
|
else for a in $list
|
|
do echo "<a href=\"${SCRIPT_NAME}?action=generate&group=$a\">$a</a> "
|
|
done
|
|
fi
|
|
echo '</p>'
|
|
}
|
|
|
|
|
|
function list_groups4display()
|
|
{
|
|
echo '<p><b>View generated report: </b>'
|
|
local list=$(find "$REPORT_DIR" -type d -mindepth 1 -maxdepth 1 | sort | while read a
|
|
do echo $(basename "$a"); done)
|
|
if [ -z "$list" ]
|
|
then echo 'none available'
|
|
else for a in $list
|
|
do echo "<a href=\"${SCRIPT_NAME}?action=display&group=$a\">$a</a> "
|
|
done
|
|
fi
|
|
echo '</p>'
|
|
}
|
|
|
|
|
|
function list_cases()
|
|
# parameter: group
|
|
{
|
|
echo '<p>'
|
|
if [ -d "$REPORT_DIR/$1" ]
|
|
then find "$REPORT_DIR/$1" -type f -name \*.html | while read a; do basename "${a%.html}"; done | sort | while read a
|
|
do echo "<a href=\"/report/$1/${a}.html\">$a</a><br/>"
|
|
done
|
|
fi
|
|
echo '</p>'
|
|
}
|
|
|
|
|
|
function display_case()
|
|
# parameter: group case
|
|
{
|
|
local FILE="$REPORT_DIR/$1/${2}.html"
|
|
if [ -e "$FILE" ]
|
|
then cat "$FILE" | sed '1,/<body/d; /<\/body>/,$d'
|
|
else echo "<p align=\"center\">File ($FILE) not found!</p>"
|
|
fi
|
|
}
|
|
|
|
|
|
########### main ##############
|
|
|
|
ACTION=$(get_cgi_param action)
|
|
GROUP=$(get_cgi_param group)
|
|
CASE=$(get_cgi_param case)
|
|
|
|
header
|
|
|
|
if [ ! -e "$DEV_FEATURES_SCRIPT" ]
|
|
then echo '<p align="center">This action is only availbale for a development CryptoBox-CD.</p>'
|
|
elif [ "$ACTION" = "generate" -a -n "$GROUP" ]
|
|
then $VALIDATE_SCRIPT check "$GROUP" </dev/null &>/dev/null &
|
|
echo '<p align="center">Validation will take some minutes ...</p>'
|
|
elif [ "$ACTION" = "display" ]
|
|
then if [ -n "$GROUP" -a -n "$CASE" ]
|
|
then display_case "$GROUP" "$CASE"
|
|
elif [ -n "$GROUP" ]
|
|
then display_case "$GROUP" "summary"
|
|
fi
|
|
else [ -n "$ACTION" ] && echo "<p align=\"center\">Unknown action ($ACTION)!</p>"
|
|
fi
|
|
|
|
footer
|