#!/bin/sh SCRIPTPATH="$(readlink -f "$0")" SCRIPTDIR="$(dirname "$SCRIPTPATH")/" TEMPLATE=${TEMPLATE:-~/Documents/reports/template/template.md} SCRIPTNAME="${SCRIPTPATH##*/}" TODAY=$(date +%d-%m-%4Y) VIEWPDF=${VIEWPDF:-/usr/bin/firefox} usage() { echo "Usage: ${SCRIPTNAME} [-h|-t] [-o outfile.pdf] " echo echo " Positional: , markdown report (input)" echo echo " -h|--help display this message and exit" echo " -t|--template print out the template" echo " -o|--output output file to be written (default: report.pdf)" echo echo " EXAMPLES" echo " # Save the markdown template to a file" echo " ${SCRIPTNAME} -t > template.md" echo " # After editing the template with your vulnerabilities" echo " # launch ${SCRIPTNAME} directly on it" echo " ${SCRIPTNAME} -o 2022-09-google.pdf template.md" echo } if ! command -v pandoc pdflatex >/dev/null; then echo "You need to install pandoc and pdflatex" fi while [ "$#" -ne 0 ]; do case "$1" in -h|--help) usage exit ;; -t|--template) cat "${TEMPLATE}" exit ;; -o|--output) shift export OUTFILE="$1" ;; *) INPUTFILE="$1" esac; shift; done if [ -z "$INPUTFILE" ]; then echo "No input file provided" exit 1 fi pandoc --pdf-engine=xelatex \ --highlight-style=/home/danix/.local/share/pandoc/templates/reports.theme \ --template reports \ --variable fontsize=16pt \ --variable linestretch=1.5 \ --variable geometry=a4paper \ -i "${INPUTFILE}" -o "${OUTFILE:-~/Documents/reports/report_$TODAY.pdf}" # once the file is exported we can preview it in the browser or in a file viewer # $VIEWPDF $OUTFILE