Ubuntu 添加多用户和Samba

USERNAME="$1"
SMBFILE="/etc/samba/smb.conf"

if [ $# != 1 ]
then
	echo "使用方: ./user-create.sh username"
	exit
fi

echo "你输入的用户名: $USERNAME"

#添加用户
echo "正在添加用户"
sudo adduser $USERNAME

#修改用户组
echo "正在修改用户组"
sudo usermod -g simcom $USERNAME
sudo usermod -G simcom $USERNAME

#添加samba用户
echo "正在添加samba用户"
sudo smbpasswd -a $USERNAME

sudo echo -e "\n" >> $SMBFILE
sudo echo "[$USERNAME]" >> $SMBFILE
sudo echo "    comment = work_space" >> $SMBFILE
sudo echo "    browseable = yes" >> $SMBFILE
sudo echo "    path = /home/$USERNAME/" >> $SMBFILE
sudo echo "    create mask = 0777" >> $SMBFILE
sudo echo "    directory mask = 0777" >> $SMBFILE
sudo echo "    valid users = $USERNAME" >> $SMBFILE
sudo echo "    public = yes" >> $SMBFILE
sudo echo "    available = yes" >> $SMBFILE
sudo echo "    writable = yes" >> $SMBFILE

如果本文对你有帮助,请不要吝啬你的赞!转载请务必注明来源!

PYPYN.COM 版权所有

发表评论

您的电子邮箱地址不会被公开。