Created
May 31, 2012 07:25
-
-
Save hothero/2841659 to your computer and use it in GitHub Desktop.
Script for creating amount of Filezilla Server User account configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/md5' | |
num = 36 # total number we want to create | |
user_info = File.new('user_info.txt', 'w+') | |
config_content = File.new('config_content.txt', 'w+') | |
(1..num).each do |t_num| | |
team_name = "team#{t_num}" | |
passwd = (0...6).map{97.+(rand(25)).chr}.join # random a string for password | |
user_info.write("#{team_name}\t#{passwd}\n") | |
passwd = Digest::MD5.hexdigest(passwd) # encoding string to md5 format | |
user_config = %(<User Name="#{team_name}"> | |
<Option Name="Pass">#{passwd}</Option> | |
<Option Name="Group">2012web_final_project</Option> | |
<Option Name="Bypass server userlimit">2</Option> | |
<Option Name="User Limit">0</Option> | |
<Option Name="IP Limit">0</Option> | |
<Option Name="Enabled">1</Option> | |
<Option Name="Comments"></Option> | |
<Option Name="ForceSsl">2</Option> | |
<IpFilter> | |
<Disallowed /> | |
<Allowed /> | |
</IpFilter> | |
<Permissions> | |
<Permission Dir="D:\\Course\\WebProgram2012\\#{team_name}"> | |
<Option Name="FileRead">1</Option> | |
<Option Name="FileWrite">1</Option> | |
<Option Name="FileDelete">1</Option> | |
<Option Name="FileAppend">1</Option> | |
<Option Name="DirCreate">1</Option> | |
<Option Name="DirDelete">1</Option> | |
<Option Name="DirList">1</Option> | |
<Option Name="DirSubdirs">1</Option> | |
<Option Name="IsHome">1</Option> | |
<Option Name="AutoCreate">0</Option> | |
</Permission> | |
</Permissions> | |
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2"> | |
<Download /> | |
<Upload /> | |
</SpeedLimits> | |
</User>) | |
config_content.write("#{user_config}\n") | |
end | |
user_info.close | |
config_content.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment