Skip to content

Commit

Permalink
report: use node from /var/lib/thruk/puppeteer is available
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed May 29, 2023
1 parent ce33915 commit 7403b5e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion script/grafana_export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export PATH=$PATH:$DIR

INPUT="$INPUT&from=$START&to=$END"

NODE="node"
if [ -n "$OMD_ROOT" ]; then
if [ -d "$OMD_ROOT/node_modules/" ]; then
export NODE_PATH=$OMD_ROOT/node_modules/
Expand All @@ -36,9 +37,12 @@ if [ -z "$NODE_PATH" ] && [ -d /var/lib/thruk/puppeteer/node_modules ]; then
if [ -z "$PUPPETEER_EXECUTABLE_PATH" ]; then
export PUPPETEER_EXECUTABLE_PATH=$(ls -1 /var/lib/thruk/puppeteer/chromium/chrome/*/chrome*/chrome | head -n 1)
fi
if [ -d /var/lib/thruk/puppeteer/node ]; then
NODE="/var/lib/thruk/puppeteer/node/bin/node"
fi
fi

node $DIR/puppeteer.js "$INPUT" "${TEMPFILE}.png" "$WIDTH" "$HEIGHT" "$THRUK_SESSION_ID" 2>&1
$NODE $DIR/puppeteer.js "$INPUT" "${TEMPFILE}.png" "$WIDTH" "$HEIGHT" "$THRUK_SESSION_ID" 2>&1
rc=$?
if [ -e "$TEMPFILE.png" ]; then
mv "$TEMPFILE.png" "$TEMPFILE"
Expand Down
6 changes: 5 additions & 1 deletion script/html2pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ OUTPUT=$2
IS_REPORT=$4


NODE="node"
if [ -n "$OMD_ROOT" ]; then
if [ -d "$OMD_ROOT/node_modules/" ]; then
export NODE_PATH=$OMD_ROOT/node_modules/
Expand All @@ -36,9 +37,12 @@ if [ -z "$NODE_PATH" ] && [ -d /var/lib/thruk/puppeteer/node_modules ]; then
if [ -z "$PUPPETEER_EXECUTABLE_PATH" ]; then
export PUPPETEER_EXECUTABLE_PATH=$(ls -1 /var/lib/thruk/puppeteer/chromium/chrome/*/chrome*/chrome | head -n 1)
fi
if [ -d /var/lib/thruk/puppeteer/node ]; then
NODE="/var/lib/thruk/puppeteer/node/bin/node"
fi
fi

node $DIR/puppeteer.js "$INPUT" "${OUTPUT}.pdf" "1600" "1200" "" $IS_REPORT 2>&1
$NODE $DIR/puppeteer.js "$INPUT" "${OUTPUT}.pdf" "1600" "1200" "" $IS_REPORT 2>&1
mv "${OUTPUT}.pdf" "${OUTPUT}"
rc=$?
exit $rc
7 changes: 6 additions & 1 deletion script/install_puppeteer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ fi
$NPM i progress puppeteer
set +e

if [ $NODE_VERSION -lt 16 ]; then
$NPM i n
./node_modules/.bin/n 16
fi

if [ -n "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" ]; then
echo ""
echo "puppeteer successfully installed in $DEST"
Expand All @@ -52,7 +57,7 @@ if [ -n "$MISSING" ]; then
yum -y install alsa-lib atk at-spi2-atk libdrm libXcomposite libXdamage libxkbcommon libXrandr mesa-libgbm nss cups-libs pango cairo
elif test -x /usr/bin/dnf; then
yum -y install alsa-lib atk at-spi2-atk cups-libs libdrm libXcomposite libXdamage libxkbcommon libXrandr mesa-libgbm nss
elif test -x /usr/bin/dnf; then
elif test -x /usr/bin/apt-get; then
apt-get install -y libasound2 libatk1.0-0 libatk-bridge2.0-0 libgbm1 libnspr4 libnss3 libxcomposite1 libxdamage1 libxkbcommon0 libxrandr2
fi

Expand Down

0 comments on commit 7403b5e

Please sign in to comment.