#!/bin/bash set -u # Requirement: sudo # -------------- # Utils function abort() { printf "%s\n" "$@" exit 1 } # string formatters if [[ -t 1 ]]; then tty_escape() { printf "\033[%sm" "$1"; } else tty_escape() { :; } fi tty_mkbold() { tty_escape "1;$1"; } tty_underline="$(tty_escape "4;39")" tty_blue="$(tty_mkbold 34)" tty_red="$(tty_mkbold 31)" tty_bold="$(tty_mkbold 39)" tty_reset="$(tty_escape 0)" shell_join() { local arg printf "%s" "$1" shift for arg in "$@"; do printf " " printf "%s" "${arg// /\ }" done } chomp() { printf "%s" "${1/"$'\n'"/}" } ohai() { printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" } have_sudo_access() { local -a args if [[ -n "${SUDO_ASKPASS-}" ]]; then args=("-A") elif [[ -n "${NONINTERACTIVE-}" ]]; then args=("-n") fi if [[ -z "${HAVE_SUDO_ACCESS-}" ]]; then if [[ -n "${args[*]-}" ]]; then SUDO="/usr/bin/sudo ${args[*]}" else SUDO="/usr/bin/sudo" fi if [[ -n "${NONINTERACTIVE-}" ]]; then ${SUDO} -l mkdir &>/dev/null else ${SUDO} -v && ${SUDO} -l mkdir &>/dev/null fi HAVE_SUDO_ACCESS="$?" fi if [[ -z "${HOMEBREW_ON_LINUX-}" ]] && [[ "$HAVE_SUDO_ACCESS" -ne 0 ]]; then abort "Need sudo access on macOS (e.g. the user $USER needs to be an Administrator)!" fi return "$HAVE_SUDO_ACCESS" } execute() { if ! "$@"; then abort "$(printf "Failed during: %s" "$(shell_join "$@")")" fi } execute_sudo() { local -a args=("$@") if have_sudo_access; then if [[ -n "${SUDO_ASKPASS-}" ]]; then args=("-A" "${args[@]}") fi ohai "/usr/bin/sudo" "${args[@]}" execute "/usr/bin/sudo" "${args[@]}" else ohai "${args[@]}" execute "${args[@]}" fi } echo "Please enter your password. " have_sudo_access true # -------------- # Installations #--- Install R execute_sudo apt update -qq # install two helper packages we need execute_sudo apt install --no-install-recommends software-properties-common dirmngr # import the signing key (by Michael Rutter) for these repo execute_sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 # add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed execute_sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" execute_sudo apt update -qq execute_sudo apt install -y \ build-essential \ file \ git \ curl \ libsodium-dev \ libffi-dev \ libbz2-dev \ libpcre2-dev \ libcairo2-dev \ libcurl4-openssl-dev \ libfftw3-dev \ libfreetype6-dev \ libfribidi-dev \ libgit2-dev \ libhdf5-dev \ libharfbuzz-dev \ libjpeg-dev \ libpng-dev \ libssl-dev \ libssh2-1-dev \ libtiff5-dev \ libv8-dev \ libxml2-dev \ psmisc \ procps \ sudo \ wget \ zlib1g-dev \ r-base r-base-dev #--- Install RStudio (TODO) # Install RAVE execute /usr/bin/env Rscript --no-save -e "$(curl -fsSL https://raw.githubusercontent.com/dipterix/instrave/master/brew/install-rave.R)"