Samba user adder BETA

A simple script because I couldn't add it to LUCI :frowning:

Maybe it will help someone..... Warning though..... it needs a few fixes before it's production quality.....

/usr/sbin/addsmbuser.sh

#!/bin/sh

# save this to /usr/sbin/addsmbuser.sh
# fix permissions: chmod +x /usr/sbin/addsmbuser.sh

# make sure you have luci commands plugin 
# opkg update; opkg install luci-app-commands

# login to luci and go to system > custom commands > configure
#DESCRIPTION: addsmbuser
#COMMAND: addsmbuser.sh
#CUSTOMARGUMENTS: checked
#save and apply

# Go back to dashboard
# In arguments type the: username password



if [ -z $1 ]; then echo "$0 <username> <password>" && exit 0; fi
if [ -z $2 ]; then echo "$0 <username> <password>" && exit 0; fi

GNUM=`cat /etc/passwd | cut -d':' -f3 | grep '^...$' | tail -n 1`
NGNUM=`expr $GNUM + 1`; SHELL="/bin/false"; HDIR="/home"

echo "$1:x:$NGNUM:$NGNUM:$1:/$HDIR/$1:$SHELL" >> /etc/passwd
echo "$1:*:17912:0:99999:7:::" >> /etc/shadow
echo "$1:x:$NGNUM:$1" >> /etc/group
(echo $2; echo $2) | smbpasswd -a -s $1
mkdir -p /home/$1; chmod 755 /home; chown $1:$1 /home/$1

echo "hopefully added: $1"