shithub: scripts

Download patch

ref: bc762e9c9294990c0d2480295637c792363dcc8c
parent: 3519f1d58ff78407227adb5a3a202d7a4e626a93
author: kitzman <kitzman@disroot.org>
date: Sun Feb 4 07:20:09 EST 2024

added and modified rc scripts

--- a/README
+++ b/README
@@ -4,6 +4,7 @@
 bin/rc/gemhist				- (stolen) gemnine history
 bin/rc/gfetch				- (stolen) gfetch
 bin/rc/gridup				- (stolen) mount grid stuff
+bin/rc/H					- $EDITOR for unix hosts
 bin/rc/inferno				- run inferno with unionfs
 bin/rc/librarysrv			- ramfs-backed cfs caching example
 bin/rc/rios/themeswitch		- switch the theme and font
@@ -15,6 +16,9 @@
 bin/rc/D2X					- acme decimal-to-hex
 bin/rc/X2D					- acme hex-to-decimal
 bin/rc/Mails				- acme Mail wrapper
+bin/rc/wlabel				- wloc for labels
+bin/rc/wp				- persistent read-only rio window
+bin/rc/wman				- same as wp but for manpages
 
 lib/lua/net.lua					- p9 wrappers for /net and /mnt/web
 lib/lua/r2pipe.lua				- r2pipe for lua
