2 echo -e "Content-type: text/html\n\n";
4 this_page
="shares.manager_user"
9 sambadir
=$rootdir/samba
14 function create_user
() {
15 [ "$F_passwd" != "$F_passwd_cf" ] && echo "<h1>Password and confirmed password not matched !</h1>" && return
17 if echo $F_user_name |
egrep '\<admin\>|\<administrator\>'; then
21 sudo useradd
-m $useradd_arg $F_user_name
23 [ $ret != 0 ] && grep "useradd_err_$ret" $sambadir/samba
/useradd.err|
sed 's/.*=//' && return
25 (echo $F_passwd; echo $F_passwd) |sudo smbpasswd
-L -s -a $F_user_name
26 [ $admin_user = 1 ] && return
27 sudo
$sambadir/modify_samba_config.pl
/etc
/samba
/smb.conf
$F_user_name /home
/$F_user_name $F_user_name yes
28 echo "<h1>Add user \"$F_user_name\" OK!</h1>"
31 function update_user
() {
32 [ "$F_passwd" != "$F_passwd_cf" ] && echo "<h1>Password and confirmed password not matched !</h1>" && return
33 if sudo
cat /etc
/samba
/private
/smbpasswd | cut
-f1 -d: |
egrep "\<$F_user_name\>"; then
34 (echo $F_passwd; echo $F_passwd) |sudo passwd
-s -a $F_user_name
35 echo 'Changed password Succesfully! "'
38 echo "User $F_user_name not exist, Please create it."
42 function delete_user
() {
43 sudo smbpasswd
-x $F_delname >/dev
/null
44 sudo
$sambadir/modify_samba_config.pl
/etc
/samba
/smb.conf
$F_delname
46 sudo userdel
-r $F_delname 2>/dev
/null
48 [ $ret != 0 ] && grep "userdel_err_$ret" $sambadir/samba
/userdel.err|
sed 's/.*=//' && return
49 echo "<h1>Delete user \"$F_delname\" OK!</h1>"
58 #[ "$F_todo" = "" ] &&( $rootdir/shares/manager_user.lua; exit)
60 $rootdir/shares
/manager_user.lua
64 [ $F_todo != "delete" -a "$F_user_name" = "" ] && h_err_quit
"<font color=red>Please enter username</font>"
65 [ $F_todo != "delete" -a "$F_passwd" = "" ] && h_err_quit
"<font color=red>Please enter password</font>"
66 [ $F_todo != "delete" -a "$F_passwd_cf" = "" ] && h_err_quit
"<font color=red>Please enter confirm password</font>"
67 [ $F_todo = "delete" -a "$F_delname" = "" ] && h_err_quit
"<font color=red>Please enter username</font>"
70 [ "$F_todo" = "create" ] && create_user
73 [ "$F_todo" = "update" ] && update_user
76 [ "$F_todo" = "delete" ] && delete_user