Takes version as 2nd argument, list versions switch, silent json fetch
This commit is contained in:
parent
674f5fe48e
commit
b95b27f625
1 changed files with 16 additions and 2 deletions
18
install.sh
18
install.sh
|
|
@ -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
|
# Set to the full version to install. Must be either available on S3 or in the working directory
|
||||||
R_VERSION=${R_VERSION:-}
|
R_VERSION=${R_VERSION:-}
|
||||||
|
# The version may optionally be provided as a second argument
|
||||||
|
if [[ "$2" != "" ]]; then
|
||||||
|
R_VERSION=$2cd
|
||||||
|
fi
|
||||||
|
|
||||||
SUDO=
|
SUDO=
|
||||||
if [[ $(id -u) != "0" ]]; then
|
if [[ $(id -u) != "0" ]]; then
|
||||||
|
|
@ -20,7 +24,7 @@ CDN_URL='https://cdn.rstudio.com/r'
|
||||||
# The URL for listing available R versions
|
# The URL for listing available R versions
|
||||||
VERSIONS_URL="${CDN_URL}/versions.json"
|
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
|
# Matches the JSON line that contains the r versions
|
||||||
grep r_versions | \
|
grep r_versions | \
|
||||||
# Gets the value of the `r_version` property (e.g., "[ 3.0.0, 3.0.3, ... ]")
|
# Gets the value of the `r_version` property (e.g., "[ 3.0.0, 3.0.3, ... ]")
|
||||||
|
|
@ -107,6 +111,14 @@ show_versions () {
|
||||||
done
|
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
|
# Returns the installer name for a given version and OS
|
||||||
download_name () {
|
download_name () {
|
||||||
os=$1
|
os=$1
|
||||||
|
|
@ -367,7 +379,6 @@ check_commands () {
|
||||||
}
|
}
|
||||||
|
|
||||||
do_install () {
|
do_install () {
|
||||||
|
|
||||||
# Check for curl
|
# Check for curl
|
||||||
check_commands
|
check_commands
|
||||||
|
|
||||||
|
|
@ -402,4 +413,7 @@ case ${SCRIPT_ACTION} in
|
||||||
"install")
|
"install")
|
||||||
do_install
|
do_install
|
||||||
;;
|
;;
|
||||||
|
"version")
|
||||||
|
do_show_versions
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue