-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·48 lines (44 loc) · 1.65 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·48 lines (44 loc) · 1.65 KB
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
#!/usr/bin/env bash
# Render resume.html -> Aswin_Resume.pdf using headless Chromium.
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Resolve a browser.
# - CI (and anyone) can pass BROWSER explicitly; we use it as-is and fail
# loudly if it isn't runnable — we don't second-guess an explicit choice.
# - Otherwise we search common Chrome/Chromium names, and if none are found
# offer to install Chromium (only when running interactively).
if [[ -n "${BROWSER:-}" ]]; then
if ! command -v "$BROWSER" >/dev/null 2>&1 && [[ ! -x "$BROWSER" ]]; then
echo "BROWSER='$BROWSER' not found or not executable." >&2
exit 1
fi
else
BROWSER=""
for b in chromium chromium-browser google-chrome google-chrome-stable chrome; do
if command -v "$b" >/dev/null 2>&1; then BROWSER="$b"; break; fi
done
if [[ -z "$BROWSER" ]]; then
echo "No Chromium/Chrome found on PATH." >&2
ans="n"
if [[ -t 0 ]]; then
read -rp "Install Chromium with apt-get now? [y/N] " ans
fi
if [[ "$ans" == [Yy]* ]]; then
sudo apt-get update || true
sudo apt-get install -y chromium \
|| sudo apt-get install -y chromium-browser \
|| true
for b in chromium chromium-browser; do
if command -v "$b" >/dev/null 2>&1; then BROWSER="$b"; break; fi
done
fi
fi
if [[ -z "$BROWSER" ]]; then
echo "No browser available. Install Chromium, or run: BROWSER=/path/to/chrome ./build.sh" >&2
exit 1
fi
fi
"$BROWSER" --headless --no-sandbox --disable-gpu --no-margins \
--print-to-pdf="$DIR/Aswin_Resume.pdf" --print-to-pdf-no-header \
"file://$DIR/resume.html"
echo "Built $DIR/Aswin_Resume.pdf"