Files
hartman-server/script-system-update-r
2022-01-02 22:41:06 -05:00

30 lines
804 B
Bash
Executable File

#!/usr/bin/env bash
# Update the R binaries and RStudio-R4 application meny entry
# $1: Version number ex. '2021.09.1-372'
# Copyright 2021 Bryan C. Roessler
parent="${BASH_SOURCE[0]}"
parent=${parent%/*}
[[ -f "$parent"/functions ]] && . "$parent"/functions || exit 1
is_root
if [[ $# -ne 1 ]]; then
echo "Missing R version argument."
echo "Example: '2021.09.1-372'"
exit 1
fi
ask_ok "RStudio-R4 to version $1?" || 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"
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"
exit $?