|
11 | 11 | # - CODE_SERVER_DATAROOT: The data root to use for code server and the extensions. |
12 | 12 | # If not set, the default by code-server will be used. |
13 | 13 | # - CODE_SERVER_SKIP_EXTENSIONS: Set to anything to skip the install of extensions |
| 14 | +# - UNSET_APPTAINER_VARS: Set to anything to unset APPTAINER/SINGULARITY vars |
14 | 15 |
|
15 | 16 | set -e |
16 | 17 |
|
17 | 18 | # The port to run on, auto set to 8080 |
18 | | -CODE_SERVER_PORT=${CODE_SERVER_PORT:-8080} |
| 19 | +PORT=${CODE_SERVER_PORT:-8080} |
| 20 | +unset CODE_SERVER_PORT |
19 | 21 |
|
20 | 22 | # The password to connect with, if one is not provided (randomly generated) |
| 23 | +PASSWORD= |
21 | 24 | if [ -z "$CODE_SERVER_PASSWORD" ]; then |
22 | | - export PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 24) |
| 25 | + PASSWORD="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 24)" |
23 | 26 | # Password was provided, so don't show it |
24 | 27 | else |
25 | | - export PASSWORD="${CODE_SERVER_PASSWORD}" |
| 28 | + PASSWORD="${CODE_SERVER_PASSWORD}" |
26 | 29 | fi |
| 30 | +export PASSWORD |
27 | 31 |
|
28 | 32 | # Create the dataroot if it doesn't exist + the extensions |
29 | 33 | if [ -n "$CODE_SERVER_DATAROOT" ]; then |
|
40 | 44 | # Install the extensions, unless requested not to |
41 | 45 | if [ -z "$CODE_SERVER_SKIP_EXTENSIONS" ]; then |
42 | 46 | /opt/code-server/bin/code-server-setup-extensions "${CODE_SERVER_ARGS[@]}" |
| 47 | +else |
| 48 | + unset CODE_SERVER_SKIP_EXTENSIONS |
43 | 49 | fi |
44 | 50 |
|
45 | 51 | # Pass the dataroot if its set |
46 | 52 | if [ -n "$CODE_SERVER_DATAROOT" ]; then |
47 | 53 | CODE_SERVER_ARGS+=("--user-data-dir=${CODE_SERVER_DATAROOT}") |
48 | 54 | fi |
| 55 | +unset CODE_SERVER_DATAROOT |
49 | 56 |
|
50 | 57 | # Expose the password to the user if we set it |
51 | 58 | if [ -z "$CODE_SERVER_PASSWORD" ]; then |
52 | 59 | GREEN='\033[0;32m' |
53 | 60 | NC='\033[0m' |
54 | | - printf "${GREEN}Connect to the instance at http://localhost:${CODE_SERVER_PORT} with password ${PASSWORD}${NC}\n" |
| 61 | + printf "${GREEN}Connect to the instance at http://localhost:${PORT} with password ${PASSWORD}${NC}\n" |
| 62 | +else |
| 63 | + unset CODE_SERVER_PASSWORD |
| 64 | +fi |
| 65 | + |
| 66 | +if [ -n "$UNSET_APPTAINER_VARS" ]; then |
| 67 | + unset "${!APPTAINER@}" "${!SINGULARITY@}" UNSET_APPTAINER_VARS |
55 | 68 | fi |
56 | 69 |
|
57 | 70 | # Run the server |
58 | 71 | code-server --auth=password \ |
59 | | - --bind-addr=0.0.0.0:"${CODE_SERVER_PORT}" \ |
| 72 | + --bind-addr=0.0.0.0:"${PORT}" \ |
60 | 73 | --disable-telemetry \ |
61 | 74 | --disable-getting-started-override \ |
62 | 75 | --disable-update-check \ |
|
0 commit comments