This commit is contained in:
jysperm
2014-11-19 08:19:28 +08:00
parent 86e27fe855
commit 1099fba34f
8 changed files with 61 additions and 20 deletions

View File

@@ -4,6 +4,7 @@
224 commits, 202 changed files with 6682 additions and 4047 deletions, by 1 contributors: jysperm, yudong.
* (新增) 基于 Travis-CI 的自动测试,增加了 Vagrantfile
* (新增) reconfigure 功能,重新应用配置
* (新增) 完成了 Supervisor 插件
* (改进) 重构了 linux, rpvhost, ssh, shadowsocks 插件
* (改进) 重构了数据库升级迁移框架
@@ -12,7 +13,7 @@
* (改进) 重构了插件机制,增强了 hook 的功能,所有插件继承自 Plugin 类
* (改进) 重构了结算机制
* (改进) 重构了国际化组件,支持更好地 fallback, 为前端添加了国际化支持,添加了语言选择功能
* (改进) 将视图文件中全部的字符串提取为了语言资源文件
* (改进) 将视图文件中全部的字符串提取为了语言资源文件,并翻译了英文版本
* (改进) 从源代码中移除配置文件,在 `sample` 目录提供一组默认配置文件
* (改进) 将 WIKI 抽取为了一个独立的插件,自动生成 WIKI 列表,代替原 WIKI 首页
* (改进) 将比特币支付功能抽取为了一个独立的插件

View File

