Spaces:
Sleeping
Sleeping
Update start_server.sh
Browse files- 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=
|
| 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 |
-
|
|
|
|
|
|
|
| 19 |
if [[ ! -z "$REPO" ]]; then
|
| 20 |
-
|
| 21 |
-
|
| 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 |
-
|
|
|
|
|
|
|
| 35 |
vscode=/app/openvscode-server/bin/openvscode-server
|
| 36 |
-
|
| 37 |
$vscode --install-extension ms-toolsai.jupyter
|
| 38 |
$vscode --install-extension ms-python.python
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|