mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-29 03:55:42 +08:00
plugin.writeConfig
This commit is contained in:
6
Makefile
6
Makefile
@@ -3,12 +3,6 @@ all: install
|
|||||||
install:
|
install:
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
build: install
|
|
||||||
node node_modules/coffee-script/bin/coffee -c .
|
|
||||||
|
|
||||||
clean:
|
|
||||||
find . -path './node_modules' -prune -o -name '*.js' -exec rm -fr {} \;
|
|
||||||
|
|
||||||
clean_socket:
|
clean_socket:
|
||||||
-rm ../rootpanel.sock
|
-rm ../rootpanel.sock
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,9 @@ RP3 的核心功能包括:
|
|||||||
make install # 安装依赖
|
make install # 安装依赖
|
||||||
make run # 直接运行
|
make run # 直接运行
|
||||||
make test # 运行测试
|
make test # 运行测试
|
||||||
make build # 生成 .js
|
make start # 以 forever 启动
|
||||||
make clean # 删除生成的 .js
|
make restart # 重启 forever 进程
|
||||||
make start # 以 pm2 启动
|
make stop # 停止 forever 进程
|
||||||
make restart # 重启 pm2 进程
|
|
||||||
make stop # 停止 pm2 进程
|
|
||||||
|
|
||||||
## 技术构成
|
## 技术构成
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
child_process = require 'child_process'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
|
tmp = require 'tmp'
|
||||||
|
fs = require 'fs'
|
||||||
|
|
||||||
i18n = require './i18n'
|
i18n = require './i18n'
|
||||||
config = require './../config'
|
config = require './../config'
|
||||||
@@ -15,3 +18,16 @@ exports.loadPlugins = (app) ->
|
|||||||
|
|
||||||
if plugin.action
|
if plugin.action
|
||||||
app.use ('/plugin/' + name), plugin.action
|
app.use ('/plugin/' + name), plugin.action
|
||||||
|
|
||||||
|
exports.writeConfig = (path, content, callback) ->
|
||||||
|
tmp.file
|
||||||
|
mode: 0o750
|
||||||
|
, (err, filepath, fd) ->
|
||||||
|
fs.writeSync fd, content, 0, 'utf8'
|
||||||
|
fs.closeSync fd
|
||||||
|
|
||||||
|
child_process.exec "sudo cp #{filepath} #{path}", (err) ->
|
||||||
|
throw err if err
|
||||||
|
|
||||||
|
fs.unlink path, ->
|
||||||
|
callback
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
child_process = require 'child_process'
|
child_process = require 'child_process'
|
||||||
|
|
||||||
service = require './service'
|
service = require './service'
|
||||||
plugin = require '../../core/plugin'
|
|
||||||
configure = require './configure'
|
configure = require './configure'
|
||||||
|
|
||||||
{requestAuthenticate, getParam} = require '../../core/router/middleware'
|
{requestAuthenticate, getParam} = require '../../core/router/middleware'
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
child_process = require 'child_process'
|
child_process = require 'child_process'
|
||||||
jade = require 'jade'
|
jade = require 'jade'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
tmp = require 'tmp'
|
|
||||||
fs = require 'fs'
|
fs = require 'fs'
|
||||||
|
|
||||||
|
plugin = require '../../core/plugin'
|
||||||
|
|
||||||
mAccount = require '../../core/model/account'
|
mAccount = require '../../core/model/account'
|
||||||
|
|
||||||
template =
|
template =
|
||||||
@@ -36,18 +37,10 @@ module.exports =
|
|||||||
user_configure = _.template template.user_configure,
|
user_configure = _.template template.user_configure,
|
||||||
sites: sites_configure
|
sites: sites_configure
|
||||||
|
|
||||||
tmp.file
|
plugin.writeConfig "/etc/nginx/sites-enabled/#{account.username}.conf", user_configure, ->
|
||||||
mode: 0o750
|
child_process.exec 'sudo service nginx reload', (err) ->
|
||||||
, (err, filepath, fd) ->
|
|
||||||
fs.writeSync fd, user_configure, 0, 'utf8'
|
|
||||||
fs.closeSync fd
|
|
||||||
|
|
||||||
child_process.exec "sudo cp #{filepath} /etc/nginx/sites-enabled/#{account.username}.conf", (err) ->
|
|
||||||
throw err if err
|
throw err if err
|
||||||
|
callback()
|
||||||
child_process.exec 'sudo service nginx reload', (err) ->
|
|
||||||
throw err if err
|
|
||||||
callback()
|
|
||||||
|
|
||||||
widget: (account, callback) ->
|
widget: (account, callback) ->
|
||||||
jade.renderFile path.join(__dirname, 'view/widget.jade'),
|
jade.renderFile path.join(__dirname, 'view/widget.jade'),
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
child_process = require 'child_process'
|
child_process = require 'child_process'
|
||||||
|
|
||||||
service = require './service'
|
service = require './service'
|
||||||
plugin = require '../../core/plugin'
|
|
||||||
{assertInService} = require '../../core/router/middleware'
|
{assertInService} = require '../../core/router/middleware'
|
||||||
|
|
||||||
mAccount = require '../../core/model/account'
|
mAccount = require '../../core/model/account'
|
||||||
|
|||||||
@@ -23,26 +23,20 @@ module.exports =
|
|||||||
callback()
|
callback()
|
||||||
|
|
||||||
switch: (account, is_enable, callback) ->
|
switch: (account, is_enable, callback) ->
|
||||||
callbackback = ->
|
restartPhpfpm = ->
|
||||||
child_process.exec 'sudo service php5-fpm restart', (err) ->
|
child_process.exec 'sudo service php5-fpm restart', (err) ->
|
||||||
throw err if err
|
throw err if err
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
if is_enable
|
if is_enable
|
||||||
tmp.file
|
config_content = _.template (fs.readFileSync path.join(__dirname, 'template/fpm-pool.conf')).toString(),
|
||||||
mode: 0o750
|
account: account
|
||||||
, (err, filepath, fd) ->
|
|
||||||
config_content = _.template (fs.readFileSync path.join(__dirname, 'template/fpm-pool.conf')).toString(),
|
|
||||||
account: account
|
|
||||||
fs.writeSync fd, config_content, 0, 'utf8'
|
|
||||||
fs.closeSync fd
|
|
||||||
|
|
||||||
child_process.exec "sudo cp #{filepath} /etc/php5/fpm/pool.d/#{account.username}.conf", (err) ->
|
plugin.writeConfig "/etc/php5/fpm/pool.d/#{account.username}.conf", config_content, ->
|
||||||
throw err if err
|
restartPhpfpm()
|
||||||
callbackback()
|
|
||||||
else
|
else
|
||||||
child_process.exec "sudo rm /etc/php5/fpm/pool.d/#{account.username}.conf", ->
|
child_process.exec "sudo rm /etc/php5/fpm/pool.d/#{account.username}.conf", ->
|
||||||
callbackback()
|
restartPhpfpm()
|
||||||
|
|
||||||
widget: (account, callback) ->
|
widget: (account, callback) ->
|
||||||
jade.renderFile path.join(__dirname, 'view/widget.jade'), {account: account}, (err, html) ->
|
jade.renderFile path.join(__dirname, 'view/widget.jade'), {account: account}, (err, html) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user