-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnullclaw
More file actions
60 lines (58 loc) · 1.6 KB
/
nullclaw
File metadata and controls
60 lines (58 loc) · 1.6 KB
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
57
58
59
60
#!/bin/sh
set -eu
cmd="${1:-run}"
case "$cmd" in
run)
# Minimal health endpoint expected by the nullclaw driver.
mkdir -p /tmp/nullclaw-spike
printf "ok\n" >/tmp/nullclaw-spike/health
exec python3 -m http.server 3000 --directory /tmp/nullclaw-spike
;;
cron)
sub="${2:-}"
case "$sub" in
list)
jobs_file=/tmp/nullclaw-spike/cron.jobs
count=0
if [ -f "$jobs_file" ]; then
count="$(wc -l <"$jobs_file" | tr -d ' ')"
fi
echo "info(cron): Scheduled jobs (${count}):"
if [ -f "$jobs_file" ]; then
i=0
while IFS="$(printf '\t')" read -r expr command; do
[ -n "${expr:-}" ] || continue
i=$((i + 1))
echo "info(cron): - job-${i} | ${expr} | next=0 | status=n/a cmd: ${command}"
done <"$jobs_file"
fi
;;
add)
if [ "$#" -lt 4 ]; then
echo "error: usage: nullclaw cron add '<schedule>' '<command>'" >&2
exit 2
fi
mkdir -p /tmp/nullclaw-spike
printf "%s\t%s\n" "$3" "$4" >>/tmp/nullclaw-spike/cron.jobs
echo "info(cron): added schedule '$3'"
;;
*)
echo "error: unknown nullclaw cron subcommand '$sub'" >&2
exit 2
;;
esac
;;
agent)
# Spike stub accepts agent invocations so PostApply cron wiring can call it.
if [ "${2:-}" = "-m" ]; then
echo "nullclaw agent: ${3:-}"
exit 0
fi
echo "error: usage: nullclaw agent -m <message>" >&2
exit 2
;;
*)
echo "error: unknown nullclaw subcommand '$cmd'" >&2
exit 2
;;
esac