Skip to content

Commit

Permalink
[rstudio]Fix for Debian 10 backports repo issue. (#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-cs committed Apr 22, 2024
1 parent 7adc5cb commit c9ff5be
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion rstudio/rstudio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ fi
RSTUDIO_SERVER_PACKAGE=rstudio-server-${RSTUDIO_SERVER_VERSION}-amd64.deb
RSTUDIO_SERVER_PACKAGE_URI=${RSTUDIO_SERVER_URL}/${RSTUDIO_SERVER_PACKAGE}

# Detect dataproc image version from its various names
if (! test -v DATAPROC_IMAGE_VERSION) && test -v DATAPROC_VERSION; then
DATAPROC_IMAGE_VERSION="${DATAPROC_VERSION}"
fi

function remove_old_backports {
# This script uses 'apt-get update' and is therefore potentially dependent on
# backports repositories which have been archived. In order to mitigate this
# problem, we will remove any reference to backports repos older than oldstable

# https://github.com/GoogleCloudDataproc/initialization-actions/issues/1157
oldstable=$(curl -s https://deb.debian.org/debian/dists/oldstable/Release | awk '/^Codename/ {print $2}');
stable=$(curl -s https://deb.debian.org/debian/dists/stable/Release | awk '/^Codename/ {print $2}');

matched_files="$(grep -rsil '\-backports' /etc/apt/sources.list*)"
if [[ -n "$matched_files" ]]; then
for filename in "$matched_files"; do
grep -e "$oldstable-backports" -e "$stable-backports" "$filename" || \
sed -i -e 's/^.*-backports.*$//' "$filename"
done
fi
}

function update_apt_get() {
for ((i = 0; i < 10; i++)); do
Expand Down Expand Up @@ -82,6 +104,9 @@ function run_with_retries() {
}

if [[ "${ROLE}" == 'Master' ]]; then
if [[ ${OS_ID} == debian ]] && [[ $(echo "${DATAPROC_IMAGE_VERSION} <= 2.1" | bc -l) == 1 ]]; then
remove_old_backports
fi
if [[ -n ${USER_PASSWORD} ]] && ((${#USER_PASSWORD} < 7)); then
echo "You must specify a password of at least 7 characters for user '$USER_NAME' through metadata 'rstudio-password'."
exit 1
Expand All @@ -97,7 +122,7 @@ if [[ "${ROLE}" == 'Master' ]]; then

# Install RStudio Server
REPOSITORY_KEY=95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7
run_with_retries apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ${REPOSITORY_KEY}
run_with_retries apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys ${REPOSITORY_KEY}
# https://cran.r-project.org/bin/linux/ubuntu/
if [[ "${OS_ID}" == "ubuntu" ]]; then
curl -fsSL --retry-connrefused --retry 10 --retry-max-time 30 https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
Expand Down

0 comments on commit c9ff5be

Please sign in to comment.