aboutsummaryrefslogtreecommitdiff
path: root/gerboweb/ansible/render.sh.j2
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-07-04 23:57:28 +0200
committerjaseg <git@jaseg.de>2022-07-04 23:57:28 +0200
commit3ba932209fc33206a28483d07fb0e108d1b16a2b (patch)
treeafd6bf65b37b096f79b2ef2697e72b31a230bc87 /gerboweb/ansible/render.sh.j2
parent1da5919d9133f09bdd112da592620564368fd103 (diff)
downloadgerbolyze-3ba932209fc33206a28483d07fb0e108d1b16a2b.tar.gz
gerbolyze-3ba932209fc33206a28483d07fb0e108d1b16a2b.tar.bz2
gerbolyze-3ba932209fc33206a28483d07fb0e108d1b16a2b.zip
gerboweb: add deployment stuff
Diffstat (limited to 'gerboweb/ansible/render.sh.j2')
-rwxr-xr-xgerboweb/ansible/render.sh.j217
1 files changed, 17 insertions, 0 deletions
diff --git a/gerboweb/ansible/render.sh.j2 b/gerboweb/ansible/render.sh.j2
new file mode 100755
index 0000000..beed8f1
--- /dev/null
+++ b/gerboweb/ansible/render.sh.j2
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+[ $# != 1 ] && exit 1
+ID=$1
+egrep -x -q '^[-0-9A-Za-z]{36}$'<<<"$ID" || exit 2
+
+systemd-nspawn \
+ -D {{gerboweb_root}} \
+ -x --bind={{gerboweb_cache}}/upload/$ID:/mnt \
+ /bin/sh -c "set -euo pipefail
+unzip -j -d /tmp/gerber /mnt/gerber.zip
+rm -f /mnt/template_top.svg /mnt/template_bottom.svg /mnt/template_top.preview.png /mnt/template_bottom.preview.png
+date; echo 'Rendering'
+gerbolyze template --top /mnt/template_top.svg --bottom /mnt/template_bottom.svg /tmp/gerber
+date; echo 'Scaling down'
+convert /mnt/template_top.svg -resize 500x500 -negate -brightness-contrast 30x30 -colorspace gray /mnt/template_top.preview.png
+convert /mnt/template_bottom.svg -resize 500x500 -negate -brightness-contrast 30x30 -colorspace gray /mnt/template_bottom.preview.png