plan9fox/sys/lib/newuser

88 lines
1.7 KiB
Bash
Executable file

#!/bin/rc
user=`{cat /dev/user}
home=/usr/$user
if(test -f $home/lib/profile){
echo user directories already made
exit no
}
cd $home
x='$'
mkdir bin bin/rc bin/mips bin/386 bin/amd64 bin/power bin/arm bin/arm64
mkdir lib tmp
chmod +t tmp
bind -qc /n/other/usr/$user/tmp $home/tmp
bind -c $home/tmp /tmp
mail -c
auth/cron -c
cat > lib/profile <<!
bind -qa $x^home/bin/rc /bin
bind -qa $x^home/bin/$x^cputype /bin
font=/lib/font/bit/vga/unicode.font
fn mothra { /bin/mothra -a $* }
switch($x^service){
case terminal
webcookies
webfs
plumber
echo -n accelerated > '#m/mousectl'
echo -n 'res 3' > '#m/mousectl'
prompt=('term% ' ' ')
fn term%{ $x^* }
rio -sb -i riostart
case cpu
bind /mnt/term/dev/cons /dev/cons
bind -q /mnt/term/dev/consctl /dev/consctl
>[2] /dev/null {
cp /dev/sysname /mnt/term/dev/label
if(wsys=`{cat /mnt/term/env/wsys} && ~ $x^#wsys 1) {
wsys=/mnt/term^$x^wsys
}
if not {
wsys=()
}
}
bind -a /mnt/term/dev /dev
prompt=('cpu% ' ' ')
fn cpu%{ $x^* }
if(! test -e /mnt/term/dev/wsys){
prompt=('draw% ' ' ')
fn draw%{ $x^* }
# call from drawterm
if(test -e /mnt/term/dev/secstore){
auth/factotum -n
read -m /mnt/term/dev/secstore >/mnt/factotum/ctl
echo >/mnt/term/dev/secstore
}
if not
auth/factotum
webcookies
webfs
plumber
rio -sb -i riostart
}
case con
prompt=('cpu% ' ' ')
}
!
cat > bin/rc/riostart <<!
#!/bin/rc
window 0,0,161,61 stats -lm
window -miny 130
# run a system shell on the serial console
!
echo '~ $#console 0 || window -scroll console' >> bin/rc/riostart
cat > lib/plumbing <<!
# to update: cp /usr/$user/lib/plumbing /mnt/plumb/rules
editor = sam
browser = mothra
include basic
!
. lib/profile