From 5beb7b3b219feb62b0ce14d450c2613a31ff98cf Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Tue, 17 Dec 2013 10:31:31 -0800 Subject: [PATCH] first draft of doc viewer script --- bin/install-docviewer.sh | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 bin/install-docviewer.sh diff --git a/bin/install-docviewer.sh b/bin/install-docviewer.sh new file mode 100755 index 000000000..bbbf4b9de --- /dev/null +++ b/bin/install-docviewer.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +die() { + echo $1 + exit 1 +} + +log() { + echo -e "\033[1;34m===== $1 \033[1;37m$2 \033[1;34m=====\033[0m" +} + +INDEX= +while getopts ":i:" opt; do + case $opt in + i) + INDEX="$OPTARG" + ;; + :) + die "Option -$OPTARG requires an argument" + ;; + esac +done + +if [ -z $INDEX ]; then + die "Need index.html to copy, use -i flag to specify" +fi + +shift $(($OPTIND - 1)) + +for repo in $@; do + name=${repo##*[/\\]}; + log "Installing Doc Viewer to" "$name" + if [ -e $repo/index.html ] && [ -e $repo/smoke.html ]; then + continue; + fi + if [ -e $repo/index.html ]; then + echo "moving old index.html to smoke test" + mv $repo/index.html $repo/smoke.html + fi + echo "Copying doc index.html" + cp $INDEX $repo/index.html +done