db hook to manage files
This commit is contained in:
parent
c5e79fc427
commit
697c896277
1
.gitignore
vendored
1
.gitignore
vendored
@ -62,3 +62,4 @@ application.yml
|
|||||||
# Ignore application configuration
|
# Ignore application configuration
|
||||||
/config/application.yml
|
/config/application.yml
|
||||||
.container-setup
|
.container-setup
|
||||||
|
_vsftpd
|
||||||
|
@ -12,6 +12,10 @@ Style/ClassAndModuleChildren:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- test/test_helper.rb
|
- test/test_helper.rb
|
||||||
|
|
||||||
|
Style/ClassVars:
|
||||||
|
Exclude:
|
||||||
|
- test/test_helper.rb
|
||||||
|
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
@ -1 +1,3 @@
|
|||||||
A simple FTP Virtual User manager
|
A simple FTP Virtual User manager
|
||||||
|
|
||||||
|
* be sure to set up config/application.yml[.sample]
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
client-two:$1$Uoqdsd1f$A39luV6N91OtA/VvcdBfC0
|
|
||||||
client-one:$1$cVA6ZMIU$K/ITsDMZWeEDFEvoWk0op.
|
|
||||||
client-three:$1$pGYnsuhu$3MPEsgikbEhX1mZQE/qDc/
|
|
@ -1 +0,0 @@
|
|||||||
local_root=_vsftpd/root/client_one
|
|
@ -1 +0,0 @@
|
|||||||
local_root=_vsftpd/root/client_three
|
|
@ -1 +0,0 @@
|
|||||||
local_root=_vsftpd/root/client_two
|
|
@ -6,4 +6,12 @@ class Account < ApplicationRecord
|
|||||||
validates :password, presence: true
|
validates :password, presence: true
|
||||||
validates :home_folder, presence: true
|
validates :home_folder, presence: true
|
||||||
validates :contact_email, presence: true, email_format: true
|
validates :contact_email, presence: true, email_format: true
|
||||||
|
|
||||||
|
after_commit :update_vsftpd_files
|
||||||
|
|
||||||
|
def update_vsftpd_files
|
||||||
|
vsftp = FtpConfig.new
|
||||||
|
vsftp.build_password_list Account.all
|
||||||
|
vsftp.build_user_configs self
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
2
test/fixtures/accounts.yml
vendored
2
test/fixtures/accounts.yml
vendored
@ -8,7 +8,7 @@ account1:
|
|||||||
|
|
||||||
account2:
|
account2:
|
||||||
username: client-two
|
username: client-two
|
||||||
password: <%= CryptSerializer.dump('azsxdcfvgbhnjmk,l.;/') %>
|
password: <%= CryptSerializer.dump('azsxdcfvgbhnjmk,l') %>
|
||||||
home_folder: client_two
|
home_folder: client_two
|
||||||
contact_email: ftp-user@mailinator.com
|
contact_email: ftp-user@mailinator.com
|
||||||
|
|
||||||
|
@ -24,4 +24,17 @@ class ActiveSupport::TestCase
|
|||||||
|
|
||||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||||
fixtures :all
|
fixtures :all
|
||||||
|
|
||||||
|
@@files_checked = false
|
||||||
|
def verify_test_files
|
||||||
|
return if @@files_checked
|
||||||
|
|
||||||
|
FileUtils.mkdir_p AppConfig.ftpusers
|
||||||
|
FileUtils.touch AppConfig.htpasswd
|
||||||
|
@@files_checked = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup
|
||||||
|
verify_test_files
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user