ref: ad872eeb19b4fcc41a5d34750ca6cdcf88a39795
dir: /lpa/
#!/bin/rc rfork ens id=0 readonly=0 printlist=0 fn usage{ echo 'usage: lpa [-n session | -r session | -l]' exit 'usage' } fn nosession{ echo 'session '^$id^' does not exist (or lpafs is not running)' exit 'no such session' } while(~ $1 -*){ switch($1){ case -n if(! ~ $id 0) usage id=$2 shift case -r if(! ~ $id 0) usage readonly=1 id=$2 shift case -l if(! ~ $id 0) usage printlist=1 case -* usage } shift } if(! ~ $#* 0) usage # Start LPA if it isn't already running if(! test -f /srv/lpa){ if(! ~ $id 0) nosession lpafs } if not mount /srv/lpa /mnt/lpa if(~ $printlist 1){ echo `{cd /mnt/lpa; ls | grep -v '^new$'} exit } if(~ $id 0) id=`{cat /mnt/lpa/new} if not{ if(! test -d /mnt/lpa/$id/) nosession } cd /mnt/lpa/$id label LPA session $id if(~ $readonly 1) cat cons if not{ cat cons & while(line=`''{read}){ n=`{tail -1l /dev/text | sed 's/^[ ]*//' | wc -r} # number of runes to delete awk 'END { for(i = 0; i < '^$n^'; i++) printf("\b"); }' /dev/text echo -n $line > cons } }