aboutsummaryrefslogtreecommitdiff
path: root/render.sh
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2019-03-27 18:28:57 +0900
committerjaseg <git@jaseg.net>2019-03-27 18:28:57 +0900
commit6a90803ae6da0759723deda24d746d18e2fb8b8c (patch)
treec0c24d09703a02aeb7743c67872fe4386e31921e /render.sh
downloadinfra-6a90803ae6da0759723deda24d746d18e2fb8b8c.tar.gz
infra-6a90803ae6da0759723deda24d746d18e2fb8b8c.tar.bz2
infra-6a90803ae6da0759723deda24d746d18e2fb8b8c.zip
gerboweb: Initial commit
The functionality is there, no design yet
Diffstat (limited to 'render.sh')
-rwxr-xr-xrender.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/render.sh b/render.sh
new file mode 100755
index 0000000..c3920de
--- /dev/null
+++ b/render.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+[ $# != 1 ] && exit 1
+ID=$1
+egrep -x -q '^[-0-9A-Za-z]{36}$'<<<"$ID" || exit 2
+
+systemd-nspawn \
+ -D /var/cache/gerbolyze_container \
+ -x --bind=/var/cache/gerboweb/upload/$ID:/mnt \
+ /bin/sh -c "set -euo pipefail
+unzip -j -d /tmp/gerber /mnt/gerber.zip
+rm -f /mnt/render_top.png /mnt/render_bottom.png /mnt/render_top.small.png /mnt/render_bottom.small.png
+date; echo 'Rendering bottom layer'
+gerbolyze render top /tmp/gerber /mnt/render_top.png
+date; echo 'Scaling down'
+convert /mnt/render_top.png -resize 500x500 /mnt/render_top.small.png
+date; echo 'Rendering top layer'
+gerbolyze render bottom /tmp/gerber /mnt/render_bottom.png
+date; echo 'Scaling down'
+convert /mnt/render_bottom.png -resize 500x500 /mnt/render_bottom.small.png"