12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- "use strict";
- var Controller = require('./../framework/Controller.js');
- var process = require('child_process');
- var php = require('phpjs');
- var $white_ip_array = ['183.60.177.224/27','58.248.138.0/28', '113.108.232.32/28', '172.16.53.148/8'];
- class SystemController extends Controller {
- check_ip(ip_array) {
- var remote_ip = getClientIp();
- return checkIpRange(remote_ip, $white_ip_array);
- }
- /**
- * 安装依赖的组件
- */
- actionNpmInstall() {
- var that = this;
- //不在ip白名单内,显示404页面
- if( !that.check_ip($white_ip_array) ){
- that._res.statusCode = 302;
- that._res.header('Location', '/public/403.html');
- that.exitMsg('...');
- } else {
- process.exec('npm install &', function(err, stdout, stderr) {
- if (err) {
- that.exitMsg('出错啦...【' + err + '】')
- } else {
- that.exitMsg('执行完毕:' + stdout);
- }
- });
- }
- }
- /**
- * 重启服务
- */
- actionRestart() {
- var that = this;
- //不在ip白名单内,显示404页面
- if( !that.check_ip($white_ip_array) ){
- that._res.statusCode = 302;
- that._res.header('Location', '/public/403.html');
- that.exitMsg('...');
- } else {
- process.exec('/bin/bash ./admin/restart.sh &');
- that.exitMsg('restart');
- }
- }
- }
- module.exports = SystemController;
|