2024-08-26 12:02:35 +02:00
|
|
|
|
install_xrsh(){
|
2024-08-27 20:40:05 +02:00
|
|
|
|
|
|
|
|
|
setup_binaries(){
|
|
|
|
|
for bin in /mnt/prompt /mnt/alert /mnt/confirm /mnt/hook /mnt/js*; do
|
|
|
|
|
chmod +x $bin
|
|
|
|
|
ln -s $bin /bin/.
|
|
|
|
|
done
|
|
|
|
|
}
|
2024-08-26 12:02:35 +02:00
|
|
|
|
|
|
|
|
|
setup_browser_dev(){
|
|
|
|
|
mkdir -p /mnt/dev/browser
|
|
|
|
|
touch /mnt/dev/browser/js
|
|
|
|
|
touch /mnt/dev/browser/html
|
2024-08-27 20:40:05 +02:00
|
|
|
|
touch /mnt/dev/browser/console
|
2024-08-26 12:02:35 +02:00
|
|
|
|
ln -s /mnt/dev/browser /dev/browser
|
|
|
|
|
test -f /etc/profile && rm /etc/profile
|
|
|
|
|
ln -s /mnt/profile /etc/profile
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 20:40:05 +02:00
|
|
|
|
setup_hook_dirs(){ # see /mnt/hook for usage
|
|
|
|
|
mkdir -p ~/hook.d/alert
|
|
|
|
|
mkdir -p ~/hook.d/confirm
|
|
|
|
|
mkdir -p ~/hook.d/prompt
|
|
|
|
|
echo -e "#!/bin/sh\necho yo" > ~/hook.d/alert/yo
|
|
|
|
|
echo -e "#!/bin/js\nalert('yo')" > ~/hook.d/alert/yo.js
|
|
|
|
|
echo -e "#!/usr/bin/lua\nalert('yo')" > ~/hook.d/alert/yo.lua
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setup_binaries
|
2024-08-26 12:02:35 +02:00
|
|
|
|
setup_browser_dev
|
2024-08-27 20:40:05 +02:00
|
|
|
|
setup_hook_dirs
|
2024-08-26 12:02:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test -d /dev/browser || install_xrsh
|
|
|
|
|
|
|
|
|
|
test -f /mnt/V86 && {
|
|
|
|
|
mount -a
|
|
|
|
|
udhcpc 1>>/var/log/network.log 2>>/var/log/network.log &
|
|
|
|
|
echo 0 > /proc/sys/kernel/printk
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 20:40:05 +02:00
|
|
|
|
## forward not-found commands to javascript (via jsh)
|
|
|
|
|
command_not_found_handle(){
|
|
|
|
|
echo "$1 not found"
|
|
|
|
|
alert "did you mean $1(...) (javascript?)"
|
|
|
|
|
alert "TIP: run 'jsh $1 hello' to run $1('hello')"
|
|
|
|
|
alert " or simply 'jsh' for a js console"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# source javascript functions
|
|
|
|
|
#js "$(cat /mnt/profile.js)"
|
|
|
|
|
|
2024-08-26 12:02:35 +02:00
|
|
|
|
resize
|
|
|
|
|
#clear
|
|
|
|
|
cat /mnt/motd
|
|
|
|
|
export PATH=$PATH:/mnt
|
|
|
|
|
export PS1="\n[38;5;57mx[38;5;93mr[38;5;129ms[38;5;165mh [38;5;201m# \033[0m"
|
2024-08-27 20:40:05 +02:00
|
|
|
|
export BROWSER=0 # running inside v86 (wasm) will set this to 1
|