@@ -13,60 +13,67 @@ if [ ! -f "/opt/app-root/src/.bashrc" ]; then
13
13
echo ' PS1="\[\033[34;1m\][\$(pwd)]\[\033[0m\]\n\[\033[1;0m\]$ \[\033[0m\]"' > /opt/app-root/src/.bashrc
14
14
fi
15
15
16
- # Initilize access logs for culling
16
+ # Initialize access logs for culling
17
17
echo ' [{"id":"code-server","name":"code-server","last_activity":"' $( date -Iseconds) ' ","execution_state":"running","connections":1}]' > /var/log/nginx/codeserver.access.log
18
18
19
- # Add "/opt/app-root/src/.vscode/" directory to set default interpreter also for Run & Debug
20
- user_dir=" /opt/app-root/src/.vscode/"
21
- settings_filepath=" ${user_dir} settings.json"
22
- launch_filepath=" ${user_dir} launch.json"
19
+ # Function to create directories and files if they do not exist
20
+ create_dir_and_file () {
21
+ local dir=$1
22
+ local filepath=$2
23
+ local content=$3
23
24
24
- json_launch_settings=' {
25
- // Use IntelliSense to learn about possible attributes.
26
- // Hover to view descriptions of existing attributes.
27
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
28
- "version": "0.2.0",
29
- "configurations": [
30
- {
31
- "name": "Python Debugger: Current File",
32
- "type": "debugpy",
33
- "request": "launch",
34
- "program": "${file}",
35
- "console": "integratedTerminal",
36
- "python": "/opt/app-root/bin/python3"
37
- }
38
- ]
25
+ if [ ! -d " $dir " ]; then
26
+ echo " Debug: Directory not found, creating '$dir '..."
27
+ mkdir -p " $dir "
28
+ echo " $content " > " $filepath "
29
+ echo " Debug: '$filepath ' file created."
30
+ else
31
+ echo " Debug: Directory already exists."
32
+ if [ ! -f " $filepath " ]; then
33
+ echo " Debug: '$filepath ' file not found, creating..."
34
+ echo " $content " > " $filepath "
35
+ echo " Debug: '$filepath ' file created."
36
+ else
37
+ echo " Debug: '$filepath ' file already exists."
38
+ fi
39
+ fi
40
+ }
41
+
42
+ # Define universal settings
43
+ universal_dir=" /opt/app-root/src/.local/share/code-server/User/"
44
+ user_settings_filepath=" ${universal_dir} settings.json"
45
+ universal_json_settings=' {
46
+ "python.defaultInterpreterPath": "/opt/app-root/bin/python3",
47
+ "telemetry.telemetryLevel": "off",
48
+ "telemetry.enableTelemetry": false,
49
+ "workbench.enableExperiments": false
39
50
}'
40
51
52
+ # Define python debuger settings
53
+ vscode_dir=" /opt/app-root/src/.vscode/"
54
+ settings_filepath=" ${vscode_dir} settings.json"
55
+ launch_filepath=" ${vscode_dir} launch.json"
56
+ json_launch_settings=' {
57
+ "version": "0.2.0",
58
+ "configurations": [
59
+ {
60
+ "name": "Python Debugger: Current File",
61
+ "type": "debugpy",
62
+ "request": "launch",
63
+ "program": "${file}",
64
+ "console": "integratedTerminal",
65
+ "python": "/opt/app-root/bin/python3"
66
+ }
67
+ ]
68
+ }'
41
69
json_settings=' {
42
70
"python.defaultInterpreterPath": "/opt/app-root/bin/python3"
43
- }'
44
-
45
- # Check if User directory exists
46
- if [ ! -d " $user_dir " ]; then
47
- echo " Debug: User directory not found, creating '$user_dir '..."
48
- mkdir -p " $user_dir "
49
- echo " $json_launch_settings " > " $launch_filepath "
50
- echo " Debug: '$launch_filepath ' file created."
51
- echo " $json_settings " > " $settings_filepath "
52
- echo " Debug: '$settings_filepath ' file created."
53
- else
54
- echo " Debug: User directory already exists."
55
- # Add settings.json and launch.json if not present
56
- if [ ! -f " $launch_filepath " ]; then
57
- echo " Debug: '$launch_filepath ' file not found, creating..."
58
- echo " $json_launch_settings " > " $launch_filepath "
59
- echo " Debug: '$launch_filepath ' file created."
60
- elif [ ! -f " $settings_filepath " ]; then
61
- echo " Debug: '$settings_filepath ' file not found, creating..."
62
- echo " $json_settings " > " $settings_filepath "
63
- echo " Debug: '$settings_filepath ' file created."
64
- else
65
- echo " Debug: '$launch_filepath ' file already exists."
66
- echo " Debug: '$settings_filepath ' file already exists."
71
+ }'
67
72
68
- fi
69
- fi
73
+ # Create necessary directories and files for python debuger and universal settings
74
+ create_dir_and_file " $universal_dir " " $user_settings_filepath " " $universal_json_settings "
75
+ create_dir_and_file " $vscode_dir " " $settings_filepath " " $json_settings "
76
+ create_dir_and_file " $vscode_dir " " $launch_filepath " " $json_launch_settings "
70
77
71
78
# Ensure the extensions directory exists
72
79
extensions_dir=" /opt/app-root/src/.local/share/code-server/extensions"
0 commit comments