werc-1.5.0-tweaks

Tweaks for the werc website builder created by the mad architect Uriel
Log | Files | Refs | README

addwuser.rc (606B)


      1 #!/bin/rc
      2 
      3 if(! ~ $#werc_root 0)
      4     cd $werc_root
      5 
      6 fn usage {
      7     if(! ~ $#* 0)
      8         echo $0: $* >[1=2]
      9     echo 'Usage:' $0 'user_name user_password [groups ...]' >[1=2]
     10     exit usage
     11 }
     12 
     13 if(! test -d etc/users/)
     14     usage 'Run for root of werc installation or set $werc_root'
     15 
     16 user_name=$1
     17 shift
     18 user_pass=$1
     19 shift
     20 user_groups=$*
     21 
     22 if(~ $"user_name '' || ~ $"user_pass '')
     23     usage 
     24 
     25 mkdir etc/users/$user_name
     26 echo $user_pass > etc/users/$user_name/password
     27 
     28 if(! ~ $#user_groups 0)
     29     for(g in $user_groups) {
     30         mkdir -p etc/users/$g
     31         echo $user_name >> etc/users/$g/members
     32     }
     33