ref: 1ff51edfc0be4600b8539583bfdee4c3eec24744
parent: 4a56ddcda879c264538df970f2d1f2b68e9dcd68
author: 9ferno <gophone2015@gmail.com>
date: Sun Aug 15 01:23:59 EDT 2021
cleaned up initialization scripts
--- a/dis/init
+++ b/dis/init
@@ -1,4 +1,6 @@
-# boot initialization here
+# boot initialization
+# configure devices
+# setup /
# sh -n /dis/init
# disinit.b does this but not sure why it loses it later
@@ -6,8 +8,8 @@
load std
-mount -a { mntgen } /n
-mount -a { mntgen } /mnt
+mount {mntgen} /n
+mount {mntgen} /mnt
#fn showlocaldev {
# echo $1' ' $2
@@ -54,13 +56,23 @@
mac=`{cat /net/ether0/addr}
if{~ $"mac deadbeefcafe}{
sysname=vmx9ferno
-}{
+}{~ $"mac 6805ca1bae72}{
sysname=9ferno
+}{
+ sysname=9ferno1
}
-#ns
+echo $"sysname > '#c'/sysname
+ <>/net/ipifc/clone {
+ x=`{read}
+ echo bind ether /net/ether0 > /net/ipifc/^$x^/ctl
+ ip/dhcp -dp -h $sysname /net/ipifc/$x
+ }
+
+#ns
if{~ $"sysname vmx9ferno}{
+
# for using the cd
9660srv /dev/sdF0/data /n/cd
bind -a /n/cd/dis /dis
@@ -85,20 +97,24 @@
## starting inferno already installed to a disk
mount -c { disk/kfs -n rootdisk /dev/sdG0/fs } /n/rootdisk
#disk/kfscmd -n rootdisk sync
- bind -b /n/rootdisk/dis /dis
+ #bind -b /n/rootdisk/dis /dis
bind -a -c /n/rootdisk/ /
# refresh the disk contents from the cd
- disk/mkfs -v -s /n/cd/ -d /n/rootdisk/ <{ echo + }
+ #disk/mkfs -v -s /n/cd/ -d /n/rootdisk/ <{ echo + } &
- mkdir -p /usr/`{cat /dev/user}
-} &
+}{~ $"sysname 9ferno}{
-<>/net/ipifc/clone {
- x=`{read}
- and {echo bind ether /net/ether0 > /net/ipifc/^$x^/ctl} {
- ip/dhcp -h $sysname -p /net/ipifc/$x}
-} &
+ # mount the vmx cd
+ mount -A tcp!192.168.88.118!17001 /n/cd
+ bind -b /n/cd/dis /dis
+ bind -a /n/cd /
-cd /usr/^`{cat /dev/user}
-sh -l -n # to use the ./lib/profile
+ disk/fdisk -p /dev/sdE0/data >/dev/sdE0/ctl
+ disk/prep -p /dev/sdE0/plan9 > /dev/sdE0/ctl
+
+}
+
+# if I add /lib/sh/profile to devroot,
+# all the above binds can be moved to $home/namespace
+sh -x -l -n # to run the /lib/sh/profile
--- a/lib/ndb/registry
+++ b/lib/ndb/registry
@@ -1,4 +1,4 @@
# this file is given to the local registry(4) by svc/registry (see svc(8))
# as its initial data. you could put static local service descriptions here.
-service=tcp!master!6679 description='acme editor' auth=none
\ No newline at end of file
+service=tcp!master!6679 description='acme editor' auth=none
--- a/lib/proto/inferno
+++ b/lib/proto/inferno
@@ -2439,5 +2439,6 @@
keyring
lib
plumbing
+ profile
namespace
wrap
--- a/lib/sh/profile
+++ b/lib/sh/profile
@@ -1,28 +1,31 @@
-# emu sh initialisation here
+# sh initialisation here
load std
user = `{cat /dev/user}
home = /usr/^$user
pubgridreg = tcp!registry.9p.zone!registry
+cd $home
-bind /locale/US_Central /locale/timezone
+# build the user's namespace in $home/
+and {ftest -e namespace} {nsbuild}
-# Fix creation annoyance for hosted inferno
-# this might be relevant for native, but is untested
-bind -c '#U'/dis /dis
-
-# Set up environment
-bind -b '#s' /chan
-
# Networking
ndb/dns -r
ndb/cs
# bind -a '#scs' /net
-mount {mntgen} /n
-mount {mntgen} /mnt
+if{~ $#emuhost 0 && ~ $#emuwdir 0}{
+ # running native
+
+ # load a heap based filesystem on /tmp
+ memfs
+}{
+ # running hosted
+
+ # dis/init has set this up already for native booting
+ mount {mntgen} /n
+ mount {mntgen} /mnt
+}
+
# Run the user's profile
-cd
-and {ftest -e namespace} {nsbuild}
-and {ftest -d tmp} {bind -c tmp /tmp}
and {ftest -e lib/profile} {run ./lib/profile}
--- a/os/init/disinit.b
+++ b/os/init/disinit.b
@@ -66,12 +66,22 @@
(s, nil) := sys->stat("/dis/init");
if(s == 0){
sys->print("spawn sh -x -n /dis/init\n");
- spawn sh->init(nil, "sh" :: "-x" :: "-n" :: "/dis/init" :: nil);
+ {
+ sh->init(nil, "sh" :: "-x" :: "-n" :: "/dis/init" :: nil);
+ } exception e {
+ "*" =>
+ sys->fprint(stderr, "dis/init status: %s\nStarting fallback shell\n", e);
+ # fallback console
+ sh1 := load Sh "/dis/sh.dis";
+ sys->print("sh -x -n\n");
+ sh1->init(nil, "sh" :: "-x" :: "-n" :: nil);
+ }
+ }{
+ # fallback console
+ sh1 := load Sh "/dis/sh.dis";
+ sys->print("sh -x -n\n");
+ sh1->init(nil, "sh" :: "-x" :: "-n" :: nil);
}
- # fallback console
- sh1 := load Sh "/dis/sh.dis";
- sys->print("sh -x -n\n");
- sh1->init(nil, "sh" :: "-x" :: "-n" :: nil);
}
srv()
--- a/usr/inferno/lib/profile
+++ b/usr/inferno/lib/profile
@@ -1,21 +1,26 @@
# Personal sh intialisation
-memfs
+echo starting /usr/inferno/lib/profile
-# Set up environment
-bind -b $home/dis /dis
-bind -b $home/module /module
+cp /locale/US_Arizona /locale/timezone
-# Networking
-ndb/cs
-ndb/dns
-
if{~ $"sysname vmx9ferno}{
# serve the cd
styxlisten -A -v tcp!192.168.88.118!17001 export /n/cd/
+ # serve the root - TODO use svc/styx(8) instead of this
+ styxlisten -A -v tcp!192.168.88.118!17002 export /
}
if{~ $"sysname 9ferno}{
- # mount the vmx cd
- mount -A tcp!192.168.88.118!17001 /n/cd
+
+ # serve the root - TODO use svc/styx(8) instead of this
+ styxlisten -A -v tcp!192.168.88.113!17001 export /
+
+ bind -a '#I1' /net.alt
+ bind -a '#l1' /net.alt
+ <>/net.alt/ipifc/clone {
+ x=`{read}
+ and {echo bind ether /net.alt/ether1 > /net.alt/ipifc/^$x^/ctl} {
+ ip/dhcp -h $"sysname^'.1' -p /net.alt/ipifc/$x}
+ }
}
--- a/usr/inferno/namespace
+++ b/usr/inferno/namespace
@@ -1,18 +1,6 @@
-# Referenced by startup scripts in /lib/sh.
-# This is run by sh, unlike in Plan 9.
-#load std
-# interface to host operating system commands
-bind -a #C /
-
-# mounting /tmp for acme
-bind -a -c '#U*'/tmp /tmp
-
# /chan/foo is more natural than '#s'/foo
-# for some reason, below breaks wmlib
-# wmlib: cannot open /chan/wmctl: '/chan/wmctl' file does not exist
-# also, this is done by wm/wm anyway. so, not needed
-# bind '#s' /chan
+bind -b '#s' /chan
-# mount 9front's network stack
-bind -c '#U*'/net /net
+bind -ib /usr/inferno/dis /dis
+bind -ib /usr/inferno/module /module