|
29 | 29 | # POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
|
31 | 31 | PERSISTENT_BASE="${HOME}/.ursim" |
32 | | -URCAP_VERSION="" # If not set, the latest version will be downloaded |
| 32 | +URCAP_VERSION="latest" |
33 | 33 | IP_ADDRESS="192.168.56.101" |
34 | 34 | PORT_FORWARDING_WITH_DASHBOARD="-p 30001-30004:30001-30004 -p 29999:29999" |
35 | 35 | PORT_FORWARDING_WITHOUT_DASHBOARD="-p 30001-30004:30001-30004" |
@@ -212,15 +212,58 @@ post_setup_e-series() |
212 | 212 | post_setup_cb3 |
213 | 213 | } |
214 | 214 |
|
| 215 | +get_effective_url() |
| 216 | +{ |
| 217 | + curl -Ls -o /dev/null -w %\{url_effective\} "$1" |
| 218 | +} |
| 219 | + |
| 220 | +get_version_from_release_url() |
| 221 | +{ |
| 222 | + echo "$effective_url" | grep -oP '\d+\.\d+\.\d+' | head -n 1 |
| 223 | +} |
| 224 | + |
| 225 | +# Get the latest tag from a GitHub release page. Provide a link to its latest release e.g. |
| 226 | +# https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/latest |
| 227 | +get_latest_release_tag() |
| 228 | +{ |
| 229 | + effective_url=$(get_effective_url "$1") |
| 230 | + get_version_from_release_url "$effective_url" |
| 231 | +} |
| 232 | + |
| 233 | +# Get the URCAPX download URL for a given version |
| 234 | +# |
| 235 | +# Specify the desired version or "latest" as the first argument |
| 236 | +# |
| 237 | +# sets URCAPX_VERSION |
| 238 | +# sets URCAPX_DOWNLOAD_URL |
| 239 | +get_download_url_urcapx() |
| 240 | +{ |
| 241 | + release_url="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/$1" |
| 242 | + URCAPX_VERSION=$(get_latest_release_tag "$release_url") |
| 243 | + URCAPX_DOWNLOAD_URL="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/download/$URCAPX_VERSION/external-control-$URCAPX_VERSION.urcapx" |
| 244 | +} |
| 245 | + |
| 246 | +# Get the URCAPX download URL for a given version |
| 247 | +# |
| 248 | +# Specify the desired version or "latest" as the first argument |
| 249 | +# |
| 250 | +# sets URCAPX_VERSION |
| 251 | +# sets URCAPX_DOWNLOAD_URL |
| 252 | +get_download_url_urcap() |
| 253 | +{ |
| 254 | + release_url="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/$1" |
| 255 | + URCAP_VERSION=$(get_latest_release_tag "$release_url") |
| 256 | + URCAP_DOWNLOAD_URL="https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/download/v$URCAP_VERSION/externalcontrol-$URCAP_VERSION.jar" |
| 257 | +} |
| 258 | + |
215 | 259 | post_setup_polyscopex() |
216 | 260 | { |
217 | | - urcapx_download_url=$(curl -s https://api.github.com/repos/UniversalRobots/Universal_Robots_ExternalControl_URCapX/releases/latest | grep "browser_download_url.*urcapx" | cut -d ":" -f 2,3 | tr -d "\"[:space:]") |
218 | | - URCAPX_VERSION=$(echo "$urcapx_download_url" | grep -oP '\d+\.\d+\.\d+' | head -n 1) |
| 261 | + get_download_url_urcapx latest |
219 | 262 | mkdir -p "${URCAP_STORAGE}" |
220 | | - urcapx_file="${URCAP_STORAGE}/external_control-$URCAPX_VERSION.urcapx" |
| 263 | + urcapx_file="${URCAP_STORAGE}/external-control-$URCAPX_VERSION.urcapx" |
221 | 264 | if [[ ! -f "$urcapx_file" ]]; then |
222 | 265 | echo "Downloading External Control URCapX version ${URCAPX_VERSION}" |
223 | | - curl -L -o "$urcapx_file" "$urcapx_download_url" |
| 266 | + curl -L -o "$urcapx_file" "$URCAPX_DOWNLOAD_URL" |
224 | 267 | fi |
225 | 268 |
|
226 | 269 | echo -ne "Starting URSim. Waiting for UrService to be up..." |
@@ -383,13 +426,10 @@ main() { |
383 | 426 | PROGRAM_STORAGE=$(realpath "$PROGRAM_STORAGE") |
384 | 427 |
|
385 | 428 | # Download external_control URCap |
386 | | - if [[ -z "$URCAP_VERSION" ]]; then |
387 | | - urcap_download_url=$(curl -s https://api.github.com/repos/UniversalRobots/Universal_Robots_ExternalControl_URCap/releases/latest | grep "browser_download_url.*jar" | cut -d ":" -f 2,3 | tr -d "\"[:space:]") |
388 | | - URCAP_VERSION=$(echo "$urcap_download_url" | grep -oP '\d+\.\d+\.\d+' | head -n 1) |
389 | | - fi |
| 429 | + get_download_url_urcap $URCAP_VERSION |
390 | 430 | if [[ ! -f "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" ]]; then |
391 | 431 | echo "Downloading and installing External Control URCap version ${URCAP_VERSION}" |
392 | | - curl -L -o "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" "$urcap_download_url" |
| 432 | + curl -L -o "${URCAP_STORAGE}/externalcontrol-${URCAP_VERSION}.jar" "$URCAP_DOWNLOAD_URL" |
393 | 433 | fi |
394 | 434 | docker_cmd="docker run --rm -d --net ursim_net --ip $IP_ADDRESS\ |
395 | 435 | -v ${URCAP_STORAGE}:/urcaps \ |
|
0 commit comments