67 lines
1.7 KiB
Bash
67 lines
1.7 KiB
Bash
#!/bin/sh
|
|
|
|
test -d /dev/browser || {
|
|
|
|
move_root_to_9pfs(){
|
|
mkdir /mnt/run # for javascript<->unix pids
|
|
test -d /mnt/root && return 0
|
|
mv /root /mnt/.
|
|
ln -fs /mnt/root /root
|
|
}
|
|
|
|
setup_links(){
|
|
ln -fs /etc/motd ~/.motd
|
|
ln -fs /mnt/profile.browser ~/.profile.browser
|
|
chmod +x ~/.profile.js
|
|
}
|
|
|
|
setup_browser_dev(){
|
|
mkdir -p /mnt/dev/browser
|
|
touch /mnt/dev/browser/js
|
|
touch /mnt/dev/browser/html
|
|
touch /mnt/dev/browser/console
|
|
ln -fs /mnt/dev/browser /dev/browser
|
|
}
|
|
|
|
setup_network(){
|
|
test -n "$BROWSER" || return 0
|
|
#mount -a
|
|
udhcpc 1>>/var/log/network.log 2>>/var/log/network.log &
|
|
echo 0 > /proc/sys/kernel/printk
|
|
}
|
|
|
|
setup_overlayfs(){
|
|
test -f /mnt/overlayfs.zip && unzip /mnt/overlayfs.zip -d /
|
|
}
|
|
|
|
setup_incoming_cmds(){
|
|
# listen for shell cmds passed to v86 from browser
|
|
# (via isoterminal.exec(...))
|
|
stty raw < /dev/ttyS1
|
|
#cat /dev/ttyS1 | xargs -I{} /bin/sh -c 'logger "isoterminal.exec({})"; {}'
|
|
mkfifo /var/run/ttyS1
|
|
echo "source /etc/profile" >> /var/run/ttyS1
|
|
cat /dev/ttyS1 > /var/run/ttyS1 &
|
|
/bin/sh < /var/run/ttyS1
|
|
}
|
|
|
|
setup_listen_homedir(){
|
|
sleep 4 # wait for inode of /mnt/root to become live (due to move_root_to_9pfs)
|
|
infinite inotifyd echo /mnt/root | awk '
|
|
|
|
# listen for writes to rootdir and send them to DOM
|
|
/^[we] \/mnt\/root index\.html/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/html") }
|
|
/^[we] \/mnt\/root index\.js/ { system("cat "$2"/"$3" | grep -vE \"^#!\" > /dev/browser/js") }
|
|
|
|
'
|
|
}
|
|
|
|
move_root_to_9pfs
|
|
setup_browser_dev
|
|
setup_links
|
|
setup_network
|
|
setup_overlayfs
|
|
setup_incoming_cmds &
|
|
setup_listen_homedir &
|
|
}
|