#!/bin/bash
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Licensed 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.

# Environment variables HOST, ACCOUNT, CONTAINER and SECRET must be set!

# python-swiftclient and python-keystoneclient must be installed
# Create a container with : swift post sfdocs
# Add unauthenticated read permission : swift post sfdocs -r '.r:*'
# Create a tempurl Key used to upload doc files : swift post -m Temp-URL-Key:1234

# This script must be call like that :
# SECRET='1234' ACCOUNT='***REMOVED***' CONTAINER='sfdocs' HOST='***REMOVED***' ./publish_docs.sh

set -e

echo "Build docs ..."
cd docs
make html &> /dev/null
cd _build/html

echo "Export docs ..."
for OBJECT in `find $1 -type f`; do
    OBJECT=`echo $OBJECT | sed 's|^\./||'`
    SWIFT_PATH="/v1/${ACCOUNT}/${CONTAINER}/${OBJECT}"
    TEMPURL=`swift tempurl PUT 3600 ${SWIFT_PATH} ${SECRET}`
    curl -f -i -X PUT --upload-file "$OBJECT" "http://${HOST}${TEMPURL}" &> /dev/null && echo -n '.' || { echo 'Fail !'; exit 1; }
done
echo
echo "Done"
rm -rf _build/html

echo "Docs are accessible here :"
echo "http://${HOST}/v1/${ACCOUNT}/${CONTAINER}/index.html"

Add script to publish Sphinx docs to Swift
Add script to publish Sphinx docs to Swift

This script can be used to build and publish docs to Swift. The periodic
job must be configured something like this:

SECRET='secret' HOST="swiftproxy:8080" ACCOUNT="AUTH_test" CONTAINER="docs" ./publish_docs.sh

Change-Id: I40e34c6ec97ac5e2bf58cb1f04d191906b8d4e2b
