Harry8654 commited on
Commit
c6555f1
·
verified ·
1 Parent(s): 0fd4a2e

Create start.sh

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