mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-09 23:48:43 +00:00
34 lines
880 B
Bash
34 lines
880 B
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
CONFIG="${1:-config.json}"
|
|
|
|
# Ensure dependencies
|
|
command -v jq >/dev/null 2>&1 || { echo "jq is required" >&2; exit 1; }
|
|
command -v qrencode >/dev/null 2>&1 || { echo "qrencode is required" >&2; exit 1; }
|
|
command -v convert >/dev/null 2>&1 || { echo "ImageMagick convert is required" >&2; exit 1; }
|
|
|
|
url=$(jq -r '.url' "$CONFIG")
|
|
tear=$(jq -r '.tear_off_link' "$CONFIG")
|
|
|
|
[ -n "$url" ] || { echo "URL missing in $CONFIG" >&2; exit 1; }
|
|
[ -n "$tear" ] || { echo "tear_off_link missing in $CONFIG" >&2; exit 1; }
|
|
|
|
tmp_content=$(mktemp)
|
|
tmp_tear=$(mktemp)
|
|
|
|
cleanup() {
|
|
rm -f "$tmp_content" "$tmp_tear"
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
qrencode -o "$tmp_content" -s 10 -m 0 "$url"
|
|
qrencode -o "$tmp_tear" -s 10 -m 0 "$tear"
|
|
|
|
convert "$tmp_content" -resize 128x128 "qrcode-content.png"
|
|
convert "$tmp_tear" -resize 128x128 "qrcode-tear-offs.png"
|
|
|
|
echo "QR codes generated"
|