mirror of https://github.com/jumpserver/jumpserver
add install wizzrd
parent
ef7f42cf6d
commit
5740dec7b4
|
@ -698,6 +698,11 @@ class Nav(object):
|
||||||
file_path = raw_input("\033[1;32mPath>:\033[0m ").strip()
|
file_path = raw_input("\033[1;32mPath>:\033[0m ").strip()
|
||||||
if file_path == 'q':
|
if file_path == 'q':
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if not file_path:
|
||||||
|
print "文件路径为空"
|
||||||
|
continue
|
||||||
|
|
||||||
runner.run('fetch', module_args='src=%s dest=%s' % (file_path, tmp_dir), pattern=pattern)
|
runner.run('fetch', module_args='src=%s dest=%s' % (file_path, tmp_dir), pattern=pattern)
|
||||||
ret = runner.results
|
ret = runner.results
|
||||||
FileLog(user=self.user.name, host=asset_name_str, filename=file_path, type='download',
|
FileLog(user=self.user.name, host=asset_name_str, filename=file_path, type='download',
|
||||||
|
|
|
@ -357,46 +357,76 @@ def web_terminal(request):
|
||||||
|
|
||||||
|
|
||||||
def install(request):
|
def install(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
username = request.GET.get('username')
|
||||||
|
password = request.GET.get('password')
|
||||||
|
email = request.GET.get('email')
|
||||||
|
db_host = request.GET.get('db_host')
|
||||||
|
db_port = int(request.GET.get('db_port')) if request.GET.get('db_port') else 1
|
||||||
|
db_user = request.GET.get('db_user')
|
||||||
|
db_pass = request.GET.get('db_pass')
|
||||||
|
db = request.GET.get('db')
|
||||||
|
smtp_host = request.GET.get('smtp_host') if request.GET.get('smtp_host') else 'jumpserver'
|
||||||
|
smtp_port = int(request.GET.get('smtp_port')) if request.GET.get('smtp_port') else 25
|
||||||
|
mail_addr = request.GET.get('mail_addr')
|
||||||
|
mail_pass = request.GET.get('mail_pass')
|
||||||
|
|
||||||
|
config = ConfigParser.ConfigParser()
|
||||||
|
config.read(os.path.join(BASE_DIR, 'jumpserver.conf'))
|
||||||
|
config.set('db', 'host', db_host)
|
||||||
|
config.set('db', 'port', db_port)
|
||||||
|
config.set('db', 'user', db_user)
|
||||||
|
config.set('db', 'password', db_pass)
|
||||||
|
config.set('db', 'database', db)
|
||||||
|
config.set('mail', 'email_host', smtp_host)
|
||||||
|
config.set('mail', 'email_port', smtp_port)
|
||||||
|
config.set('mail', 'email_host_user', mail_addr)
|
||||||
|
config.set('mail', 'email_host_passoword', mail_pass)
|
||||||
|
f = open(os.path.join(BASE_DIR, 'jumpserver.conf'), 'w')
|
||||||
|
config.write(f)
|
||||||
|
|
||||||
return render_to_response('install.html', locals())
|
return render_to_response('install.html', locals())
|
||||||
|
|
||||||
|
|
||||||
def install_test(request, offset):
|
def install_test(request, offset):
|
||||||
if request.method == 'post':
|
if request.method == 'GET':
|
||||||
if offset == 'db':
|
if offset == 'db':
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
db_host = request.GET.get('db_host')
|
db_host = request.GET.get('db_host')
|
||||||
db_port = int(request.GET.get('db_port'))
|
db_port = int(request.GET.get('db_port')) if request.GET.get('db_port') else 1
|
||||||
db_user = request.GET.get('db_user')
|
db_user = request.GET.get('db_user')
|
||||||
db_pass = request.GET.get('db_pass')
|
db_pass = request.GET.get('db_pass')
|
||||||
db = request.GET.get('db')
|
db = request.GET.get('db')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn = MySQLdb.connect(host=db_host, port=db_port, user=db_user, passwd=db_pass, db=db)
|
conn = MySQLdb.connect(host=db_host, port=db_port, user=db_user, passwd=db_pass, db=db)
|
||||||
except Exception:
|
except Exception, e:
|
||||||
return HttpResponse('链接失败', status=500)
|
logger.debug(u'测试连接数据库失败: %s %s % s %s' % (db_host, db_port, db_user, db_pass))
|
||||||
|
return HttpResponse(u'链接失败 %s' % e, status=500)
|
||||||
else:
|
else:
|
||||||
return HttpResponse('连接成功')
|
return HttpResponse('连接成功')
|
||||||
|
|
||||||
elif offset == 'mail':
|
elif offset == 'mail':
|
||||||
from smtplib import SMTP
|
from smtplib import SMTP
|
||||||
smtp_host = request.GET.get('smtp_host')
|
smtp_host = request.GET.get('smtp_host') if request.GET.get('smtp_host') else 'jumpserver'
|
||||||
smtp_port = request.GET.get('smtp_port')
|
smtp_port = int(request.GET.get('smtp_port')) if request.GET.get('smtp_port') else 25
|
||||||
mail_addr = request.GET.get('mail_addr')
|
mail_addr = request.GET.get('mail_addr')
|
||||||
mail_pass = request.GET.get('mail_pass')
|
mail_pass = request.GET.get('mail_pass')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
smtp = SMTP(smtp_host, port=smtp_port)
|
smtp = SMTP(smtp_host, port=smtp_port, timeout=2)
|
||||||
smtp.login(mail_addr, mail_pass)
|
smtp.login(mail_addr, mail_pass)
|
||||||
smtp.sendmail(mail_addr, (mail_addr),
|
smtp.sendmail(mail_addr, (mail_addr),
|
||||||
'''From:%s\r\nTo:%s\r\nSubject:Jumpserver Mail Test!\r\n\r\n Mail test passed!\r\n''')
|
'''From:%s\r\nTo:%s\r\nSubject:Jumpserver Mail Test!\r\n\r\n Mail test passed!\r\n''' %
|
||||||
|
(mail_addr, mail_addr))
|
||||||
smtp.quit()
|
smtp.quit()
|
||||||
|
|
||||||
except Exception:
|
except Exception, e:
|
||||||
return HttpResponse('测试失败', status=500)
|
logger.debug(u'邮件测试失败: %s' % e)
|
||||||
|
return HttpResponse('测试失败 %s' % e)
|
||||||
else:
|
else:
|
||||||
return HttpResponse(u'登陆 %s邮箱查看邮件' % mail_addr)
|
return HttpResponse(u'登陆 %s邮箱查看邮件' % mail_addr)
|
||||||
else:
|
else:
|
||||||
print request.method
|
return HttpResponse('请求方法错误')
|
||||||
return HttpResponse('请求方法错误', status=500)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,40 +46,40 @@
|
||||||
请输入相关信息完成安装
|
请输入相关信息完成安装
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form id="form" action="#" class="wizard-big" >
|
<form id="form" action="{% url 'install' %}" method="post" class="wizard-big" >
|
||||||
{# <h1>管理员账户</h1>#}
|
<h1>管理员账户</h1>
|
||||||
{# <fieldset>#}
|
<fieldset>
|
||||||
{# <h2>管理员账号是首次登陆的账号</h2>#}
|
<h2>管理员账号是首次登陆的账号</h2>
|
||||||
{# <div class="row">#}
|
<div class="row">
|
||||||
{# <div class="col-sm-6">#}
|
<div class="col-sm-6">
|
||||||
{# <div class="form-group">#}
|
<div class="form-group">
|
||||||
{# <label>用户名 *</label>#}
|
<label>用户名 *</label>
|
||||||
{# <input id="username" name="username" type="text" class="form-control required" minlength="5" >#}
|
<input id="username" name="username" type="text" class="form-control required" minlength="5" >
|
||||||
{# </div>#}
|
</div>
|
||||||
{# <div class="form-group">#}
|
<div class="form-group">
|
||||||
{# <label>密码 *</label>#}
|
<label>密码 *</label>
|
||||||
{# <input id="password" name="password" type="password" class="form-control required password" minlength="8">#}
|
<input id="password" name="password" type="password" class="form-control required password" minlength="8">
|
||||||
{# </div>#}
|
</div>
|
||||||
{# </div>#}
|
</div>
|
||||||
{# <div class="col-sm-6">#}
|
<div class="col-sm-6">
|
||||||
{# <div class="form-group">#}
|
<div class="form-group">
|
||||||
{# <label>邮件 *</label>#}
|
<label>邮件 *</label>
|
||||||
{# <input id="email" name="email" type="email" class="form-control required">#}
|
<input id="email" name="email" type="email" class="form-control required">
|
||||||
{# </div>#}
|
</div>
|
||||||
{# <div class="form-group">#}
|
<div class="form-group">
|
||||||
{# <label>确认密码 *</label>#}
|
<label>确认密码 *</label>
|
||||||
{# <input id="pass_confirm" name="pass_confirm" type="password" equalto="#password" class="form-control required">#}
|
<input id="pass_confirm" name="pass_confirm" type="password" equalto="#password" class="form-control required">
|
||||||
{# </div>#}
|
</div>
|
||||||
{# </div>#}
|
</div>
|
||||||
{# <div class="col-sm-4">#}
|
<div class="col-sm-4">
|
||||||
{# <div class="text-center">#}
|
<div class="text-center">
|
||||||
{# <div style="margin-top: 20px">#}
|
<div style="margin-top: 20px">
|
||||||
{# <i class="fa fa-sign-in" style="font-size: 180px;color: #e5e5e5 "></i>#}
|
<i class="fa fa-sign-in" style="font-size: 180px;color: #e5e5e5 "></i>
|
||||||
{# </div>#}
|
</div>
|
||||||
{# </div>#}
|
</div>
|
||||||
{# </div>#}
|
</div>
|
||||||
{# </div>#}
|
</div>
|
||||||
{# </fieldset>#}
|
</fieldset>
|
||||||
<h1>数据库</h1>
|
<h1>数据库</h1>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<h2>数据库连接信息</h2>
|
<h2>数据库连接信息</h2>
|
||||||
|
@ -87,29 +87,29 @@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>地址 *</label>
|
<label>地址 *</label>
|
||||||
<input id="db_host" name="db_host" type="text" class="form-control required">
|
<input id="db_host" name="db_host" type="text" value="127.0.0.1" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>端口 *</label>
|
<label>端口 *</label>
|
||||||
<input id="db_port" name="db_port" type="text" class="form-control required number">
|
<input id="db_port" name="db_port" type="text" value="3306" class="form-control required number">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>数据库 *</label>
|
<label>数据库 *</label>
|
||||||
<input id="db" name="db" type="text" class="form-control required">
|
<input id="db" name="db" type="text" value="jumpserver" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>用户名 *</label>
|
<label>用户名 *</label>
|
||||||
<input id="db_user" name="db_user" type="text" class="form-control required">
|
<input id="db_user" name="db_user" type="text" value="jumpserver" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>密码 *</label>
|
<label>密码 *</label>
|
||||||
<input id="db_pass" name="db_pass" type="password" class="form-control">
|
<input id="db_pass" name="db_pass" type="password" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div></div>
|
<div></div>
|
||||||
<a id="db_btn" value="{% url 'install_test' 'db' %}" class="btn btn-sm btn-warning" style="float: right"> 测试连接 </a>
|
<a id="db_btn" value="{% url 'install_test' 'db' %}" class="btn btn-sm btn-warning" style="float: right" onclick="db_test(this)"> 测试连接 </a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -122,25 +122,25 @@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>SMTP *</label>
|
<label>SMTP *</label>
|
||||||
<input id="smtp_host" name="smtp_host" type="text" class="form-control required">
|
<input id="smtp_host" name="smtp_host" placeholder="smtp.qq.com" type="text" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>端口 *</label>
|
<label>端口 *</label>
|
||||||
<input id="smtp_port" name="smtp_port" type="text" class="form-control required">
|
<input id="smtp_port" name="smtp_port" value="25" type="text" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>邮件地址 *</label>
|
<label>邮件地址 *</label>
|
||||||
<input id="mail_addr" name="mail_addr" type="text" class="form-control required">
|
<input id="mail_addr" name="mail_addr" placeholder="xxxx@qq.com" type="text" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>密码 *</label>
|
<label>密码 *</label>
|
||||||
<input id="mail_pass" name="mail_pass" type="password" class="form-control">
|
<input id="mail_pass" name="mail_pass" type="password" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div></div>
|
<div></div>
|
||||||
<a id="mail_btn" href="{% url 'install_test' 'mail' %}" class="btn btn-sm btn-warning" style="float: right"> 测试邮件 </a>
|
<a id="mail_btn" value="{% url 'install_test' 'mail' %}" class="btn btn-sm btn-warning" style="float: right" onclick="smtp_test(this)"> 测试邮件 </a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -148,8 +148,8 @@
|
||||||
|
|
||||||
<h1>完成</h1>
|
<h1>完成</h1>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<h2>Terms and Conditions</h2>
|
<h2>确认信息</h2>
|
||||||
<input id="acceptTerms" name="acceptTerms" type="checkbox" class="required"> <label for="acceptTerms">I agree with the Terms and Conditions.</label>
|
<p id="confirm"></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -159,8 +159,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Mainly scripts -->
|
<!-- Mainly scripts -->
|
||||||
<!-- // <script src="js/jquery-2.1.1.js"></script> -->
|
<!-- // <script src="js/jquery-2.1.1.js"></script> -->
|
||||||
<script src="/static/js/jquery-2.1.1.js"></script>
|
<script src="/static/js/jquery-2.1.1.js"></script>
|
||||||
|
@ -181,30 +179,76 @@
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
var db_test_valid = false;
|
||||||
// $("#wizard").steps();
|
var smtp_test_valid = false;
|
||||||
|
|
||||||
$('#db_btn').click(function(){
|
function db_test(t, alert_){
|
||||||
console.log('hello');
|
var valid = $(t).closest('form').valid();
|
||||||
var db_host = $('#db_host').val();
|
if (valid == false){
|
||||||
var db_port = $('#db_port').val();
|
console.log('Not valid');
|
||||||
var db_user = $('#db_user').val();
|
return
|
||||||
var db_pass = $('#db_pass').val();
|
}
|
||||||
$.post(
|
var db_host = $('#db_host').val();
|
||||||
$(this).attr('value'),
|
var db_port = $('#db_port').val();
|
||||||
{'db_host': db_host,
|
var db_user = $('#db_user').val();
|
||||||
'db_port': db_port,
|
var db_pass = $('#db_pass').val();
|
||||||
'db_user': db_user,
|
var db = $('#db').val();
|
||||||
'db_pass': db_pass
|
$.ajax({
|
||||||
},
|
url: $(t).attr('value'),
|
||||||
function(data, status){
|
data: {'db_host': db_host,
|
||||||
alert(data)
|
'db_port': db_port,
|
||||||
}
|
'db_user': db_user,
|
||||||
|
'db_pass': db_pass,
|
||||||
|
'db': db },
|
||||||
|
success: function(data, status){
|
||||||
|
db_test_valid = true;
|
||||||
|
$('#db_btn').removeClass('btn-danger');
|
||||||
|
$('#db_btn').addClass('btn-primary');
|
||||||
|
alert(data)
|
||||||
|
},
|
||||||
|
error: function(data){
|
||||||
|
$('#db_btn').addClass('btn-danger');
|
||||||
|
alert(data.responseText)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
);
|
function smtp_test(t){
|
||||||
return false;
|
var valid = $(t).closest('form').valid();
|
||||||
|
if (valid == false){
|
||||||
|
console.log('Not valid');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var smtp_host = $('#smtp_host').val();
|
||||||
|
var smtp_port = $('#smtp_port').val();
|
||||||
|
var mail_addr = $('#mail_addr').val();
|
||||||
|
var mail_pass = $('#mail_pass').val();
|
||||||
|
$.ajax({
|
||||||
|
url: $(t).attr('value'),
|
||||||
|
data: {
|
||||||
|
'smtp_host': smtp_host,
|
||||||
|
'smtp_port': smtp_port,
|
||||||
|
'mail_addr': mail_addr,
|
||||||
|
'mail_pass': mail_pass
|
||||||
|
},
|
||||||
|
success: function(data, status){
|
||||||
|
smtp_test_valid = false;
|
||||||
|
$('#smtp_btn').removeClass('btn-danger');
|
||||||
|
$('#smtp_btn').addClass('btn-primary');
|
||||||
|
alert(data)
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
$('#smtp_btn').addClass('btn-danger');
|
||||||
|
alert(data.responseText)
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
// $("#wizard").steps();
|
||||||
|
|
||||||
$("#form").steps({
|
$("#form").steps({
|
||||||
bodyTag: "fieldset",
|
bodyTag: "fieldset",
|
||||||
|
@ -217,11 +261,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forbid suppressing "Warning" step if the user is to young
|
// Forbid suppressing "Warning" step if the user is to young
|
||||||
if (newIndex === 3 && Number($("#age").val()) < 18)
|
if (newIndex === 2){
|
||||||
{
|
if (db_test_valid == false) {
|
||||||
return false;
|
$('#db_btn').removeClass('btn-warning');
|
||||||
|
$('#db_btn').addClass('btn-danger');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newIndex === 3){
|
||||||
|
//if (smtp_test_valid == false){
|
||||||
|
// $('#smtp_btn').removeClass('btn-warning');
|
||||||
|
// $('#smtp_btn').addClass('btn-danger');
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
console.log('pass')
|
||||||
|
}
|
||||||
var form = $(this);
|
var form = $(this);
|
||||||
|
|
||||||
// Clean up if user went backward before
|
// Clean up if user went backward before
|
||||||
|
@ -251,6 +307,20 @@
|
||||||
{
|
{
|
||||||
$(this).steps("previous");
|
$(this).steps("previous");
|
||||||
}
|
}
|
||||||
|
console.log(currentIndex + ';' + priorIndex);
|
||||||
|
if (currentIndex === 3 && priorIndex === 2)
|
||||||
|
{
|
||||||
|
$('#confirm').html(
|
||||||
|
'<span>' + '管理账号: ' + $('#username').val() + '<br/ >' +
|
||||||
|
'<span>' + '管理邮箱: ' + $('#email').val() + '<br/ >' +
|
||||||
|
'<span>' + '数据库地址: ' + $('#db_host').val() + '<br/ >' +
|
||||||
|
'<span>' + '数据库端口: ' + $('#db_port').val() + '<br/ >' +
|
||||||
|
'<span>' + '数据库账号: ' + $('#db_user').val() + '<br/ >' +
|
||||||
|
'<span>' + 'SMTP地址: ' + $('#smtp_host').val() + '<br/ >' +
|
||||||
|
'<span>' + 'SMTP端口: ' + $('#smtp_port').val() + '<br/ >' +
|
||||||
|
'<span>' + '邮件账号: ' + $('#mail_addr').val() + '<br/ >'
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onFinishing: function (event, currentIndex)
|
onFinishing: function (event, currentIndex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,12 +150,6 @@ $('#userForm').validator({
|
||||||
ok: "",
|
ok: "",
|
||||||
msg: {required: "必须填写!"}
|
msg: {required: "必须填写!"}
|
||||||
},
|
},
|
||||||
"password": {
|
|
||||||
rule: "length[6~50];check_pass",
|
|
||||||
tip: "输入密码",
|
|
||||||
ok: "",
|
|
||||||
msg: {required: "必须填写!"}
|
|
||||||
},
|
|
||||||
"name": {
|
"name": {
|
||||||
rule: "required",
|
rule: "required",
|
||||||
tip: "姓名",
|
tip: "姓名",
|
||||||
|
|
Loading…
Reference in New Issue