@@ -34,18 +34,30 @@
rm /etc/nginx/sites-enabled/default
vi /etc/nginx/sites-enabled/rpadmin
ssl_certificate /home/rpadmin/rpvhost.crt;
ssl_certificate_key /home/rpadmin/keys/rpvhost.key;
ssl_session_cache shared:SSL:10m;
server {
listen 80 default_server;
listen 443 ssl default_server;
listen [::]:80 default_server ipv6only=on;
rewrite ^/(.*)$ http://rp.rpvhost.net/#redirect permanent;
rewrite .* $scheme://rp.rpvhost.net/#redirect redirect;
}
server {
listen 80;
listen 443 ssl;
server_name rp.rpvhost.net;
location ~ /\.git {
deny all;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://unix:/home/rpadmin/rootpanel.sock:/;
@@ -55,6 +67,8 @@
useradd -m rpadmin
usermod -G rpadmin -a www-data
mkdir -m 750 /home/rpadmin/keys
vi /etc/sudoers
rpadmin ALL=(ALL) NOPASSWD: ALL
@@ -90,7 +104,7 @@
service redis-server restart
service supervisor restart
### Plugin
### Plugins
# Linux
apt-get install quota quotatool
@@ -118,7 +132,7 @@
# PHP-FPM
apt-get install php5-cli php5-fpm php-pear php5-mysql php5-curl php5-gd php5-imap php5-mcrypt php5-memcache php5-tidy php5-xmlrpc php5-sqlite php5-mongo
apt-get install php5-fpm php-pear php5-readline php5-mysql php5-curl php5-gd php5-imap php5-mcrypt php5-memcache php5-tidy php5-xmlrpc php5-sqlite php5-mongo
rm /etc/php5/fpm/pool.d/www.conf
@@ -137,13 +151,14 @@
ulimit -n 51200
iptables -A OUTPUT -p tcp --dport 25 -j DROP
iptables -A OUTPUT -p tcp --dport 25 -d smtp.postmarkapp.com -j ACCEPT
iptables -A OUTPUT -p tcp --dport 25 -j DROP
iptables-save > /etc/iptables.rules
### Runtime
# Shell
aot-get install screen wget zip unzip iftop vim curl htop iptraf nethogs
apt-get install screen wget zip unzip iftop vim curl htop iptraf nethogs
apt-get install libcurl4-openssl-dev axel unrar-free emacs subversion subversion-tools tmux mercurial postfix
# Golang

View File

@@ -33,7 +33,7 @@ RootPanel 具有良好的设计,高度的可定制性,支持多语言和多
supervisorctl stop RootPanel
# 备份数据库
mongodump --db RootPanel --out .backup/db -u rpadmin -p
mongodump --authenticationDatabase admin --db RootPanel --out .backup/db -u rpadmin -p
# 更新源代码
git pull

View File

@@ -13,14 +13,18 @@ Account.find
async.eachSeries accounts, (account, callback) ->
original_account = account
services = _.flatten _.compact _.map account.billing.plans, (plan) ->
plans = _.filter account.billing.plans, (plan) ->
return config.plans[plan]
services = _.uniq _.flatten _.compact _.map plans, (plan) ->
return config.plans[plan]?.services
if _.isEqual account.billing.services, services
if _.isEqual(account.billing.services, services) and _.isEqual(account.billing.plans, plans)
return callback()
Account.findByIdAndUpdate account._id,
$set:
'billing.plans': plans
'billing.services': services
, (err, account) ->
services = account.billing.services

View File

@@ -23,10 +23,10 @@ module.exports = (db, callback) ->
bitcoin_secret = crypto.createHash('sha256').update(crypto.randomBytes(256)).digest('hex')
genAddress bitcoin_secret, (address) ->
mAccount.update {_id: account._id},
cAccount.update {_id: account._id},
$set:
'attribute.bitcoin_deposit_address': address
'bitcoin_secret': bitcoin_secret
'attribute.bitcoin_secret': bitcoin_secret
, callback
, (err) ->

View File

@@ -50,6 +50,9 @@ module.exports = (db, callback) ->
for plan_name in account.attribute.plans
last_billing_at[plan_name] = account.attribute.last_billing_at
if account.attribute.plugin.nginx
delete account.attribute.plugin.nginx
cAccount.update {_id: account._id},
$set:
email: account.email.toLowerCase()
@@ -67,7 +70,6 @@ module.exports = (db, callback) ->
last_billing_at: last_billing_at
$unset:
attribute: true
setting: true
signup_at: true
group: true
@@ -105,7 +107,8 @@ module.exports = (db, callback) ->
callback()
, ->
db.dropCollection 'balance_log', callback
db.dropCollection 'balance_log', ->
callback()
(callback) ->
console.log '[couponcodes] beginning'
@@ -130,7 +133,8 @@ module.exports = (db, callback) ->
callback()
, ->
db.dropCollection 'coupon_code', callback
db.dropCollection 'coupon_code', ->
callback()
(callback) ->
console.log '[securitylogs] beginning'
@@ -177,7 +181,8 @@ module.exports = (db, callback) ->
callback()
, ->
db.dropCollection 'security_log', callback
db.dropCollection 'security_log', ->
callback()
(callback) ->
console.log '[tickets] beginning'

View File

@@ -17,10 +17,13 @@ exports.registerHook 'view.layout.menu_bar',
exports.registerHook 'account.username_filter',
filter: (username, callback) ->
linux.getPasswdMap (passwd_map) ->
if username in _.values passwd_map
callback false
else
callback true
linux.getGroup (group_map) ->
if username in _.values passwd_map
callback false
else if username in _.values group_map
callback false
else
callback true
exports.registerHook 'view.panel.styles',
path: '/plugin/linux/style/panel.css'

View File

@@ -60,6 +60,19 @@ exports.getPasswdMap = (callback) ->
SETEX result, 120
, callback
exports.getGroup = (callback) ->
cache.try 'linux.getGroup', (SETEX) ->
fs.readFile '/etc/group', (err, content) ->
logger.error err if err
result = {}
for line in _.compact(content.toString().split '\n')
[name, password, uid] = line.split ':'
result[uid] = name
SETEX result, 120
, callback
exports.getMemoryInfo = (callback) ->
cache.try 'linux.getMemoryInfo', (SETEX) ->
fs.readFile '/proc/meminfo', (err, content) ->