baf27a82fd031b3fc9c28e1176083da9dab2548a
configuration/environments_scripts/sailing_server/files/usr/local/bin/refreshInstance.sh
| ... | ... | @@ -153,17 +153,11 @@ install_environment () |
| 153 | 153 | load_from_release_file () |
| 154 | 154 | { |
| 155 | 155 | if [[ ${INSTALL_FROM_RELEASE} == "" ]]; then |
| 156 | - INSTALL_FROM_RELEASE="$(wget -O - https://releases.sapsailing.com/ 2>/dev/null | grep main- | tail -1 | sed -e 's/^.*\(main-[0-9]*\).*$/\1/')" |
|
| 157 | - echo "You didn't provide a release. Defaulting to latest master build https://releases.sapsailing.com/$INSTALL_FROM_RELEASE" |
|
| 158 | - # Alternatively, to download a release from Github, here is how the latest Java8/main-release can be obtained: |
|
| 159 | - # curl -L -H 'Authorization: Bearer ***' https://api.github.com/repos/SAP/sailing-analytics/releases 2>/dev/null | jq -r 'sort_by(.created_at) | reverse | map(select(.name | startswith("main-")))[0].assets[] | select(.content_type=="application/x-tar").id' |
|
| 160 | - # will output something like: |
|
| 161 | - # 169233159 |
|
| 162 | - # which can then be used in a request such as: |
|
| 163 | - # curl -L -o main-1234567890.tar.gz -H 'Accept: application/octet-stream' -H 'Authorization: Bearer ***' 'https://api.github.com/repos/SAP/sailing-analytics/releases/assets/169233159' |
|
| 164 | - # Or to obtain the latest docker-17 release, try this: |
|
| 165 | - # curl -L -H 'Authorization: Bearer ***' https://api.github.com/repos/SAP/sailing-analytics/releases 2>/dev/null | jq -r 'sort_by(.created_at) | reverse | map(select(.name | startswith("docker-17-")))[0].assets[] | select(.content_type=="application/x-tar").id' |
|
| 166 | - # and then on like above... |
|
| 156 | + GITHUB_RELEASE=$( curl -L https://api.github.com/repos/SAP/sailing-analytics/releases 2>/dev/null | jq -r 'sort_by(.created_at) | reverse | map(select(.name | startswith("main-")))[0].assets[] | select(.content_type=="application/x-tar")' ) |
|
| 157 | + INSTALL_FROM_RELEASE=$( echo "${GITHUB_RELEASE}" | jq -r '.name' | sed -e 's/\.tar\.gz$//' ) |
|
| 158 | + echo "You didn't provide a release. Defaulting to latest main branch build ${INSTALL_FROM_RELEASE}" |
|
| 159 | + else |
|
| 160 | + GITHUB_RELEASE=$( curl -L https://api.github.com/repos/SAP/sailing-analytics/releases 2>/dev/null | jq -r 'sort_by(.created_at) | reverse | map(select(.name=="'${INSTALL_FROM_RELEASE}'"))[0].assets[] | select(.content_type=="application/x-tar")' ) |
|
| 167 | 161 | fi |
| 168 | 162 | if which mail; then |
| 169 | 163 | if [ -n "${BUILD_COMPLETE_NOTIFY}" ]; then |
| ... | ... | @@ -182,8 +176,8 @@ load_from_release_file () |
| 182 | 176 | SCP_HOST=$( echo ${INSTALL_FROM_SCP_USER_AT_HOST_AND_PORT} | sed -e 's/^\([^:]*\):\?\([0-9]*\)\?$/\1/' ) |
| 183 | 177 | scp ${SCP_PORT_OPTION} ${SCP_HOST}:/home/trac/releases/${INSTALL_FROM_RELEASE}/${RELEASE_FILE_NAME} . |
| 184 | 178 | else |
| 185 | - echo "Loading from release file https://releases.sapsailing.com/${INSTALL_FROM_RELEASE}/${RELEASE_FILE_NAME}" |
|
| 186 | - wget https://releases.sapsailing.com/${INSTALL_FROM_RELEASE}/${RELEASE_FILE_NAME} |
|
| 179 | + echo "Loading from release file $( echo "${GITHUB_RELEASE}" | jq -r '.browser_download_url' )" |
|
| 180 | + wget $( echo "${GITHUB_RELEASE}" | jq -r '.browser_download_url' ) |
|
| 187 | 181 | fi |
| 188 | 182 | load_from_local_release_file |
| 189 | 183 | } |