spark-connector
aien-dev/spark-connector
Brought by drakestapleton
spark-connector / runner / joingen.om
| 1 | note runner/joingen.om -- writes the join script (dist/join.sh) the hub serves at /community/join. |
| 2 | note argv: hub URL, sha256 of interplane-runner, sha256 of omc. The script only downloads the two |
| 3 | note files by their hashes, checks the hashes, prints them with where to compare them, and runs |
| 4 | note `interplane-runner join`, which explains what it will do and asks before anything is registered. |
| 5 | note On a computer that is not Linux on aarch64 it says so and installs nothing. |
| 6 | text jgusage "usage: joingen HUB RUNNER_SHA256 OMC_SHA256\n" |
| 7 | text jg1 "#!/bin/sh\n# Interplane runner: join this computer to Interplane's community machines.\n# Read it first. Generated by spark-connector runner/joingen.om (rad:z2LKDxnAK3EFfqgr7HTZh6djts65P).\n# It downloads two files, checks their SHA-256, and starts `interplane-runner join`, which explains\n# what it will do and asks for a yes before anything is registered.\nset -eu\nhub='" |
| 8 | text jg2 "'\nd=\"$HOME/.interplane-runner\"\nif [ \"$(uname -s)\" != Linux ] || [ \"$(uname -m)\" != aarch64 ]; then\n echo \"The Interplane runner needs Linux on 64-bit ARM (aarch64), like an NVIDIA DGX Spark. This computer is $(uname -s) $(uname -m). Nothing was installed.\"\n exit 1\nfi\nif [ -e \"$d/key\" ]; then exec \"$d/bin/interplane-runner\" status; fi\nmkdir -p \"$d/bin\"\nchmod 700 \"$d\"\nget() {\n if curl -fsSL -o \"$d/bin/$1.part\" \"$hub/community/dl/$1-$2\" && [ \"$(sha256sum < \"$d/bin/$1.part\" | cut -d' ' -f1)\" = \"$2\" ]; then\n chmod 700 \"$d/bin/$1.part\"; mv \"$d/bin/$1.part\" \"$d/bin/$1\"\n else\n rm -rf \"$d\"; echo \"The download of $1 failed or its SHA-256 was not $2. Nothing was installed.\"; exit 1\n fi\n}\nget interplane-runner " |
| 9 | text jg3 "\nget omc " |
| 10 | text jg4 "\necho \"Downloaded and checked:\"\necho \" interplane-runner sha256 " |
| 11 | text jg5 "\"\necho \" omc sha256 " |
| 12 | text jg6 "\"\necho \"Compare them with $hub/community/ (Files and fingerprints) and with SHA256SUMS in the\"\necho \"runner's source, rad:z2LKDxnAK3EFfqgr7HTZh6djts65P.\"\nif (exec < /dev/tty) 2> /dev/null; then exec \"$d/bin/interplane-runner\" join \"$hub\" < /dev/tty; fi\nexec \"$d/bin/interplane-runner\" join \"$hub\"\n" |
| 13 | |
| 14 | fn jg_ok s view uchar * hex bool to bool |
| 15 | if or eq len s 0 gt len s 300 |
| 16 | ret false |
| 17 | end |
| 18 | for i ulong len s bound 512 |
| 19 | c = get s i |
| 20 | lo = or and ge c 97 le c 122 and ge c 48 le c 57 |
| 21 | if hex |
| 22 | if not and lo not and ge c 103 le c 122 |
| 23 | ret false |
| 24 | end |
| 25 | else |
| 26 | if not or lo or or eq c 46 eq c 45 or eq c 58 eq c 47 |
| 27 | ret false |
| 28 | end |
| 29 | end |
| 30 | end |
| 31 | ret true |
| 32 | end |
| 33 | |
| 34 | fn main to int |
| 35 | h = new uchar 512 0 |
| 36 | r = new uchar 80 0 |
| 37 | o = new uchar 80 0 |
| 38 | if ne argcnt 4 |
| 39 | w = write 2 jgusage 0 len jgusage |
| 40 | ret 2 |
| 41 | end |
| 42 | hn = argread 1 h 0 400 |
| 43 | rn = argread 2 r 0 80 |
| 44 | on = argread 3 o 0 80 |
| 45 | if or or le hn 0 ne rn 64 ne on 64 |
| 46 | ret 2 |
| 47 | end |
| 48 | if not and jg_ok part h 0 ulong hn false and jg_ok part r 0 64 true jg_ok part o 0 64 true |
| 49 | ret 2 |
| 50 | end |
| 51 | w = write 1 jg1 0 len jg1 |
| 52 | w = write 1 h 0 ulong hn |
| 53 | w = write 1 jg2 0 len jg2 |
| 54 | w = write 1 r 0 64 |
| 55 | w = write 1 jg3 0 len jg3 |
| 56 | w = write 1 o 0 64 |
| 57 | w = write 1 jg4 0 len jg4 |
| 58 | w = write 1 r 0 64 |
| 59 | w = write 1 jg5 0 len jg5 |
| 60 | w = write 1 o 0 64 |
| 61 | w = write 1 jg6 0 len jg6 |
| 62 | ret 0 |
| 63 | end |