@@ -4,6 +4,34 @@ EXTENSIONS=("${EXTENSIONS}")
4
4
BOLD=' \033[0;1m'
5
5
CODE=' \033[36;40;1m'
6
6
RESET=' \033[0m'
7
+ CODE_SERVER=" ${INSTALL_PREFIX} /bin/code-server"
8
+
9
+ function run_code_server() {
10
+ echo " 👷 Running code-server in the background..."
11
+ echo " Check logs at ${LOG_PATH} !"
12
+ $CODE_SERVER --auth none --port " ${PORT} " --app-name " ${APP_NAME} " > " ${LOG_PATH} " 2>&1 &
13
+ }
14
+
15
+ # Check if the settings file exists...
16
+ if [ ! -f ~ /.local/share/code-server/User/settings.json ]; then
17
+ echo " ⚙️ Creating settings file..."
18
+ mkdir -p ~ /.local/share/code-server/User
19
+ echo " ${SETTINGS} " > ~ /.local/share/code-server/User/settings.json
20
+ fi
21
+
22
+ # Check if code-server is already installed for offline or cached mode
23
+ if [ -f " $CODE_SERVER " ]; then
24
+ if [ " ${OFFLINE} " = true ] || [ " ${USE_CACHED} " = true ]; then
25
+ echo " 🥳 Found a copy of code-server"
26
+ run_code_server
27
+ exit 0
28
+ fi
29
+ fi
30
+ # Offline mode always expects a copy of code-server to be present
31
+ if [ " ${OFFLINE} " = true ]; then
32
+ echo " Failed to find a copy of code-server"
33
+ exit 1
34
+ fi
7
35
8
36
printf " $$ {BOLD}Installing code-server!\n"
9
37
@@ -22,8 +50,6 @@ if [ $? -ne 0 ]; then
22
50
fi
23
51
printf " 🥳 code-server has been installed in ${INSTALL_PREFIX} \n\n"
24
52
25
- CODE_SERVER=" ${INSTALL_PREFIX} /bin/code-server"
26
-
27
53
# Install each extension...
28
54
IFS=' ,' read -r -a EXTENSIONLIST <<< " $${EXTENSIONS}"
29
55
for extension in " $$ {EXTENSIONLIST[@]}" ; do
@@ -38,13 +64,4 @@ for extension in "$${EXTENSIONLIST[@]}"; do
38
64
fi
39
65
done
40
66
41
- # Check if the settings file exists...
42
- if [ ! -f ~ /.local/share/code-server/User/settings.json ]; then
43
- echo " ⚙️ Creating settings file..."
44
- mkdir -p ~ /.local/share/code-server/User
45
- echo " ${SETTINGS} " > ~ /.local/share/code-server/User/settings.json
46
- fi
47
-
48
- echo " 👷 Running code-server in the background..."
49
- echo " Check logs at ${LOG_PATH} !"
50
- $CODE_SERVER --auth none --port ${PORT} --app-name " ${APP_NAME} " > ${LOG_PATH} 2>&1 &
67
+ run_code_server
0 commit comments