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

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