eoeooe commited on
Commit
fbf278f
·
verified ·
1 Parent(s): 012e86e

Create start.sh

Browse files
Files changed (1) hide show
  1. start.sh +39 -0
start.sh ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #!/bin/bash
3
+
4
+ # Configuration from your images
5
+ REPO_ID=
6
+ HF_TOKEN=""
7
+
8
+ echo "--- System Starting ---"
9
+
10
+ #
11
+ echo "Restoring files from $REPO_ID..."
12
+ huggingface-cli download $REPO_ID --local-dir /home/user/storage --repo-type dataset --token $HF_TOKEN
13
+
14
+ #
15
+ cat <<EOF > /home/user/auto_backup.sh
16
+ #!/bin/bash
17
+ while true; do
18
+ sleep 300
19
+ echo "Backing up data to Hugging Face..."
20
+ huggingface-cli upload $REPO_ID /home/user/storage . --repo-type=dataset --token=$HF_TOKEN
21
+ done
22
+ EOF
23
+ chmod +x /home/user/auto_backup.sh
24
+ ./auto_backup.sh &
25
+
26
+ #
27
+ cat <<EOF > /home/user/final_backup.sh
28
+ #!/bin/bash
29
+ #
30
+ sleep 172200
31
+ echo "Hugging Face is about to restart soon. Taking final backup..."
32
+ huggingface-cli upload $REPO_ID /home/user/storage . --repo-type=dataset --token=$HF_TOKEN
33
+ EOF
34
+ chmod +x /home/user/final_backup.sh
35
+ ./final_backup.sh &
36
+
37
+ # เงช.
38
+ echo "--- System is Ready. Access via Web Terminal ---"
39
+ ttyd -p 7860 -W bash