From 91c0bcbf59cbd5a74001d83a5e2662c14a9c8d79 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Thu, 4 Jul 2024 20:40:47 -0400 Subject: [PATCH] Update rstudio --- opt/cs50/bin/rstudio | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/opt/cs50/bin/rstudio b/opt/cs50/bin/rstudio index d291cafe..a824ac30 100755 --- a/opt/cs50/bin/rstudio +++ b/opt/cs50/bin/rstudio @@ -13,11 +13,11 @@ function spin() { local spinner='|/-\' while [ -d /proc/$pid ]; do for i in $(seq 0 3); do - printf "\rHit CTRL-C to stop the server [%c]\n" "${spinner:$i:1}" - sleep 0.1 + printf "\rHit CTRL-C to stop the server [%c] " "${spinner:$i:1}" + sleep 0.5 done done - printf "\r \r" + printf "\n" } # Check for $1 @@ -33,14 +33,17 @@ if [[ $# -eq 1 ]]; then fi # Check for running image -id=$(docker ps --filter "name=rstudio" --quiet) +id=$(docker ps --all --filter "name=rstudio" --quiet) if [[ -n "$id" ]]; then # Stop current container (so as to restart port forwarding) - docker stop "$id" + docker stop "$id" > /dev/null + + # Try to remove in case created but somehow not started + docker rm "$id" &> /dev/null fi -# Pull image +# Pull latest image docker pull "$IMAGE" # Create container @@ -51,24 +54,24 @@ docker create \ --publish 8787:8787 \ --rm \ --volume "$LOCAL_WORKSPACE_FOLDER":"/workspaces/$RepositoryName" \ - rocker/tidyverse + rocker/tidyverse > /dev/null # Customize rstudio-prefs.json jq ".initial_working_directory = \"/workspaces/$RepositoryName\"" /opt/cs50/lib/rstudio/rstudio-prefs.json > /tmp/rstudio-prefs.json # Copy files into container -docker cp /opt/cs50/lib/rstudio/_icons.css rstudio:/tmp -docker cp /opt/cs50/lib/rstudio/rstudio-server.json rstudio:/etc/rstudio/ -docker cp /tmp/rstudio-prefs.json rstudio:/etc/rstudio/ +docker cp --quiet /opt/cs50/lib/rstudio/_icons.css rstudio:/tmp +docker cp --quiet /opt/cs50/lib/rstudio/rstudio-server.json rstudio:/etc/rstudio/ +docker cp --quiet /tmp/rstudio-prefs.json rstudio:/etc/rstudio/ # Start container -docker start rstudio +docker start rstudio > /dev/null # Inject CSS docker exec rstudio sh -c "cat /tmp/_icons.css >> /usr/lib/rstudio-server/www/css/icons.css" # Attach to container -docker attach rstudio & +docker attach rstudio &> /dev/null & pid=$! # Spin until container stops