PYAE1994 commited on
Commit
b422b4b
·
verified ·
1 Parent(s): 81989c9

Update start_server.sh

Browse files
Files changed (1) hide show
  1. start_server.sh +30 -22
start_server.sh CHANGED
@@ -1,41 +1,49 @@
1
  #!/bin/bash
2
 
 
 
 
 
 
 
 
3
  NGX_NAME="${NGX_NAME:-admin}"
4
  NGX_PASS="${NGX_PASS:-admin}"
5
- CRYPTPASS=`openssl passwd -apr1 ${NGX_PASS}`
6
- PORT="${PORT:-8080}"
7
-
8
- echo "USERNAME:" $NGX_NAME
9
- echo "PASSWORD:" $NGX_PASS
10
 
11
  echo "${NGX_NAME}:${CRYPTPASS}" > ngpasswd
12
 
 
 
 
13
  COMMIT=$(cat /app/openvscode-server/product.json | awk '/commit/{print $4;exit}' FS='[""]')
 
14
  sed -i "s/#COMMIT#/$COMMIT/" nginx.conf
15
- sed -i "s/#PORT#/$PORT/" nginx.conf
 
16
  nginx -c $PWD/nginx.conf
17
 
18
- set +e
 
 
19
  if [[ ! -z "$REPO" ]]; then
20
- dir=$(basename "$REPO" .git)
21
- echo start to clone initial repo $REPO into $dir
22
- git clone --progress $REPO $dir
23
- cd $dir
24
- git config --global user.name "$(git log -1 --pretty=format:'%an')"
25
- git config --global user.email "$(git log -1 --pretty=format:'%ae')"
26
- cd ..
27
- else
28
- git config --global user.name "$SPACE_AUTHOR_NAME"
29
- git config --global user.email "$SPACE_AUTHOR_NAME@hf.co"
30
  fi
31
 
32
  git config --global http.postBuffer 524288000
33
 
34
- echo "Starting VSCode Server..."
 
 
35
  vscode=/app/openvscode-server/bin/openvscode-server
36
- vscode_cli=/app/openvscode-server/bin/remote-cli/openvscode-server
37
  $vscode --install-extension ms-toolsai.jupyter
38
  $vscode --install-extension ms-python.python
39
- ln -s $vscode_cli $(dirname $vscode_cli)/code
40
- set -e
41
- exec $vscode --host 0.0.0.0 --port 5050 --without-connection-token \"${@}\" --
 
 
 
 
 
1
  #!/bin/bash
2
 
3
+ set -e
4
+
5
+ echo "🚀 Starting VSCode AI Space..."
6
+
7
+ # ========================
8
+ # Auth
9
+ # ========================
10
  NGX_NAME="${NGX_NAME:-admin}"
11
  NGX_PASS="${NGX_PASS:-admin}"
12
+ CRYPTPASS=$(openssl passwd -apr1 ${NGX_PASS})
 
 
 
 
13
 
14
  echo "${NGX_NAME}:${CRYPTPASS}" > ngpasswd
15
 
16
+ # ========================
17
+ # nginx config
18
+ # ========================
19
  COMMIT=$(cat /app/openvscode-server/product.json | awk '/commit/{print $4;exit}' FS='[""]')
20
+
21
  sed -i "s/#COMMIT#/$COMMIT/" nginx.conf
22
+ sed -i "s/#PORT#/${PORT:-8080}/" nginx.conf
23
+
24
  nginx -c $PWD/nginx.conf
25
 
26
+ # ========================
27
+ # Repo clone
28
+ # ========================
29
  if [[ ! -z "$REPO" ]]; then
30
+ dir=$(basename "$REPO" .git)
31
+ git clone $REPO $dir
 
 
 
 
 
 
 
 
32
  fi
33
 
34
  git config --global http.postBuffer 524288000
35
 
36
+ # ========================
37
+ # VSCode Server
38
+ # ========================
39
  vscode=/app/openvscode-server/bin/openvscode-server
40
+
41
  $vscode --install-extension ms-toolsai.jupyter
42
  $vscode --install-extension ms-python.python
43
+
44
+ echo "✅ Starting VSCode..."
45
+
46
+ exec $vscode \
47
+ --host 0.0.0.0 \
48
+ --port 5050 \
49
+ --without-connection-token