aboutsummaryrefslogtreecommitdiff
path: root/vector.sh.j2
blob: b17116edbf2418c1b74522a105eb0dca4897fdad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

[ $# != 2 ] && exit 1
ID=$1
egrep -x -q '^[-0-9A-Za-z]{36}$'<<<"$ID" || exit 2
LAYER=$2
egrep -x -q '^(top|bottom)$'<<<"$LAYER" || exit 2

systemd-nspawn \
    -D {{gerboweb_root}} \
    -x --bind={{gerboweb_cache}}/upload/$ID:/mnt \
    /bin/sh -c "set -euo pipefail
cd /tmp
unzip -j -d gerber_in /mnt/gerber.zip
gerbolyze vectorize $LAYER gerber_in gerber /mnt/overlay.png
rm -f /mnt/gerber_out.zip
zip -r /mnt/gerber_out.zip gerber"