Fix R update script

This commit is contained in:
2022-01-02 23:38:29 -05:00
parent e2420ffe3d
commit 8fd5ad4f46
2 changed files with 24 additions and 13 deletions

View File

@@ -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

View File

@@ -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
[[ -f "$desktop_file" ]] && \
sed -i "s|/opt/R/.*/bin/R|/opt/R/$1/bin/R|" "$desktop_file"
exit $?