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