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:09 UTC
[55/58] [abbrv] incubator-guacamole-website git commit: Properly
document and license build.sh script.
Properly document and license build.sh script.
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/36e569c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-website/tree/36e569c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-website/diff/36e569c7
Branch: refs/heads/master
Commit: 36e569c739e4b9016dad8905e62affc1a2db60bb
Parents: 7988bb6
Author: Michael Jumper <mj...@apache.org>
Authored: Sat Apr 23 17:03:39 2016 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sat Apr 23 17:03:39 2016 -0700
----------------------------------------------------------------------
build.sh | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 74 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-website/blob/36e569c7/build.sh
----------------------------------------------------------------------
diff --git a/build.sh b/build.sh
index 4366088..7bc73ed 100755
--- a/build.sh
+++ b/build.sh
@@ -1,9 +1,60 @@
#!/bin/sh -e
-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+#
+# -----------------------------------------------------------------------------
+#
+# build.sh: Automatically build the Apache Guacamole website.
+#
+# This script invokes Jekyll to build a static copy of the Guacamole website
+# based on its Markdown and HTML source. If requested, Ruby's HTTP server will
+# be started to serve the built result for the sake of testing.
+#
+# The built results will be available in the "content" subdirectory of the
+# source tree.
+#
+# USAGE:
+#
+# ./build.sh [HTTP SERVER PORT]
+#
+# -----------------------------------------------------------------------------
+#
+
+##
+## Logs the given message to STDERR.
+##
+## @param ...
+## The message to log to STDERR.
+##
log() {
echo "$*" >&2
}
+##
+## Verifies that the given file exists and is a directory. If the file does not
+## exist or is not a directory, an error message is logged and script execution
+## is aborted.
+##
+## @param NAME
+## The name of the file to verify.
+##
assert_directory() {
NAME="$1"
if [ ! -d doc ]; then
@@ -12,6 +63,14 @@ assert_directory() {
fi
}
+##
+## Verifies that the given program is installed and within the search path. If
+## the program is not installed nor within the search path, an error message is
+## logged and script execution is aborted.
+##
+## @param NAME
+## The name of the program to verify.
+##
assert_program() {
NAME="$1"
if ! which "$NAME" &> /dev/null; then
@@ -20,6 +79,11 @@ assert_program() {
fi
}
+##
+## Builds the website using Jekyll. The build result is copied to the "content"
+## subdirectory of the current directory. If the "content" directory already
+## exists, it will first be recursively removed.
+##
build() {
# Verify required programs are installed
@@ -41,13 +105,21 @@ build() {
}
+##
+## Serves the "content" directory using Ruby's own HTTP server.
+##
+## @param PORT
+## The port number on which the HTTP server should listen.
+##
serve() {
+ PORT="$1"
+
# Verify required programs are installed
assert_program ruby
# Run server
- ruby -run -e httpd content/ -p "$1"
+ ruby -run -e httpd content/ -p "$PORT"
}