diff --git a/buildroot-v86/board/v86/rootfs_overlay/bin/zip b/buildroot-v86/board/v86/rootfs_overlay/bin/zip new file mode 100755 index 0000000..e617945 Binary files /dev/null and b/buildroot-v86/board/v86/rootfs_overlay/bin/zip differ diff --git a/buildroot-v86/board/v86/rootfs_overlay/etc/profile b/buildroot-v86/board/v86/rootfs_overlay/etc/profile index 8a78eb3..43f1b0c 100644 --- a/buildroot-v86/board/v86/rootfs_overlay/etc/profile +++ b/buildroot-v86/board/v86/rootfs_overlay/etc/profile @@ -35,11 +35,12 @@ help_tips(){ echo '----' echo 'text editors ' "type ' '" echo 'programming languages ' "type 'ls ~/bin/helloworld*'" - echo 'run 64bit linux app ' "type 'blink '" + echo 'upload file to xrsh ' "type 'upload '" + echo 'download file locally ' "type 'download '" echo 'paste text ' "ctrl/cmd+shift+v'" echo 'paste text to file ' "ctrl/cmd+v'" echo 'import file to scene ' "drag-drop file or ctrl/cmd+v or type 'upload'" - echo 'import remote URL ' "type 'require '" + echo 'import remote URL ' "type 'require https://xrfragment.org/index.glb'" echo 'reset scene & shell ' "type 'reset'" echo 'js run ' "type 'js 'alert(\"hello\")'" echo 'js console.log: ' "type 'console document.baseURI" @@ -47,7 +48,6 @@ help_tips(){ echo 'js inspect: ' "type 'js \"return document.baseURI\"'" echo 'js capture console: ' "type 'tail -f /dev/browser/console'" echo 'js<->filesystem hooks:' "type 'see [executable] files in ~/hook.d'" - echo 'include file into page' "type 'require '" echo 'say something ' "type 'say hello'" echo '' echo 'type "help" or "man xrsh" to read the full manual' diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/.profile b/buildroot-v86/board/v86/rootfs_overlay/root/.profile index 8a5d88c..73a1eba 100644 --- a/buildroot-v86/board/v86/rootfs_overlay/root/.profile +++ b/buildroot-v86/board/v86/rootfs_overlay/root/.profile @@ -32,19 +32,7 @@ test -f /root/.boot || { touch /root/.boot # make sure we run below once # add menu items https://xrsh.isvery.ninja/#Launcher%20menu - find /root/.config/launcher -type f | while read item; do - js ' - let term = document.querySelector("[isoterminal]").components.isoterminal.term - launcher.register({ - name: "'$(basename $item)'", - cb: () => term.exec("'$item'") - }) - return "'$item'" - ' - done > /tmp/log - - # get latest xrfragments to support interactive models - require https://xrfragment.org/dist/xrfragment.aframe.js + /root/bin/launcher init # start index.js if /dev/browser/js filesize is not great than 0 if [ ! -s /dev/browser/js ]; then diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/bin/launcher b/buildroot-v86/board/v86/rootfs_overlay/root/bin/launcher new file mode 100755 index 0000000..110e5af --- /dev/null +++ b/buildroot-v86/board/v86/rootfs_overlay/root/bin/launcher @@ -0,0 +1,19 @@ +#!/bin/sh + +init(){ + + # add menu items https://xrsh.isvery.ninja/#Launcher%20menu + { find /root/.config/launcher -type f; find /root/.config/launcher -type l; } | while read item; do + js ' + let term = document.querySelector("[isoterminal]").components.isoterminal.term + launcher.register({ + name: "'$(basename $item)'", + cb: () => term.emit("exec",["'$item'"]) + }) + return "'$item'" + ' + done > /tmp/log + +} + +"$@" diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/bin/save b/buildroot-v86/board/v86/rootfs_overlay/root/bin/save index 3398af8..fd10bf3 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/bin/save +++ b/buildroot-v86/board/v86/rootfs_overlay/root/bin/save @@ -4,8 +4,8 @@ source /etc/profile.sh state(){ javascript=' const isoterminal = document.querySelector("[isoterminal]").components.isoterminal.term - isoterminal.save() - return "[OK] xrsh state saved\n" + isoterminal.save({'$1':true}) + return "\n" ' echo "[i] triggering ~/hook.d/save/* scripts" @@ -16,6 +16,9 @@ state(){ exit } -test -z "$1" && state -echo "Usage: save" -echo "it saves VM state to localStorage" +test -n "$1" && state "$1" +test -z "$1" && { + echo "Usage: save [localstorage|remotestorage]" + echo "" + echo "save VM (filesystem) to local (=default) or remotestorage" +} diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/bin/watchfs b/buildroot-v86/board/v86/rootfs_overlay/root/bin/watchfs index 7a25f2a..707d59b 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/bin/watchfs +++ b/buildroot-v86/board/v86/rootfs_overlay/root/bin/watchfs @@ -1,9 +1,10 @@ #!/bin/sh - -infinite inotifyd echo /root | awk ' +exec inotifyd echo /root /root/.config/launcher | awk ' # listen for writes to rootdir and send them to DOM - /^[wne] \/root index\.html/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/html") } - /^[wne] \/root index\.js/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/js") } + /^[wne] \/root index\.html/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/html") } + /^[wne] \/root index\.js/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/js") } + /^[wne] \/root\/.config\/launcher/ { system("/root/bin/launcher init") } + /.*/ { system("logger "$0) } ' diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/default.html b/buildroot-v86/board/v86/rootfs_overlay/root/default.html new file mode 100755 index 0000000..d3d1591 --- /dev/null +++ b/buildroot-v86/board/v86/rootfs_overlay/root/default.html @@ -0,0 +1,13 @@ +#!/bin/html + + + + + + + + + + diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/URI/fragment/exec.sh b/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/URI/fragment/exec.sh index f696b6a..e049093 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/URI/fragment/exec.sh +++ b/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/URI/fragment/exec.sh @@ -6,6 +6,11 @@ if [[ "$1" =~ "pos=|t=" ]]; then echo "[.] detected Media/XR Fragment in URI" fi +if [[ "$1" =~ "access_token=" ]]; then + # remotestorage redirect oAuth + exit 0 +fi + if [[ "$1" =~ "zip$" ]]; then echo "[.] detected XRSH zip package in URL" echo "[.] fetching $1" diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/wakeup/reload.sh b/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/wakeup/reload.sh index 611192f..249c124 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/wakeup/reload.sh +++ b/buildroot-v86/board/v86/rootfs_overlay/root/hook.d/wakeup/reload.sh @@ -1,5 +1,8 @@ #!/bin/sh +# launcher init +/root/bin/launcher init & + # intialize global funcs /root/index.js &> /dev/null diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/manual.md b/buildroot-v86/board/v86/rootfs_overlay/root/manual.md index a7b9f10..46341ef 100644 --- a/buildroot-v86/board/v86/rootfs_overlay/root/manual.md +++ b/buildroot-v86/board/v86/rootfs_overlay/root/manual.md @@ -51,6 +51,13 @@ Currently the following languages are supported: * nano (busybox nano) * mg (microemacs) +# Autoboot + +To skip the bootmenu you can provide a bootoption via the URL: + +* autoboot the ISO: http://xrsh.isvery.ninja/src/index.html#1 +* autoboot and run `date` cmd: http://localhost:8080/src/index.html#1&date + # Multiple terminals [GNU screen] ## From the cmdline diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/opt/codemirror/codemirror b/buildroot-v86/board/v86/rootfs_overlay/root/opt/codemirror/codemirror index 0a98566..5566425 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/opt/codemirror/codemirror +++ b/buildroot-v86/board/v86/rootfs_overlay/root/opt/codemirror/codemirror @@ -13,5 +13,6 @@ else fi $me/codemirror.js "$file" $2 $3 $4 +echo "NOTE: codemirror can only edit files in /mnt (for now)" echo "press ctrl-Q to exit editor" diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/scene1/.env b/buildroot-v86/board/v86/rootfs_overlay/root/scene1/.env index c940ddd..8eee0ac 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/scene1/.env +++ b/buildroot-v86/board/v86/rootfs_overlay/root/scene1/.env @@ -1,4 +1,3 @@ #!/bin/sh -cd $(dirname $(readlink -f $0)) echo "loading AFRAME glTF scene" cp index.html /root/index.html diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/scene2/.env b/buildroot-v86/board/v86/rootfs_overlay/root/scene2/.env index 6db4606..18956d4 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/scene2/.env +++ b/buildroot-v86/board/v86/rootfs_overlay/root/scene2/.env @@ -1,5 +1,4 @@ #!/bin/sh -cd $(dirname $(readlink -f $0)) echo "loading THREE.js scene" echo "" > /root/index.html # empty scene cp index.js /root/index.js diff --git a/buildroot-v86/board/v86/rootfs_overlay/root/scene3/.env b/buildroot-v86/board/v86/rootfs_overlay/root/scene3/.env index 38d83c3..7cf94a6 100755 --- a/buildroot-v86/board/v86/rootfs_overlay/root/scene3/.env +++ b/buildroot-v86/board/v86/rootfs_overlay/root/scene3/.env @@ -1,4 +1,3 @@ #!/bin/sh -cd $(dirname $(readlink -f $0)) echo "loading AFRAME demo scene" cp index.html /root/index.html