ref: 3eb1bbbf7fa853c6bf5fee8d076010631b37c032
parent: f6809d510b19103bd5034f9c66ec4e7ad6d5684c
author: glenda <glenda@9front.local>
date: Sun Nov 29 01:13:54 EST 2020
moved crap around
--- /dev/null
+++ b/grid/chat
@@ -1,0 +1,104 @@
+#!/bin/rc
+# minimal chat client for hubfs: chat [-n NICK] [-j CHANNEL] [chatsrv]
+
+fn helpmessage{
+ echo -------------------------
+ echo '/q to quit | /c to list channels | /h for help message'
+ echo '/n NICK to change nick | /j CHANNEL to change channels'
+ echo -------------------------
+}
+
+rfork enf
+channel=chat
+chatsrv=chat
+while (~ $1 -*){
+ switch($1){
+ case -n
+ name = $2
+ shift
+ shift
+ case -j
+ channel = $2
+ shift
+ shift
+ case *
+ echo bad flag $1 '-n NICK -j CHANNEL'
+ shift
+ }
+}
+if(! ~ $1 '')
+ chatsrv=$1
+if(! test -e /n/$chatsrv/chat)
+ mount /srv/$chatsrv /n/$chatsrv
+if(! test -e /n/$chatsrv/chat){
+ echo 'no chat service named $chatsrv found' >[1=2]
+ exit no.chat
+}
+
+echo ' -- hubchat 0.2 --'
+helpmessage
+sleep 2
+while(~ $#name 0){
+ echo 'please enter a chat name:'
+ name=`{read}
+}
+echo JOIN $name to $channel >>/n/$chatsrv/$channel
+cat /n/$chatsrv/$channel &
+catkill=$apid
+
+while(talk=`{read}){
+ if(~ $talk /*){
+ switch($talk){
+ case /q*
+ echo PART $name from $channel >>/n/$chatsrv/$channel
+ @{echo kill>/proc/$catkill/ctl}
+ exit
+ case /n*
+ if(! ~ $talk(2) ''){
+ echo nick $name ' -> ' $talk(2) >>/n/$chatsrv/$channel
+ name=$talk(2)
+ }
+ if not
+ echo 'you need to provide a nick for /n NICK'
+ command=yes
+ case /j*
+ if (~ $talk(2) '')
+ echo must specify a channel to join
+ if not if(test -e /n/chat/$talk(2)){
+ echo PART $name from $channel >>/n/$chatsrv/$channel
+ @{echo kill>/proc/$catkill/ctl}
+ channel=$talk(2)
+ cat /n/chat/$channel &
+ catkill=$apid
+ echo JOIN $name to $channel >>/n/$chatsrv/$channel
+ }
+ if not
+ echo channel does not exist
+ command=yes
+ case /h*
+ helpmessage
+ echo currently in $channel
+ echo
+ command=yes
+ case /c
+ echo Available channels:
+ lc /n/$chatsrv
+ echo -------------------
+ echo currently in $channel
+ echo
+ command=yes
+ case *
+ echo unknown command
+ command=yes
+ }
+ }
+ if(~ $talk '')
+ command=yes
+ if(! ~ $command yes){
+# ts=`{date -u}
+# ts=`{echo '('^$ts(4)^')'}
+ line=`{echo $name ': ' $talk}
+ echo $line >>/n/chat/$channel
+ }
+ command=no
+}
--- /dev/null
+++ b/grid/clear
@@ -1,0 +1,14 @@
+#!/bin/rc
+# clear -- clears the window
+
+> /dev/text
+
+if(! ~ $#* 0){
+ echo -n $prompt
+ echo -n ' clear '
+ echo -n ''''
+ echo -n $"*
+ echo ''''
+ echo
+ eval $"*
+}
--- /dev/null
+++ b/grid/gridstart
@@ -1,0 +1,101 @@
+#!/bin/rc
+# connects to 9gridchan grid services and starts a new subrio
+# options -t tls -m mountonly -s scriptonly
+# awk '/exportfs/{print "srv -c", $1, $3, $5}' /mnt/registry/index
+
+fn cpl{
+ cp $1 /n/griddisk/cpl
+ ptarg=`{basename $1}
+ plumb http://wiki.9gridchan.org/incoming/cpl/$ptarg
+}
+
+fn error{
+ echo An error ocurred.
+ exit
+}
+
+while (~ $1 -*){
+ switch($1){
+ case -t
+ tls = yes
+ shift
+ case -m
+ mountonly = yes
+ shift
+ case -s
+ scriptonly = yes
+ shift
+ case *
+ echo bad flag $1 >>[1=2]
+ shift
+ }
+}
+
+if(test -e /srv/gridregistry){
+ echo 'old grid connections found in /srv, remove? (y/n)'
+ ans=`{read}
+ if(~ $ans y){
+ rm /srv/gridchat
+ rm /srv/gridplumber
+ rm /srv/gridram
+ rm /srv/gridregistry
+ rm /srv/gridroot
+ rm /srv/gridwiki
+ rm /srv/griddisk
+ rm /srv/pubregistry
+ }
+}
+
+if(~ $tls yes){
+ auth/factotum
+ echo 'key proto=dp9ik user=glenda dom=grid !password=9gridchan' >/mnt/factotum/ctl
+ srvtls tcp!registry.9gridchan.org!16675 gridregistry /mnt/registry || error
+ awk '/tlssrv/{print "srvtls -c", $1, $3, $5}' /mnt/registry/index >/tmp/gridscript
+# cat /mnt/registry/index |grep tlssrv |sed 's/^/srvtls -c /g' |sed 's/is //g' |sed 's/mountpoint //g' |sed 's/service.*$//g' >/tmp/gridscript
+}
+if(! ~ $tls yes){
+ srv tcp!registry.9gridchan.org!6675 gridregistry /mnt/registry || error
+ awk '/exportfs/{print "srv -c", $1, $3, $5}' /mnt/registry/index >/tmp/gridscript
+# cat /mnt/registry/index |grep exportfs |sed 's/^/srv -c /g' |sed 's/is //g' |sed 's/mountpoint //g' |sed 's/service.*$//g' >/tmp/gridscript
+}
+
+if(~ $scriptonly yes){
+ echo 'script saved in /tmp/gridscript'
+ cat /tmp/gridscript
+ exit
+}
+
+. /tmp/gridscript
+
+if(~ $mountonly yes){
+ echo 'grid services mounted'
+ exit
+}
+
+if(test -e /bin/grio)
+ srio=(grio -s -c 0x99009900)
+if not
+ srio=(rio -s)
+
+echo '#!/bin/rc
+window -r 0 0 700 400 chat
+window -r 700 0 1300 400 acme -l/tmp/gridacme
+window -r 0 400 700 750 mothra -a http://wiki.9gridchan.org/message_board
+window -r 700 400 1300 750 page /n/gridroot/lib/musicant.png
+' >/tmp/gridrio
+
+chmod +x /tmp/gridrio
+if(! test -e /mnt/web/ctl)
+ webfs
+
+echo '/usr/glenda
+/lib/font/bit/vga/unicode.font
+/lib/font/bit/vga/unicode.font
+ 0 66
+f 1 1 36 36 3
+ 1 33 36 1 0 /n/griddisk/ Del Snarf Get | Look
+F 1 1 15 15 28 15
+ 2 23 15 0 1 Del Snarf Undo | Look
+Wiki /mnt/wiki' >/tmp/gridacme
+
+window -m -r 0 0 1350 750 $srio -i /tmp/gridrio
--- /dev/null
+++ b/install/install-go.rc
@@ -1,0 +1,12 @@
+#! /bin/rc
+cd /tmp
+hget http://www.9legacy.org/download/go/go1.14.1-plan9-amd64-bootstrap.tbz | bunzip2 -c | tar x
+mkdir -p /sys/lib/go
+cd /sys/lib/go/
+hget https://golang.org/dl/go1.15.2.src.tar.gz | gunzip -c | tar x
+cd /sys/lib/go/go/src
+GOROOT_BOOTSTRAP=/tmp/go-plan9-amd64-bootstrap
+GOROOT=/sys/lib/go/go
+
+make.rc
+cp /sys/lib/go/go/bin/* /$objtype/bin
--- /dev/null
+++ b/install/install-irc7.rc
@@ -1,0 +1,5 @@
+#! /bin/rc
+ramfs
+hget http://plan9.stanleylieber.com/src/irc7.tgz | tar xvz
+cd irc*
+mk install
--- /dev/null
+++ b/install/patch-rio
@@ -1,0 +1,5 @@
+#!/bin/rc
+bind -ac /dist/plan9front /
+cd /sys/src/cmd/rio
+hget https://ftrv.se/_/9/patches/rio-themes.patch | hg patch -f --no-commit -
+mk install
--- /dev/null
+++ b/install/pull9front
@@ -1,0 +1,4 @@
+#!/bin/rc
+cd /dist/plan9front
+hg pull
+hg update -c
--- a/restore
+++ b/restore
@@ -1,6 +1,6 @@
#!/bin/rc
-cp ./df ./email-login ./riostart ./clear ./chat ./gridstart ./screenshot ./sysbuild ./respawn ./mailwindow $home/bin/rc
+cp util/* $home/bin/rc
cp color $home/
-./install-go.rc
-./pull9front
-./patch-rio
+./install/*.rc
+./install/pull9front
+./install/patch-rio
--- /dev/null
+++ b/util/df
@@ -1,0 +1,24 @@
+#!/bin/rc
+# df: print file system disk usage
+# usage: df [ server ]
+# This is the work of mischief (mischief on freenode) not Fulton Browne (the owner of this repo)
+rfork e
+
+hj=/srv/hjfs.cmd
+cw=/srv/cwfs.cmd
+owner=glenda
+server=$1
+
+if(~ $#server 1)
+ exec rcpu -h $server -u $owner -c /mnt/term/bin/df
+
+if(! ~ $user $owner)
+ exec rcpu -h $sysname -u $owner -c /mnt/term/bin/df
+
+if(test -w $hj)
+ echo df >>$hj &&
+ cat /dev/kmesg |
+ tail -2
+if(test -w $cw)
+ echo statw >>$cw &&
+ read -n 21 $cw
--- /dev/null
+++ b/util/email-login
@@ -1,0 +1,3 @@
+#! /bin/rc
+# adjust to your own server
+upas/fs -f /imaps/mail.fulton.software/fulton@fulton.software
--- /dev/null
+++ b/util/factotumgr
@@ -1,0 +1,18 @@
+#! /bin/rc
+# Add a smpt password with:
+# factotumgr -s server user password
+while (~ $1 -*){
+ switch($1){
+ case -s
+ smpt = yes
+ shift
+ case -*
+ echo bad flag $1 >>[1=2]
+ shift
+ }
+}
+if(~ smpt){
+ echo 'key proto=pass server=$1 service=smpt \
+ user=$2 !password=$3'\
+ >/mnt/factotum/ctl
+}
--- /dev/null
+++ b/util/mailwindow
@@ -1,0 +1,4 @@
+#! /bin/rc
+label mail
+email-login
+respawn mail
--- /dev/null
+++ b/util/respawn
@@ -1,0 +1,4 @@
+#! /bin/rc -e
+while(){
+ $*
+}
--- /dev/null
+++ b/util/riostart
@@ -1,0 +1,13 @@
+#!/bin/rc
+window 0,0,161,117 stats -lmisce
+window -miny 130
+
+# run a system shell on the serial console
+~ $#console 0 || window -scroll console
+
+window 'cat /usr/glenda/color > /mnt/wsys/theme;
+ sleep 0.5;
+ grep softscreen /dev/vgactl >> /dev/vgactl;
+ echo hwblank off >> /dev/vgactl;
+ cat /dev/kprint'
+
--- /dev/null
+++ b/util/screenshot
@@ -1,0 +1,4 @@
+#! /bin/rc
+date -n > /env/thetime
+topng < /dev/screen
+
--- /dev/null
+++ b/util/sysbuild
@@ -1,0 +1,14 @@
+#! /bin/rc
+# Fulton Browne 11/27/2020 on 9front
+# You are free to distrbute and modify the source as you wish
+
+# Start a sub shell
+@{
+ rfork
+ # bind the source - change locaction as needed
+ bind -ac /disk/plan9front
+ cd /sys/src
+ mk clean
+ mk install
+ mk clean
+}