Skip to content

Commit

Permalink
Unset unused variables
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour committed Feb 14, 2025
1 parent c67bf30 commit a998932
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions apptainer/files/moose-dev/opt/code-server/bin/code-server-start
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
set -e

# The port to run on, auto set to 8080
CODE_SERVER_PORT=${CODE_SERVER_PORT:-8080}
PORT=${CODE_SERVER_PORT:-8080}
unset CODE_SERVER_PORT

# The password to connect with, if one is not provided (randomly generated)
PASSWORD=
if [ -z "$CODE_SERVER_PASSWORD" ]; then
export PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 24)
PASSWORD="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 24)"
# Password was provided, so don't show it
else
export PASSWORD="${CODE_SERVER_PASSWORD}"
PASSWORD="${CODE_SERVER_PASSWORD}"
fi
export PASSWORD

# Create the dataroot if it doesn't exist + the extensions
if [ -n "$CODE_SERVER_DATAROOT" ]; then
Expand All @@ -41,27 +44,32 @@ fi
# Install the extensions, unless requested not to
if [ -z "$CODE_SERVER_SKIP_EXTENSIONS" ]; then
/opt/code-server/bin/code-server-setup-extensions "${CODE_SERVER_ARGS[@]}"
else
unset CODE_SERVER_SKIP_EXTENSIONS
fi

# Pass the dataroot if its set
if [ -n "$CODE_SERVER_DATAROOT" ]; then
CODE_SERVER_ARGS+=("--user-data-dir=${CODE_SERVER_DATAROOT}")
fi
unset CODE_SERVER_DATAROOT

# Expose the password to the user if we set it
if [ -z "$CODE_SERVER_PASSWORD" ]; then
GREEN='\033[0;32m'
NC='\033[0m'
printf "${GREEN}Connect to the instance at http://localhost:${CODE_SERVER_PORT} with password ${PASSWORD}${NC}\n"
printf "${GREEN}Connect to the instance at http://localhost:${PORT} with password ${PASSWORD}${NC}\n"
else
unset CODE_SERVER_PASSWORD
fi

if [ -n "$UNSET_APPTAINER_VARS" ]; then
unset "${!APPTAINER@}" "${!SINGULARITY@}"
unset "${!APPTAINER@}" "${!SINGULARITY@}" UNSET_APPTAINER_VARS
fi

# Run the server
code-server --auth=password \
--bind-addr=0.0.0.0:"${CODE_SERVER_PORT}" \
--bind-addr=0.0.0.0:"${PORT}" \
--disable-telemetry \
--disable-getting-started-override \
--disable-update-check \
Expand Down

0 comments on commit a998932

Please sign in to comment.