磁盘资源文件限制

This commit is contained in:
jysperm
2014-07-29 02:36:44 +08:00
parent 5e718052aa
commit e043187faf
3 changed files with 19 additions and 4 deletions

View File

@@ -8,10 +8,12 @@ exports.joinPlan = (account, plan, callback) ->
if serviceName in account.attribute.services
return callback()
mAccount.update _id: account._id,
mAccount.findAndModify _id: account._id, {},
$addToSet:
'attribute.services': serviceName
, ->
,
new: true
, (err, account)->
(plugin.get serviceName).service.enable account, ->
callback()

View File

@@ -6,7 +6,8 @@ $ ->
if $(@).attr('href') == location.pathname
$(@).parent().addClass('active')
$('#logout').click ->
$('#logout').click (e) ->
e.preventDefault()
$.post '/account/logout/', {}
.success ->
location.reload()

View File

@@ -9,7 +9,19 @@ module.exports =
enable: (account, callback) ->
child_process.exec "sudo useradd -m -s /bin/bash #{account.username}", (err, stdout, stderr) ->
throw err if err
child_process.exec "sudo usermod -G #{account.username} -a www-data", (err, stdout, stderr) ->
async.parallel [
(callback) ->
child_process.exec "sudo usermod -G #{account.username} -a www-data", callback
(callback) ->
soft_limit = (account.attribute.resources_limit.storage * 1024 * 0.8).toFixed()
hard_limit = (account.attribute.resources_limit.storage * 1024 * 1.2).toFixed()
soft_inode_limit = (account.attribute.resources_limit.storage * 64 * 0.8).toFixed()
hard_inode_limit = (account.attribute.resources_limit.storage * 64 * 1.2).toFixed()
child_process.exec "sudo setquota -u #{account.username} #{soft_limit} #{hard_limit} #{soft_inode_limit} #{hard_inode_limit} -a", callback
], (err) ->
throw err if err
callback()
delete: (account, callback) ->