singh-monish commited on
Commit
20f7d8a
·
verified ·
1 Parent(s): 3e20ee4

Upload setup_project_alpha.sh

Browse files
Files changed (1) hide show
  1. setup_project_alpha.sh +55 -0
setup_project_alpha.sh ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # This setup script is intended to be executed as root via:
5
+ # echo 'password' | sudo -S /tmp/setup_project_alpha.sh
6
+ #
7
+ # It prepares the environment for OSWorld-SFT/evaluation_examples/examples/os/task2.json
8
+
9
+ TARGET_DIR="/home/user/dev/project_alpha"
10
+ LOG_DIR="$TARGET_DIR/logs"
11
+ DEPLOY="$TARGET_DIR/deploy.sh"
12
+
13
+ mkdir -p "$LOG_DIR"
14
+
15
+ # Ensure "developers" group exists and user is a member (so chgrp can succeed without sudo after newgrp).
16
+ if ! getent group developers >/dev/null 2>&1; then
17
+ groupadd developers || true
18
+ fi
19
+ usermod -aG developers user || true
20
+
21
+ # Create deploy.sh with deterministic size + mtime but "wrong" perms/group so the task has work to do.
22
+ cat > "$DEPLOY" <<'EOF'
23
+ #!/usr/bin/env bash
24
+ set -euo pipefail
25
+ echo "Deploy placeholder"
26
+ EOF
27
+
28
+ # Pad deploy.sh to exactly 1234 bytes (deterministic size for evaluator checks).
29
+ python3 - <<'PY'
30
+ from pathlib import Path
31
+ p = Path("/home/user/dev/project_alpha/deploy.sh")
32
+ data = p.read_bytes()
33
+ TARGET = 1234
34
+ if len(data) > TARGET:
35
+ raise SystemExit("deploy.sh too large")
36
+ p.write_bytes(data + (b"#" * (TARGET - len(data))))
37
+ PY
38
+
39
+ # Deterministic mtime for evaluator checks.
40
+ touch -d '2001-02-03 04:05:06' "$DEPLOY"
41
+
42
+ # Set starting ownership/perms (task should change group to developers and perms to 754).
43
+ chown user:user "$DEPLOY"
44
+ chmod 700 "$DEPLOY"
45
+
46
+ # Create logs: one recent and one old (>7 days) so cleanup is meaningful.
47
+ printf '%s\n' 'recent log' > "$LOG_DIR/recent.log"
48
+ printf '%s\n' 'old log' > "$LOG_DIR/old.log"
49
+ touch -d '2 days ago' "$LOG_DIR/recent.log"
50
+ touch -d '8 days ago' "$LOG_DIR/old.log"
51
+
52
+ # Ensure ownership for the whole tree.
53
+ chown -R user:user "$TARGET_DIR"
54
+
55
+