35 lignes
Pas d'EOL
1,4 Kio
Batchfile
35 lignes
Pas d'EOL
1,4 Kio
Batchfile
@echo off
|
|
:: sambaUsers - prepare script and configuration for your linux samba server from some windows computer
|
|
:: Release history:
|
|
:: V1 - initial release
|
|
|
|
:: usersFolder is the mounted smb share where user folders will be created
|
|
set usersFolder=Z:\users
|
|
:: userlist contains list of users to be created, each line must contains only user:pass
|
|
set userList=%usersFolder%\userlist.txt
|
|
:: sambaPath is server-side internal path where users folder will be located
|
|
set sambaPath=/srv/shares/users
|
|
:: usrGroup is the name of the group of our users
|
|
set usrGroup=tai
|
|
|
|
echo #!/bin/bash> userStep.sh
|
|
echo groupeadd %usrGroup%>> userStep.sh
|
|
echo.> sambaConf.txt
|
|
for /F "tokens=1,2 delims=:" %%i in (%userList%) do (
|
|
mkdir %usersFolder%\%%i
|
|
rem net user %%i:%%j /add
|
|
rem cacls %usersFolder%\%%i /E /G %%i:r
|
|
rem cacls %usersFolder%\%%i /E /G %%i:w
|
|
echo [%%i]>> sambaConf.txt
|
|
echo path = %sambaPath%/%%i>> sambaConf.txt
|
|
echo read only = no>> sambaConf.txt
|
|
echo guest ok = no>> sambaConf.txt
|
|
echo valid users = %%i>> sambaConf.txt
|
|
echo write list = %%i>> sambaConf.txt
|
|
echo create mask = 0666>> sambaConf.txt
|
|
echo directory mask = 0777>> sambaConf.txt
|
|
echo usereadd -d /srv/users/%%i -g %usrGroup% -N -R -s /sbin/nologin %%i>> userStep.sh
|
|
echo echo "%%i:%%j" ^| chpasswd>> userStep.sh
|
|
)
|
|
echo Over. Please do not forget to convert line endings on bash script before use.
|
|
pause |