#!/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 mkfifo /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) /mnt/root/bin/watchfs & } move_root_to_9pfs setup_browser_dev setup_links setup_network setup_overlayfs setup_incoming_cmds & setup_listen_homedir }