ref: 5f392fec7dd509cf62d55e3b53faf6675f32f8de
parent: b2571022c75be091e743a58c487105af200de28b
author: mkf <mkf@cloud9p.org>
date: Mon Sep 23 01:13:00 EDT 2024
newuser: make sponsermail optional, generate password if none specfied
--- a/newuser
+++ b/newuser
@@ -1,38 +1,23 @@
#!/bin/rc
run_newuser=t
+args=()
fn usage {
- echo 'usage: newuser [-n] [-d dept] [-e email] [-i postid] sponsormail user pass' >[1=2]
+ echo 'usage: newuser [-n] [-d dept] [-e email] [-i postid] [-s sponsormail] user [pass]' >[1=2]
exit 'usage'
}
-while (~ $1 -*) {
- switch ($1) {
- case -[dier]
- if(~ $#x 0) x=$1 $2
- if not x=$x $1 $2
- shift
- case -n
- run_newuser=f
- case -*
- usage
- }
- shift
-}
+fn newu {
+ u=$1
+ p=$2
-if (~ $#* 3) {
-
- s=$1
- u=$2
- p=$3
-
auth/keyfs
if(test -w /srv/cwfs.cmd){
echo newuser $u >> /srv/cwfs.cmd
- wm/chusr $x -s $s -p $p $u
+ wm/chusr $args -p $p $u
if(~ $run_newuser t) {
- # auth/as $u /sys/lib/newuserb # messes up with namespace
+ # auth/as $u /sys/lib/newuser # messes up with namespace
if(! test -f /env/authdom)
authdom=`{ndb/query sys $sysname authdom}
@@ -50,8 +35,30 @@
echo 'no cwfs.cmd or access to it'>[2=1]
exit 'no cwfs.cmd or access to it'
}
+}
+while (~ $1 -*) {
+ switch ($1) {
+ case -[sdier]
+ if(~ $#x 0)
+ args=$args $1 $2
+ shift
+ case -n
+ run_newuser=f
+ case -*
+ usage
+ }
+ shift
}
+
+if (~ $#* 1) {
+ pass=`{fortune /lib/dict/pgwindex | awk '{ print $1 }'}
+ pass=($pass `{fortune /lib/dict/pgwindex | awk '{ print $1 }'})
+ newu $1 $pass
+}
+
+if (~ $#* 2)
+ newu $1 $2
if not
usage