-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsec-input.sh
executable file
·63 lines (61 loc) · 2.72 KB
/
sec-input.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
## This scritpt requires jq as dependency and input.json
confirm() {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
rm report.html
echo "<!DOCTYPE html>
<html>
<title>Report</title>
<xmp theme=\"united\" style=\"display:none;\">" > report.html
#jq -r '.[0]."aud-cmd"' input.json ;
len=$(jq '. | length' input.json) ;
#len=1
x=0
while [[ $x -lt $len ]]
do
echo "## $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."desc"' input.json)" >> report.html;
echo "### Used command" >> report.html;
if [[ $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."aud-cmd"' input.json) != "" ]] ; then echo "\`\`\`" >> report.html; fi
if [[ $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."aud-cmd"' input.json) != "" ]] ; then echo $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."aud-cmd"' input.json) >> report.html; else echo "No command" >> report.html; fi
if [[ $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."aud-cmd"' input.json) != "" ]] ; then echo "\`\`\`" >> report.html; fi
echo "
### Result
" >> report.html;
echo "\`\`\`" >> report.html;
if [[ $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."aud-cmd"' input.json) != "" ]] ;
then echo $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."aud-cmd"' input.json ; echo ' ; if [ $? -ne 0 ]; then echo "No output from command" ; fi') > temp.sh && bash temp.sh >> report.html && rm temp.sh ;
else echo "NO command" >> report.html
fi
echo "
" >> report.html;
echo "\`\`\`" >> report.html;
echo "<br>" >> report.html;
if [[ $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."aud-desc"' input.json) != "" ]] ; then echo "<p> $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."aud-desc"' input.json) </p>" >> report.html; fi
#echo "\`\`\`" >> report.html;
if [[ `jq --arg x $x -r '[.[] ] | .[$x | tonumber]."rem-exec"' input.json` -eq 1 ]] ; then echo $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."rem-cmd"' input.json) > temp.sh && bash temp.sh >> report.html && rm temp.sh ; fi
#echo "\`\`\`" >> report.html;
if [[ `jq --arg x $x -r '[.[] ] | .[$x | tonumber]."rem-exec"' input.json` -eq 1 ]] ; then echo $(jq --arg x $x -r '[.[] ] | .[$x | tonumber]."rem-desc"' input.json) >> report.html ; fi
#echo $x >> report.html ;
echo $x ;
echo "
---" >> report.html;
x=$(( $x + 1 )) ;
done
echo "
</xmp>
<script src=\"https://cdn.ztx.io/strapdown/strapdown.min.js\"></script>
</html>" >> report.html
fn=`date "+%Y%m%d%H%M%S"`
curl -v --retry 15 --retry-delay 0 --retry-max-time 40 -T report.html "ftp://report33:358976665@files.000webhost.com/public_html/$fn.html"
echo "Report: https://report33.000webhostapp.com/$fn.html"
#markdown report.html -f fencedcode > md.html