move bench.sh to the template instead
diff --git a/Makefile b/Makefile
index 7205dcf..983c304 100644
--- a/Makefile
+++ b/Makefile
@@ -20,8 +20,5 @@
 	@$(REBAR) clean
 
 app:
+	@[ -z "$(PROJECT)" ] && echo "ERROR: required variable PROJECT missing" 1>&2 && exit 1 || true
 	@$(REBAR) -r create template=mochiwebapp dest=$(DEST) appid=$(PROJECT)
-
-bench: app
-	@echo "Writing $(DEST)/$(PROJECT).sh"
-	@cp support/bench.sh $(DEST)/bench.sh
diff --git a/support/bench.sh b/support/bench.sh
deleted file mode 100755
index 7af4c69..0000000
--- a/support/bench.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-SERVER_IP=""
-
-if test ! -n "$SERVER_IP"; then
-    echo "error: please set SERVER_IP"
-    exit 1
-fi
-
-BENCH_RUN="siege -q -c400 -r100 -b http://$SERVER_IP:8080/hello_world"
-
-sleep 120
-
-echo ""
-echo ""
-for i in `seq 1 10`;
-do
-    echo "Running test #$i:"
-    $BENCH_RUN
-    sleep 90
-done
diff --git a/support/templates/mochiwebapp.template b/support/templates/mochiwebapp.template
index 4942609..c56314c 100644
--- a/support/templates/mochiwebapp.template
+++ b/support/templates/mochiwebapp.template
@@ -13,6 +13,7 @@
 {template, "mochiwebapp_skel/src/mochiapp_sup.erl", "{{dest}}/src/{{appid}}_sup.erl"}.
 {template, "mochiwebapp_skel/src/mochiapp_web.erl", "{{dest}}/src/{{appid}}_web.erl"}.
 {template, "mochiwebapp_skel/start-dev.sh", "{{dest}}/start-dev.sh"}.
+{template, "mochiwebapp_skel/bench.sh", "{{dest}}/bench.sh"}.
 {template, "mochiwebapp_skel/priv/www/index.html", "{{dest}}/priv/www/index.html"}.
 {file, "../../.gitignore", "{{dest}}/.gitignore"}.
 {file, "../../Makefile", "{{dest}}/Makefile"}.
@@ -20,3 +21,4 @@
 {file, "../../rebar", "{{dest}}/rebar"}.
 {chmod, 8#755, "{{dest}}/rebar"}.
 {chmod, 8#755, "{{dest}}/start-dev.sh"}.
+{chmod, 8#755, "{{dest}}/bench.sh"}.
diff --git a/support/templates/mochiwebapp_skel/bench.sh b/support/templates/mochiwebapp_skel/bench.sh
new file mode 100755
index 0000000..eb6e9c9
--- /dev/null
+++ b/support/templates/mochiwebapp_skel/bench.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# workaround for rebar mustache template bug
+DEFAULT_PORT={{port}}
+HOST=${HOST:-127.0.0.1}
+PORT=${PORT:-${DEFAULT_PORT}}
+
+BENCH_RUN="siege -q -c400 -r100 -b http://$HOST:$PORT/hello_world"
+
+sleep 120
+
+echo ""
+echo ""
+for i in `seq 1 10`;
+do
+    echo "Running test #$i:"
+    $BENCH_RUN
+    sleep 90
+done