#!/bin/sh set -eu PLUGIN="u-navigator" VERSION="0.1.0" PKG_DIR="packages" WORK_DIR=".plugin-build" PKG_NAME="${PLUGIN}-${VERSION}.tgz" rm -rf "$WORK_DIR" mkdir -p "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/app" "$PKG_DIR" cp -R plugin-root/usr "$WORK_DIR/" cp package.json "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/app/" cp -R public "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/app/" cp -R server "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/app/" find "$WORK_DIR" -name "*.test.js" -delete chmod +x "$WORK_DIR/usr/local/emhttp/plugins/${PLUGIN}/scripts/rc.u-navigator" tar -czf "$PKG_DIR/$PKG_NAME" -C "$WORK_DIR" usr rm -rf "$WORK_DIR" MD5="$(md5 -q "$PKG_DIR/$PKG_NAME" 2>/dev/null || md5sum "$PKG_DIR/$PKG_NAME" | awk '{print $1}')" sed "s/__VERSION__/${VERSION}/g; s/__MD5__/${MD5}/g" u-navigator.plg.in > u-navigator.plg echo "Built $PKG_DIR/$PKG_NAME" echo "MD5 $MD5"