From 8fd5ad4f46400e1b6d39340db064f518e14f3b0d Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Sun, 2 Jan 2022 23:38:29 -0500 Subject: [PATCH] Fix R update script --- README.md | 9 ++++++--- script-system-update-r | 28 ++++++++++++++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 405c544e..880bf249 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Last updated: 2022-01-02 - [Make an existing Windows 10 account user an administrator](#make-an-existing-windows-10-account-user-an-administrator) - [Creating more VM disk space](#creating-more-vm-disk-space) - [Updating system software](#updating-system-software) - - [Updating RStudio and RStudio Server](#updating-rstudio-and-rstudio-server) + - [Updating R, RStudio Desktop, and RStudio Server](#updating-r-rstudio-desktop-and-rstudio-server) - [Scheduling a restart](#scheduling-a-restart) - [Adding a drive](#adding-a-drive) - [Logging](#logging) @@ -304,9 +304,12 @@ Once configured, the user will no longer need to enter their password to access - The server regularly installs security updates unattended - If the kernel, java, systemd, or other major components are updated, the system should be restarted. -### Updating RStudio and RStudio Server +### Updating R, RStudio Desktop, and RStudio Server - -`script-system-update-r` +- `script-system-update-r` `R_VERSION` `RSTUDIO_VERSION` + - Example `R_VERSION`: `4.1.2` + - Example `RSTUDIO_VERSION`: `2021.09.1-372` + - Links to latest available [R](https://docs.rstudio.com/resources/install-r/) and [RStudio](https://www.rstudio.com/products/rstudio/download/#download) versions ### Scheduling a restart diff --git a/script-system-update-r b/script-system-update-r index 61ccd404..e5de95ee 100755 --- a/script-system-update-r +++ b/script-system-update-r @@ -1,6 +1,7 @@ #!/usr/bin/env bash -# Update the R binaries and RStudio-R4 application meny entry -# $1: Version number ex. '2021.09.1-372' +# Update the R binaries and RStudio-R4 application menu entry +# $1: R version number, ex. '4.1.2' +# $2: RStudio version number, ex. '2021.09.1-372' # Copyright 2021 Bryan C. Roessler parent="${BASH_SOURCE[0]}" @@ -10,21 +11,28 @@ parent=${parent%/*} is_root -if [[ $# -ne 1 ]]; then - echo "Missing R version argument." - echo "Example: '2021.09.1-372'" +if [[ $# -eq 2 ]]; then + re='^[0-9].[0-9].[0-9]$' + [[ $1 =~ $re ]] || echo "Bad R version number" && exit 1 + re='^[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9]-[0-9]+$' + [[ $2 =~ $re ]] || echo "Bad RStudio version number" && exit 1 +else + echo "You must provide exactly two arguments!" + echo "\$1: R version, ex. '4.1.2'" + echo "\$2: RStudio version, ex. '2021.09.1-372'" exit 1 + fi -ask_ok "RStudio-R4 to version $1?" || exit $? +ask_ok "Update R to version $1 and RStudio to version $2?" || exit $? sudo dnf install -y "https://cdn.rstudio.com/r/centos-7/pkgs/R-${1}-1-1.x86_64.rpm" \ - "https://download2.rstudio.org/server/centos7/x86_64/rstudio-server-rhel-${1}-x86_64.rpm" + "https://download2.rstudio.org/server/centos7/x86_64/rstudio-server-rhel-${2}-x86_64.rpm" \ + "https://download1.rstudio.org/desktop/centos7/x86_64/rstudio-${2}-x86_64.rpm" desktop_file="/usr/share/applications/rstudio-R4.desktop" -[[ ! -f "$desktop_file" ]] && exit 1 - -sed -i "s|/opt/R/.*/bin/R|/opt/R/$1/bin/R|" "$desktop_file" +[[ -f "$desktop_file" ]] && \ + sed -i "s|/opt/R/.*/bin/R|/opt/R/$1/bin/R|" "$desktop_file" exit $? \ No newline at end of file