2017-11-18 00:26:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-11-18 22:52:03 +00:00
|
|
|
. $1
|
2017-11-18 00:26:25 +00:00
|
|
|
|
2017-11-18 22:52:03 +00:00
|
|
|
setStatusCode 200
|
2017-11-18 00:26:25 +00:00
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
<!DOCTYPE>
|
|
|
|
<html>
|
|
|
|
<head>
|
2017-11-21 21:33:36 +00:00
|
|
|
<title>Index of ${server[scriptName]}</title>
|
2017-11-18 00:26:25 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2017-11-21 21:33:36 +00:00
|
|
|
<h1>Index of ${server[scriptName]}</h1>
|
2017-11-18 00:26:25 +00:00
|
|
|
<hr />
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
Name
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Type
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Executeable
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Size
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
EOF
|
|
|
|
|
2017-11-21 21:33:36 +00:00
|
|
|
for file in $(ls -a "${server[scriptFilename]}"); do
|
|
|
|
if test "$file" = ".." -a "${server[scriptName]}" = "/"; then
|
2017-11-18 00:26:25 +00:00
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
cat <<EOF
|
|
|
|
<tr>
|
|
|
|
<td>
|
2017-11-21 21:33:36 +00:00
|
|
|
<a href="$(realpath -sm "${server[scriptName]}/$file")">$file</a>
|
2017-11-18 00:26:25 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
2017-11-21 21:33:36 +00:00
|
|
|
$(file -b "${server[scriptFilename]}/$file")
|
2017-11-18 00:26:25 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
2017-11-21 21:33:36 +00:00
|
|
|
$(if test ! -d "${server[scriptFilename]}/$file"; then if test -x "${server[scriptFilename]}/$file"; then echo yes; else echo no; fi; fi)
|
2017-11-18 00:26:25 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
2017-11-21 21:33:36 +00:00
|
|
|
$(if test ! -d "${server[scriptFilename]}/$file"; then du -kh "${server[scriptFilename]}/$file" | cut -f1; fi)
|
2017-11-18 00:26:25 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
</table>
|
|
|
|
<hr />
|
2017-11-21 21:33:36 +00:00
|
|
|
${server[serverSignature]}
|
2017-11-18 00:26:25 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOF
|