mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
up
This commit is contained in:
+23
-2
@@ -4,6 +4,8 @@ import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import socket
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
@@ -460,9 +462,28 @@ class App:
|
||||
data = mi.mail_init().check_env()
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
|
||||
def change_hostname(self):
|
||||
'''
|
||||
mac
|
||||
sudo scutil --set HostName mac_hostname.vm
|
||||
'''
|
||||
args = self.getArgs()
|
||||
hostname = args['hostname']
|
||||
rep_domain = "^(?=^.{3,255}$)[a-zA-Z0-9\_\-][a-zA-Z0-9\_\-]{0,62}(\.[a-zA-Z0-9\_\-][a-zA-Z0-9\_\-]{0,62})+$"
|
||||
if not re.search(rep_domain, hostname):
|
||||
return mw.returnJson(False, "请输入完整域名,例如 mail.bt.com),")
|
||||
mw.execShell('hostnamectl set-hostname --static {}'.format(hostname))
|
||||
h = socket.gethostname()
|
||||
if h == hostname:
|
||||
return mw.returnJson(True, "设置成功!")
|
||||
return mw.returnJson(False, "设置失败!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
classApp = App()
|
||||
data = eval("classApp." + func + "()")
|
||||
print(data)
|
||||
try:
|
||||
data = eval("classApp." + func + "()")
|
||||
print(data)
|
||||
except Exception as e:
|
||||
print('error:' + str(e))
|
||||
|
||||
+60
-2
@@ -462,9 +462,14 @@ var mail = {
|
||||
case 'Dovecot-install':
|
||||
_key = 'repair_dovecot';
|
||||
break;
|
||||
case 'HostName':
|
||||
_key = 'repair_host_name';
|
||||
break;
|
||||
}
|
||||
if (key == 'HostName'){
|
||||
this.repair_host_name();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(key,_key);
|
||||
|
||||
this.send({
|
||||
tips: '正在修复' + key + ',请稍候...',
|
||||
@@ -475,7 +480,60 @@ var mail = {
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 修复hostname
|
||||
repair_host_name: function () {
|
||||
var _this = this;
|
||||
layer.open({
|
||||
type: 1,
|
||||
shift: 5,
|
||||
closeBtn: 1,
|
||||
shadeClose: false,
|
||||
title: '修复【主机名】',
|
||||
btn: ['确定', '取消'],
|
||||
area: "400px",
|
||||
content: '\
|
||||
<div class="bt-form pd20">\
|
||||
<div class="line">\
|
||||
<span class="tname">域名</span>\
|
||||
<div class="info-r" style="margin-left: 102px;">\
|
||||
<input class="bt-input-text" type="text" name="hostname" style="width: 190px" />\
|
||||
</div>\
|
||||
</div>\
|
||||
<ul class="help-info-text c7">\
|
||||
<li>请输入你的完整域名,如:mail.mw.cn</li>\
|
||||
</ul>\
|
||||
</div>',
|
||||
success: function ($layer, index) {
|
||||
},
|
||||
yes: function(index){
|
||||
var hostname = $('input[name="hostname"]').val().trim();
|
||||
if (hostname === '') {
|
||||
layer.msg('请输入你的完整域名', { icon: 2, closeBtn: true });
|
||||
return
|
||||
}
|
||||
_this.change_hostname({
|
||||
hostname: hostname,
|
||||
}, function (res) {
|
||||
layer.close(index);
|
||||
_this.create_post_env_table();
|
||||
layer.msg(res.msg, { icon: res.status ? 1 : 5 });
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 一键修复主机名
|
||||
change_hostname: function(data, callback){
|
||||
this.send({
|
||||
tips: '正在获取修复主机名, 请稍候...',
|
||||
method: 'change_hostname',
|
||||
data: data,
|
||||
success: function (res) {
|
||||
if (callback) callback(res);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
str2Obj:function(str){
|
||||
var data = {};
|
||||
|
||||
Reference in New Issue
Block a user