为使用samba 的net usershare命令,需要创建共享路径"/var/lib/samba/usershares"和组sambashare
并且将已有的用户添加到sambashare中。
#! /bin/sh USERSHARES_DIR="/var/lib/samba/usershares" USERSHARES_GROUP="sambashare" HAVE_SHARES_GROUP=`awk -F : '{name = $1;if(name=="sambashare")print $1}' /etc/group` if test "x$HAVE_SHARES_GROUP" = "x" ; then /usr/sbin/groupadd ${USERSHARES_GROUP} fi mkdir -p ${USERSHARES_DIR} chown root:${USERSHARES_GROUP} ${USERSHARES_DIR} chmod 01770 ${USERSHARES_DIR} for USERSHARES_NAME in $(grep /home /etc/passwd | cut -f1 -d:) do /usr/sbin/usermod -a -G ${USERSHARES_GROUP} ${USERSHARES_NAME} done