abc1181 commited on
Commit
99f659f
·
verified ·
1 Parent(s): d7efe47

Update start_server.sh

Browse files
Files changed (1) hide show
  1. start_server.sh +26 -9
start_server.sh CHANGED
@@ -1,20 +1,37 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- # 1. Move to the root workspace
5
- cd /root/app
 
 
 
6
 
7
- # 2. Start your dataset sync in the root context
8
- # Ensure scripts/sync_hf.py uses /root/app/data
9
- python3 scripts/sync_hf.py --path /root/app/data &
10
 
11
- # 3. Setup Nginx (running as root)
 
 
 
 
 
 
 
 
12
  nginx -c /root/app/nginx.conf
13
 
14
- # 4. Launch VS Code forced into /root
15
- # --user-data-dir and --extensions-dir are key to avoiding /home/user
 
 
 
 
 
16
  vscode="/opt/openvscode-server/bin/openvscode-server"
17
 
 
18
  exec $vscode \
19
  --host 0.0.0.0 \
20
  --port 5050 \
@@ -22,4 +39,4 @@ exec $vscode \
22
  --working-dir / \
23
  --user-data-dir /root/.vscode-server \
24
  --extensions-dir /root/.vscode-server/extensions \
25
- "${@}"
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ # 1. Configuration for Username/Password
5
+ # These will default to admin/admin if you don't set them in HF Space Secrets
6
+ NGX_NAME="${NGX_NAME:-admin}"
7
+ NGX_PASS="${NGX_PASS:-admin}"
8
+ PORT="${PORT:-7860}" # HF default port
9
 
10
+ # Generate the htpasswd file for Nginx in the root app folder
11
+ CRYPTPASS=$(openssl passwd -apr1 "${NGX_PASS}")
12
+ echo "${NGX_NAME}:${CRYPTPASS}" > /root/app/ngpasswd
13
 
14
+ echo "Login configured as: $NGX_NAME"
15
+
16
+ # 2. Fix Nginx Config Paths
17
+ # We assume nginx.conf is in /root/app/
18
+ COMMIT=$(cat /opt/openvscode-server/product.json | jq -r .commit)
19
+ sed -i "s/#COMMIT#/$COMMIT/g" /root/app/nginx.conf
20
+ sed -i "s/#PORT#/$PORT/g" /root/app/nginx.conf
21
+
22
+ # Start Nginx as root (since we called this script with sudo)
23
  nginx -c /root/app/nginx.conf
24
 
25
+ # 3. Dataset Sync (Background)
26
+ # Pointing specifically to the root-level data folder
27
+ echo "Starting HF dataset sync to /root/app/data..."
28
+ python3 /root/app/scripts/sync_hf.py --destination /root/app/data &
29
+
30
+ # 4. Launch VS Code Server
31
+ # Forced to /root for everything
32
  vscode="/opt/openvscode-server/bin/openvscode-server"
33
 
34
+ echo "Launching VSCode with Absolute Root access..."
35
  exec $vscode \
36
  --host 0.0.0.0 \
37
  --port 5050 \
 
39
  --working-dir / \
40
  --user-data-dir /root/.vscode-server \
41
  --extensions-dir /root/.vscode-server/extensions \
42
+ "${@}"