linux的共享服务器samba,不经常使用有点忘记怎么配置,奉献安装及创建脚本一份!已经经过本人测试。若是访问共享文件夹出现不能写入的问题,修改本地系统的selinux 关闭selinux

#!/bin/bash
#an zhuang tian jia gong xiang
#written by yingzi234
yum -y install samba samba-client
echo "First you should add user"
echo -e "Input username you want to add:"
read account
useradd $account
echo -e "Input share path you want to add:"
read path
mkdir -p $path
chown -R $account $path
echo -e "Input share name: "
read sharename
echo -e "[$sharename]" >>/etc/samba/smb.conf
echo -e "path = $path" >>/etc/samba/smb.conf
echo -e "writeable = yes" >>/etc/samba/smb.conf
echo -e "browseable = yes" >>/etc/samba/smb.conf
echo -e "create mask = 0664" >>/etc/samba/smb.conf
echo -e "directory mask=0777" >>/etc/samba/smb.conf
echo "Confirm that you want to give written permission,input [y|n]"
read ans
if [[ $ans = [yY] ]]
then
echo -e "write list = $account" >>/etc/samba/smb.conf
else
echo -e "read list = $account" >>/etc/samba/smb.conf
echo
fi
echo "Now you must add your samba account ! If you want to delete samba account you can use smbpasswd -x account "
smbpasswd -e $account
smbpasswd -a $account
service smb restart