Thomas Vachuska | 683b31b | 2015-01-26 11:54:31 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Uploads ONOS Java API docs. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
Brian O'Connor | f5d9363 | 2015-09-04 20:18:31 -0700 | [diff] [blame] | 6 | set -e |
| 7 | |
Thomas Vachuska | 683b31b | 2015-01-26 11:54:31 -0800 | [diff] [blame] | 8 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 9 | . $ONOS_ROOT/tools/build/envDefaults |
| 10 | |
Brian O'Connor | a317872 | 2016-03-10 15:44:27 -0800 | [diff] [blame] | 11 | user=${1:-${WIKI_USER:-$USER}} |
Ray Milkey | 46b3e85 | 2017-09-05 19:41:15 -0700 | [diff] [blame] | 12 | remote=$user@api.onosproject.org |
Thomas Vachuska | 683b31b | 2015-01-26 11:54:31 -0800 | [diff] [blame] | 13 | |
Ray Milkey | f77ea41 | 2018-08-10 17:37:28 -0700 | [diff] [blame^] | 14 | docs="bazel-bin/docs/external.jar" |
Brian O'Connor | 1b6ae59 | 2016-10-25 00:45:00 -0700 | [diff] [blame] | 15 | |
Ray Milkey | 75ee45e | 2018-01-19 14:08:20 -0800 | [diff] [blame] | 16 | ONOS_VERSION_STRING=$ONOS_VERSION |
Ray Milkey | f77ea41 | 2018-08-10 17:37:28 -0700 | [diff] [blame^] | 17 | if echo $ONOS_VERSION_STRING | grep -- '-b'; then |
Ray Milkey | f27ac30 | 2018-05-09 13:14:21 -0700 | [diff] [blame] | 18 | echo "ONOS version $ONOS_VERSION_STRING is a beta. Skipping" |
Ray Milkey | 75ee45e | 2018-01-19 14:08:20 -0800 | [diff] [blame] | 19 | exit 0 |
| 20 | fi |
| 21 | |
| 22 | scp $remote:/var/www/api/index.html /tmp/index.html |
| 23 | CURRENT_VERSION_STRING=`grep URL /tmp/index.html | sed "s%.*URL=/%%" | sed "s%/.*%%"` |
| 24 | CURRENT_VERSION_SPLIT=(${CURRENT_VERSION_STRING//\./ }) |
| 25 | ONOS_VERSION_SPLIT=(${ONOS_VERSION_STRING//\./ }) |
| 26 | |
| 27 | if (( ${ONOS_VERSION_SPLIT[1]} >= ${CURRENT_VERSION_SPLIT[1]} )); then |
Ray Milkey | 859e041 | 2018-03-27 13:58:08 -0700 | [diff] [blame] | 28 | replace="1" |
Ray Milkey | 75ee45e | 2018-01-19 14:08:20 -0800 | [diff] [blame] | 29 | echo "Should replace current version $CURRENT_VERSION_STRING with new ONOS version $ONOS_VERSION_STRING" |
| 30 | else |
| 31 | echo "Not replacing current version $CURRENT_VERSION_STRING with ONOS version $ONOS_VERSION_STRING" |
Ray Milkey | 859e041 | 2018-03-27 13:58:08 -0700 | [diff] [blame] | 32 | replace="0" |
Ray Milkey | 75ee45e | 2018-01-19 14:08:20 -0800 | [diff] [blame] | 33 | fi |
| 34 | |
Ray Milkey | f77ea41 | 2018-08-10 17:37:28 -0700 | [diff] [blame^] | 35 | if echo $ONOS_VERSION_STRING | grep -- '-'; then |
Ray Milkey | f27ac30 | 2018-05-09 13:14:21 -0700 | [diff] [blame] | 36 | echo "ONOS version $ONOS_VERSION_STRING is a beta or RC. Not replacing default document set." |
| 37 | replace="0" |
| 38 | fi |
| 39 | |
Brian O'Connor | 1b6ae59 | 2016-10-25 00:45:00 -0700 | [diff] [blame] | 40 | scp $docs $remote:/tmp/onos-apidocs-$ONOS_VERSION.tar.gz |
Thomas Vachuska | 683b31b | 2015-01-26 11:54:31 -0800 | [diff] [blame] | 41 | ssh $remote " |
| 42 | mkdir -p /var/www/api/$ONOS_VERSION |
| 43 | cd /var/www/api/$ONOS_VERSION |
Brian O'Connor | 1b6ae59 | 2016-10-25 00:45:00 -0700 | [diff] [blame] | 44 | unzip /tmp/onos-apidocs-$ONOS_VERSION.tar.gz |
| 45 | #mv onos-apidocs-$ONOS_VERSION/* . |
| 46 | #rm -rf onos-apidocs-$ONOS_VERSION |
Thomas Vachuska | 683b31b | 2015-01-26 11:54:31 -0800 | [diff] [blame] | 47 | |
Brian O'Connor | c04e876 | 2016-03-01 19:18:53 -0800 | [diff] [blame] | 48 | # bump /var/www/api/index.html |
Ray Milkey | 859e041 | 2018-03-27 13:58:08 -0700 | [diff] [blame] | 49 | if [ "$replace" == "1" ]; then |
| 50 | sed -i -E 's#/[^/]+/#/$ONOS_VERSION/#g' /var/www/api/index.html |
| 51 | fi |
Thomas Vachuska | 683b31b | 2015-01-26 11:54:31 -0800 | [diff] [blame] | 52 | " |