Takes version as 2nd argument, list versions switch, silent json fetch

This commit is contained in:
Ricardo Andrade 2019-09-06 14:38:38 -05:00
commit b95b27f625

View file

@ -8,6 +8,10 @@ SCRIPT_ACTION=${SCRIPT_ACTION:-install}
# Set to the full version to install. Must be either available on S3 or in the working directory
R_VERSION=${R_VERSION:-}
# The version may optionally be provided as a second argument
if [[ "$2" != "" ]]; then
R_VERSION=$2cd
fi
SUDO=
if [[ $(id -u) != "0" ]]; then
@ -20,7 +24,7 @@ CDN_URL='https://cdn.rstudio.com/r'
# The URL for listing available R versions
VERSIONS_URL="${CDN_URL}/versions.json"
R_VERSIONS=$(curl ${VERSIONS_URL} | \
R_VERSIONS=$(curl -s ${VERSIONS_URL} | \
# Matches the JSON line that contains the r versions
grep r_versions | \
# Gets the value of the `r_version` property (e.g., "[ 3.0.0, 3.0.3, ... ]")
@ -107,6 +111,14 @@ show_versions () {
done
}
# Same as above but for automation purposes
do_show_versions () {
for v in ${R_VERSIONS}
do
echo "${v}"
done
}
# Returns the installer name for a given version and OS
download_name () {
os=$1
@ -367,7 +379,6 @@ check_commands () {
}
do_install () {
# Check for curl
check_commands
@ -402,4 +413,7 @@ case ${SCRIPT_ACTION} in
"install")
do_install
;;
"version")
do_show_versions
;;
esac