2024-08-29 17:18:14 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test -d /dev/browser || {
|
|
|
|
|
|
|
|
setup_binaries(){
|
2024-09-02 15:05:47 +02:00
|
|
|
for bin in /mnt/js* /mnt/v86pipe /mnt/xrsh; do
|
2024-08-29 17:18:14 +02:00
|
|
|
chmod +x $bin
|
|
|
|
ln -s $bin /bin/.
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2024-09-02 15:05:47 +02:00
|
|
|
setup_links(){
|
|
|
|
ln -s /mnt/profile ~/.profile
|
|
|
|
ln -s /mnt/profile.js ~/.profile.js
|
|
|
|
ln -s /mnt/profile.browser ~/.profile.browser
|
|
|
|
ln -s /mnt/profile.sh ~/.profile.sh
|
|
|
|
ln -s /mnt/motd ~/.motd
|
2024-09-06 10:30:24 +02:00
|
|
|
ln -s ~/.profile.js ~/index.js
|
|
|
|
chmod +x ~/.profile.js
|
2024-09-02 15:05:47 +02:00
|
|
|
}
|
|
|
|
|
2024-08-29 17:18:14 +02:00
|
|
|
setup_browser_dev(){
|
|
|
|
mkdir -p /mnt/dev/browser
|
|
|
|
touch /mnt/dev/browser/js
|
|
|
|
touch /mnt/console.tty
|
|
|
|
ln -s /mnt/dev/browser /dev/browser
|
2024-09-04 20:44:49 +02:00
|
|
|
# emulator.write_file() only writes to /mnt/. :(
|
|
|
|
# should be in /proc, but v86 gives 'no such file or dir' when creating it there
|
|
|
|
ln -s /mnt/console.tty /dev/browser/console.tty
|
2024-09-05 19:09:40 +02:00
|
|
|
echo 1 > /dev/browser/console.tty
|
2024-09-04 20:44:49 +02:00
|
|
|
touch /mnt/console && ln -s /mnt/console /dev/browser/console
|
|
|
|
touch /mnt/index.html && ln -s /mnt/index.html /dev/browser/index.html
|
|
|
|
ln -s /dev/browser/index.html ~/index.html
|
2024-08-29 17:18:14 +02:00
|
|
|
|
|
|
|
test -f /etc/profile && rm /etc/profile
|
|
|
|
ln -s /mnt/profile /etc/profile
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_hook_dirs(){ # see /mnt/hook for usage
|
2024-09-04 20:44:49 +02:00
|
|
|
mkdir ~/bin
|
2024-08-29 17:18:14 +02:00
|
|
|
mkdir -p ~/hook.d/alert
|
2024-09-04 20:44:49 +02:00
|
|
|
echo -e "#!/bin/sh\necho hook.d/alert/yo: yo \$*" > ~/hook.d/alert/yo
|
2024-09-05 19:09:40 +02:00
|
|
|
echo -e "#!/bin/js\nstr = \"hook.d/alert/yo.js yo \"+args.slice(1).join(' ')\nalert(str)\nreturn str" > ~/hook.d/alert/yo.js
|
2024-09-03 18:33:35 +02:00
|
|
|
echo -e "#!/usr/bin/env lua\nprint(\"hook.d/alert/yo.lua: yo \" .. arg[1])" > ~/hook.d/alert/yo.lua
|
|
|
|
echo -e "#!/usr/bin/awk -f\nBEGIN{\n\tprint \"hook.d/alert/yo.awk: yo \" ARGV[1]\n}" > ~/hook.d/alert/yo.awk
|
2024-09-04 20:44:49 +02:00
|
|
|
echo -e "#!/bin/sh\necho hello \$*" > ~/bin/hello
|
|
|
|
chmod +x ~/bin/hello
|
2024-08-29 17:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_network(){
|
|
|
|
test -n "$BROWSER" || return 0
|
2024-09-02 15:05:47 +02:00
|
|
|
#mount -a
|
2024-08-29 17:18:14 +02:00
|
|
|
udhcpc 1>>/var/log/network.log 2>>/var/log/network.log &
|
|
|
|
echo 0 > /proc/sys/kernel/printk
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_binaries
|
|
|
|
setup_browser_dev
|
|
|
|
setup_hook_dirs
|
2024-09-02 15:05:47 +02:00
|
|
|
setup_links
|
2024-09-03 18:33:35 +02:00
|
|
|
setup_network
|
2024-08-30 13:09:37 +02:00
|
|
|
|
2024-08-29 17:18:14 +02:00
|
|
|
}
|