You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2016/04/24 03:03:08 UTC
[54/58] [abbrv] incubator-guacamole-website git commit: Add easy
mechanism for starting local webserver.
Add easy mechanism for starting local webserver.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-website/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-website/commit/7988bb69
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-website/tree/7988bb69
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-website/diff/7988bb69
Branch: refs/heads/master
Commit: 7988bb699470598a1a424d055de0863e5c283ae5
Parents: b64cf52
Author: Michael Jumper <mj...@apache.org>
Authored: Sat Apr 23 16:51:28 2016 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sat Apr 23 16:51:28 2016 -0700
----------------------------------------------------------------------
build.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 52 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-website/blob/7988bb69/build.sh
----------------------------------------------------------------------
diff --git a/build.sh b/build.sh
index c161575..4366088 100755
--- a/build.sh
+++ b/build.sh
@@ -7,24 +7,64 @@ log() {
assert_directory() {
NAME="$1"
if [ ! -d doc ]; then
- log "FATAL: $NAME does not exist or is not a directory."
+ log "FATAL: \"$NAME\" does not exist or is not a directory."
exit 1
fi
}
-# Build site
-jekyll build
+assert_program() {
+ NAME="$1"
+ if ! which "$NAME" &> /dev/null; then
+ log "FATAL: \"$NAME\" is not installed."
+ exit 1
+ fi
+}
+
+build() {
+
+ # Verify required programs are installed
+ assert_program jekyll
+
+ # Build site
+ jekyll build
+
+ # Verify expected directories exist
+ assert_directory doc
+ assert_directory _site
-# Verify expected directories exist
-assert_directory doc
-assert_directory _site
+ # Clean out content directory (if present)
+ rm -rf content/; mkdir content
+
+ # Copy site and docs into place
+ cp -a doc/ content/
+ cp -a _site/* content/
+
+}
+
+serve() {
+
+ # Verify required programs are installed
+ assert_program ruby
+
+ # Run server
+ ruby -run -e httpd content/ -p "$1"
+
+}
-# Clean out content directory (if present)
-rm -rf content/; mkdir content
+# Verify number of arguments
+if [ "$#" -gt 1 -o "$1" = "-h" ]; then
+ log "Usage:"
+ log " $0 -h # Display this message"
+ log " $0 # Build website"
+ log " $0 PORT # Build website and serve from the given PORT"
+ exit 1
+fi
-# Copy site and docs into place
-cp -a doc/ content/
-cp -a _site/* content/
+# Build in all cases
+build
-# Done
+# Serve on requested port
+if [ -n "$1" ]; then
+ serve "$1"
+fi