--- /dev/null
+++ b/bin/rc/H
@@ -1,0 +1,44 @@
+#!/usr/bin/env rc
+
+files=()
+plumber=$home/mnt/plumb/send
+# Hhost=()
+
+if(~ $#* 0) {
+	echo 'usage: H file' >[2=1]
+	exit 'usage'
+}
+
+files=($1)
+shift
+
+if(~ $#Hhost 0) {
+	Hhost=`{hostname}
+}
+
+# plumb file
+hostfile=$files
+relpath='/n/'^$"Hhost^`{pwd}
+if(~ $files `{realpath $files}) {
+	files='/n/'^$"Hhost^$"files
+}
+fileslen=`{echo -n $files | wc -c}
+echo 'E
+edit
+'^$"relpath^'
+text
+
+'^$fileslen^'
+'^$"files >>$plumber
+
+echo 'plumbed' $hostfile >[2=1]
+
+# wait for modification
+stat=`{ls -l $hostfile}
+while(sleep 1) {
+	nstat=`{ls -l $hostfile}
+	if(! ~ $"nstat $"stat) {
+		echo $file 'modified; closing' >[2=1]
+		exit
+	}
+}
--- a/bin/rc/themeswitch
+++ /dev/null
@@ -1,39 +1,0 @@
-#!/bin/rc
-
-switch($themespec) {
-case green
-	font=/lib/font/bit/uni-vga/u_vga16.font
-	# font=/lib/font/bit/zevv-peep/zevv-peep-14.font
-	# font=/lib/font/bit/spleen/spleen.12.font
-	# font=/lib/font/bit/tamzen/tamzen14.font
-	themepath=$home/lib/theme/green.theme
-case blit
-	font=/lib/font/bit/fixed/unicode.9x18B.font
-	font=/lib/font/bit/fixed/unicode.9x15B.font
-	themepath=$home/lib/theme/blit.theme
-case orange
-	font=/lib/font/bit/zevv-peep/zevv-peep-14.font
-	font=/lib/font/bit/tamzen/tamzen16.font
-	themepath=$home/lib/theme/orange.theme
-case gruvbox
-	font=/lib/font/bit/uni-vga/u_vga16.font
-	themepath=$home/lib/theme/gruvbox.theme
-case gruvboxl
-	font=/lib/font/bit/uni-vga/u_vga16.font
-	themepath=$home/lib/theme/gruvboxl.theme
-case white
-	font=/lib/font/bit/lucm/unicode.9.font
-	font=/lib/font/bit/lucidasans/typeunicode.7.font
-	# font=/lib/font/bit/pelm/unicode.8.font
-	themepath=$home/lib/theme/white.theme
-case greeng
-	font=/lib/font/bit/zevv-peep/zevv-peep-16.font
-	themepath=$home/lib/theme/greengold.theme
-case nord
-	font=/lib/font/bit/pelm/unicode.8.font
-	themepath=$home/lib/theme/nord.theme
-}
-
-if(test -f /dev/theme) {
-	cat $themepath >/dev/theme
-}
--- a/bin/rc/urexport
+++ b/bin/rc/urexport
@@ -1,5 +1,7 @@
 #!/bin/rc
 
+rfork ne
+
 uhost=$1
 srvname=$2
 srvrem=$3
@@ -14,44 +16,27 @@
 if not
 	if(~ $#srvrem 0)
 		srvrem=srvname
-	
-if(~ $#srvname 0) {
-	ipipe='/n/unixhub/fs!'^$uhost^'0'
-	opipe='/n/unixhub/fs!'^$uhost^'1'
-}
-if not {
-	ipipe='/n/unixhub/'^$srvname^'!'^$uhost^'!0'
-	opipe='/n/unixhub/'^$srvname^'!'^$uhost^'!1'
-}
 
-if(! test -f /srv/unixhub) {
-	hubfs -t -s unixhub -m /n/unixhub
-	touch /n/unixhub/ctl
-}
-if not
-	mount -c /srv/unixhub /n/unixhub
+bind '#|' /mnt/urexport
+pipe0=/mnt/urexport/data
+pipe1=/mnt/urexport/data1
 
-if(test -f $ipipe)
-	rm $ipipe
-touch $ipipe
-
-if(test -f $opipe)
-	rm $opipe
-touch $opipe
-
 if(~ $#srvname 0) {
-	exportfs -r / <$ipipe >$opipe &
+	exportfs -r / <$pipe0 >$pipe0 &
 }
 if not {
 	mount /srv/$srvname /n/$srvrem
-	exportfs -r /n/$srvrem <$ipipe >$opipe &
+	exportfs -r /n/$srvrem <$pipe0 >$pipe0 &
 }
 
 if(~ $#srvname 0) {
 	ssh $uhost .local/bin/socat \
-		unix-listen:srv/term.$apid - >$ipipe <$opipe &
+		unix-listen:srv/term.$apid - >$pipe1 <$pipe1 &
+#	can't get this working
+#	ssh $uhost .local/bin/9 \
+#		9pserve unix!srv/term.$apid >$pipe1 <$pipe1 &
 }
 if not {
 	ssh $uhost .local/bin/socat \
-		unix-listen:srv/$srvrem - >$ipipe <$opipe &
+		unix-listen:srv/$srvrem - >$pipe1 <$pipe1 &
 }
--- a/bin/rc/urimport
+++ b/bin/rc/urimport
@@ -9,13 +9,8 @@
 }
 
 ruser=`{echo $rhost | sed 's/^([a-zA-Z0-9]+)@.*/\1/g'}
-if(~ $#ruser 0)
+if(~ $ruser $rhost)
 	ruser=`{cat /dev/user}
 
-if(! test -f /srv/execnet) {
-	execnet /n/execnet
-	srvfs execnet /n/execnet
-}
-mount -b /srv/execnet /net
-
-srv 'exec!ssh '^$rhost^' .local/bin/u9fs -l /dev/null -u '^$ruser^' -a none' $rhost
+srv -e 'ssh '^$rhost^' .local/bin/u9fs -l /dev/null -u '^$ruser^' -a none' $rhost
+# srv -e 'ssh '^$rhost^' go/bin/export9p -s' $rhost
--- /dev/null
+++ b/bin/rc/wlabel
@@ -1,0 +1,13 @@
+#!/bin/rc
+
+if(! test -d /mnt/wsys/wsys)
+	exit 'wsys not found'
+
+wlabels=`{walk -n 1,2 /mnt/wsys/wsys | grep label}
+
+for (wl in $wlabels) {
+	wn=`{basename `{basename -d $wl}}
+	echo -n $wn^'	'
+	cat $wl
+	echo
+}
--- /dev/null
+++ b/bin/rc/wman
@@ -1,0 +1,26 @@
+#!/bin/rc
+
+sections=()
+if(~ $#* 2) {
+	sections=($"1)
+	manpage=$"2
+}
+if(~ $#* 1) {
+	manpage=$"1
+}
+if(~ $#manpage 0) {
+	echo 'usage: wman [section] manpage'
+	exit 'usage'
+}
+if(~ $#sections 0) {
+	manfiles=`{man -w $manpage}
+	for(mp in $manfiles) {
+		sectionno=`{basename `{basename -d $mp}}
+		sections=($sectionno $sections)
+	}
+}
+
+for (section in $sections) {
+	wplabel=$"manpage^'('^$"section^')'
+	window 'man '^$section^' '^$"manpage^' ;& label '''^$"wplabel^'''; cat /dev/cons >/dev/null'
+}
--- /dev/null
+++ b/bin/rc/wp
@@ -1,0 +1,7 @@
+#!/bin/rc
+
+rfork ne
+wplabel=$1
+shift
+
+exec window $"*^'; label '''^$"wplabel^'''; cat /dev/cons >/dev/null'