xrsh-buildroot/buildroot-v86/board/v86/rootfs_overlay/etc/profile.xrsh

67 lines
1.7 KiB
Plaintext
Raw Normal View History

2024-09-11 14:58:31 +02:00
#!/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
}
2024-09-11 14:58:31 +02:00
setup_links(){
ln -fs /etc/motd ~/.motd
ln -fs /mnt/profile.browser ~/.profile.browser
2024-09-11 14:58:31 +02:00
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
2024-09-11 14:58:31 +02:00
}
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 /
}
2024-09-15 11:18:36 +02:00
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
2024-09-15 11:18:36 +02:00
}
setup_listen_homedir(){
sleep 4 # wait for inode of /mnt/root to become live (due to move_root_to_9pfs)
2024-09-24 16:13:37 +02:00
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") }
'
2024-09-15 11:18:36 +02:00
}
move_root_to_9pfs
2024-09-11 14:58:31 +02:00
setup_browser_dev
setup_links
setup_network
setup_overlayfs
2024-09-15 11:18:36 +02:00
setup_incoming_cmds &
setup_listen_homedir &
2024-09-11 14:58:31 +02:00
}