Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
4f979870
Commit
4f979870
authored
Feb 29, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #97 from jumpserver/bug_fix_guang
fix 启动脚本,配置文件,批量命令异常等
parents
69ac8ae1
cba53bba
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
79 additions
and
81 deletions
+79
-81
connect.py
connect.py
+11
-3
functions
install/functions
+0
-0
install.py
install/install.py
+2
-2
next.py
install/next.py
+2
-2
views.py
jlog/views.py
+3
-3
jumpserver.conf
jumpserver.conf
+8
-10
api.py
jumpserver/api.py
+2
-1
settings.py
jumpserver/settings.py
+1
-1
views.py
jumpserver/views.py
+2
-3
run_server.py
run_server.py
+1
-1
service.sh
service.sh
+44
-42
log_online.html
templates/jlog/log_online.html
+2
-7
web_terminal.html
templates/jlog/web_terminal.html
+1
-6
No files found.
connect.py
View file @
4f979870
...
...
@@ -523,7 +523,13 @@ class Nav(object):
if
gid_pattern
.
match
(
str_r
):
gid
=
int
(
str_r
.
lstrip
(
'g'
))
# 获取资产组包含的资产
user_asset_search
=
get_object
(
AssetGroup
,
id
=
gid
)
.
asset_set
.
all
()
asset_group
=
get_object
(
AssetGroup
,
id
=
gid
)
if
asset_group
:
user_asset_search
=
asset_group
.
asset_set
.
all
()
else
:
color_print
(
'没有该资产组或没有权限'
)
return
else
:
# 匹配 ip, hostname, 备注
for
asset
in
user_asset_all
:
...
...
@@ -609,6 +615,9 @@ class Nav(object):
command
=
raw_input
(
"
\033
[1;32mCmds>:
\033
[0m "
)
.
strip
()
if
command
==
'q'
:
break
elif
not
command
:
color_print
(
'命令不能为空...'
)
continue
runner
.
run
(
'shell'
,
command
,
pattern
=
pattern
)
ExecLog
(
host
=
asset_name_str
,
user
=
self
.
user
.
username
,
cmd
=
command
,
remote_ip
=
remote_ip
,
result
=
runner
.
results
)
.
save
()
...
...
@@ -661,7 +670,7 @@ class Nav(object):
runner
=
MyRunner
(
res
)
runner
.
run
(
'copy'
,
module_args
=
'src=
%
s dest=
%
s directory_mode'
%
(
tmp_dir
,
tmp_dir
),
pattern
=
pattern
)
%
(
tmp_dir
,
'/tmp'
),
pattern
=
pattern
)
ret
=
runner
.
results
FileLog
(
user
=
self
.
user
.
name
,
host
=
asset_name_str
,
filename
=
filename_str
,
remote_ip
=
remote_ip
,
type
=
'upload'
,
result
=
ret
)
.
save
()
...
...
@@ -815,7 +824,6 @@ def main():
except
IndexError
,
e
:
color_print
(
e
)
time
.
sleep
(
5
)
pass
if
__name__
==
'__main__'
:
main
()
functions
→
install/
functions
View file @
4f979870
File moved
install/install.py
View file @
4f979870
...
...
@@ -97,13 +97,13 @@ class PreSetup(object):
conf
=
ConfigParser
.
ConfigParser
()
conf
.
read
(
conf_file
)
conf
.
set
(
'base'
,
'url'
,
'http://
%
s'
%
self
.
ip
)
conf
.
set
(
'base'
,
'websocket_url'
,
'ws://
%
s'
%
self
.
ip
)
conf
.
set
(
'base'
,
'key'
,
self
.
key
)
conf
.
set
(
'db'
,
'host'
,
self
.
db_host
)
conf
.
set
(
'db'
,
'port'
,
self
.
db_port
)
conf
.
set
(
'db'
,
'user'
,
self
.
db_user
)
conf
.
set
(
'db'
,
'password'
,
self
.
db_pass
)
conf
.
set
(
'db'
,
'database'
,
self
.
db
)
conf
.
set
(
'websocket'
,
'web_socket_host'
,
'
%
s:3000'
%
self
.
ip
)
conf
.
set
(
'mail'
,
'email_host'
,
self
.
mail_host
)
conf
.
set
(
'mail'
,
'email_port'
,
self
.
mail_port
)
conf
.
set
(
'mail'
,
'email_host_user'
,
self
.
mail_addr
)
...
...
@@ -237,7 +237,7 @@ class PreSetup(object):
print
def
start
(
self
):
color_print
(
'请务必先查看wiki https://github.com/
ibuler/jumpserver/wiki/Quickinstall
'
)
color_print
(
'请务必先查看wiki https://github.com/
jumpserver/jumpserver/wiki
'
)
time
.
sleep
(
3
)
self
.
_rpm_repo
()
self
.
_depend_rpm
()
...
...
install/next.py
View file @
4f979870
...
...
@@ -86,7 +86,7 @@ class Setup(object):
os
.
chmod
(
'init.sh'
,
0755
)
os
.
chmod
(
'connect.py'
,
0755
)
os
.
chmod
(
'manage.py'
,
0755
)
os
.
chmod
(
'run_
websocket
.py'
,
0755
)
os
.
chmod
(
'run_
server
.py'
,
0755
)
os
.
chmod
(
'service.sh'
,
0755
)
os
.
chmod
(
'logs'
,
0777
)
os
.
chmod
(
'keys'
,
0777
)
...
...
@@ -95,7 +95,7 @@ class Setup(object):
def
_run_service
():
os
.
system
(
'sh
%
s start'
%
os
.
path
.
join
(
jms_dir
,
'service.sh'
))
print
color_print
(
'安装成功,请访问web, 祝你使用愉快。
\n
请访问 https://github.com/jumpserver/jumpserver 查看文档'
,
'green'
)
color_print
(
'安装成功,请访问web, 祝你使用愉快。
\n
请访问 https://github.com/jumpserver/jumpserver
/wiki
查看文档'
,
'green'
)
def
start
(
self
):
print
"开始安装Jumpserver, 要求环境为 CentOS 6.5 x86_64"
...
...
jlog/views.py
View file @
4f979870
...
...
@@ -9,7 +9,7 @@ from django.http import HttpResponseNotFound
from
jlog.log_api
import
renderTemplate
from
jlog.models
import
Log
,
ExecLog
,
FileLog
from
jumpserver.settings
import
WEB_SOCKET_
HOST
from
jumpserver.settings
import
WEB_SOCKET_
URL
@require_role
(
'admin'
)
...
...
@@ -66,8 +66,8 @@ def log_list(request, offset):
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
web_monitor_ur
i
=
'
%
s/monitor'
%
WEB_SOCKET_HOST
web_kill_ur
i
=
'/kill'
web_monitor_ur
l
=
'
%
s/monitor'
%
WEB_SOCKET_URL
web_kill_ur
l
=
'/kill'
session_id
=
request
.
session
.
session_key
return
render_to_response
(
'jlog/log_
%
s.html'
%
offset
,
locals
(),
context_instance
=
RequestContext
(
request
))
...
...
jumpserver.conf
View file @
4f979870
[
base
]
url
=
http
://
192
.
168
.
244
.
129
key
=
88
aaaf7ffe3c6c04
websocket_url
=
ws
://
192
.
168
.
244
.
129
key
=
i6k2zeu8x6mncl76
ip
=
0
.
0
.
0
.
0
port
=
80
log
=
debug
ip
=
127
.
0
.
0
.
1
port
=
8080
[
db
]
host
=
127
.
0
.
0
.
1
...
...
@@ -12,14 +13,11 @@ user = jumpserver
password
=
mysql234
database
=
jumpserver
[
websocket
]
web_socket_host
=
192
.
168
.
244
.
129
:
3000
[
mail
]
mail_enable
=
1
email_host
=
smtp
.
qq
.
com
email_host
=
smtp
.
exmail
.
qq
.
com
email_port
=
25
email_host_user
=
xxxxxxxx
@
qq
.
com
email_host_password
=
xxxxxx
email_use_tls
=
Fals
e
email_host_user
=
noreply
@
jumpserver
.
org
email_host_password
=
xxxxxx
xxxx
email_use_tls
=
Tru
e
jumpserver/api.py
View file @
4f979870
...
...
@@ -484,7 +484,8 @@ def my_render(template, data, request):
def
get_tmp_dir
():
dir_name
=
os
.
path
.
join
(
'/tmp'
,
uuid
.
uuid4
()
.
hex
)
seed
=
uuid
.
uuid4
()
.
hex
[:
4
]
dir_name
=
os
.
path
.
join
(
'/tmp'
,
'
%
s-
%
s'
%
(
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d-
%
H
%
M
%
S'
),
seed
))
mkdir
(
dir_name
,
mode
=
0777
)
return
dir_name
...
...
jumpserver/settings.py
View file @
4f979870
...
...
@@ -41,7 +41,7 @@ SSH_KEY_DIR = os.path.join(BASE_DIR, 'keys/role_keys')
KEY
=
config
.
get
(
'base'
,
'key'
)
URL
=
config
.
get
(
'base'
,
'url'
)
LOG_LEVEL
=
config
.
get
(
'base'
,
'log'
)
WEB_SOCKET_
HOST
=
config
.
get
(
'websocket'
,
'web_socket_host
'
)
WEB_SOCKET_
URL
=
config
.
get
(
'base'
,
'websocket_url
'
)
IP
=
config
.
get
(
'base'
,
'ip'
)
PORT
=
config
.
get
(
'base'
,
'port'
)
...
...
jumpserver/views.py
View file @
4f979870
...
...
@@ -286,7 +286,7 @@ def upload(request):
res
=
gen_resource
({
'user'
:
user
,
'asset'
:
asset_select
})
runner
=
MyRunner
(
res
)
runner
.
run
(
'copy'
,
module_args
=
'src=
%
s dest=
%
s directory_mode'
%
(
upload_dir
,
upload_dir
),
pattern
=
'*'
)
%
(
upload_dir
,
'/tmp'
),
pattern
=
'*'
)
ret
=
runner
.
results
logger
.
debug
(
ret
)
FileLog
(
user
=
request
.
user
.
username
,
host
=
' '
.
join
([
asset
.
hostname
for
asset
in
asset_select
]),
...
...
@@ -356,8 +356,7 @@ def web_terminal(request):
if
asset
:
print
asset
hostname
=
asset
.
hostname
# web_terminal_uri = '%s/ws/terminal?id=%s&role=%s' % (WEB_SOCKET_HOST, asset_id, role_name)
web_terminal_uri
=
'/ws/terminal?id=
%
s&role=
%
s'
%
(
asset_id
,
role_name
)
web_terminal_url
=
'
%
s/ws/terminal?id=
%
s&role=
%
s'
%
(
WEB_SOCKET_URL
,
asset_id
,
role_name
)
return
render_to_response
(
'jlog/web_terminal.html'
,
locals
())
run_
websocket
.py
→
run_
server
.py
View file @
4f979870
...
...
@@ -464,6 +464,6 @@ if __name__ == '__main__':
# server.bind(options.port, options.host)
# #server.listen(options.port)
# server.start(num_processes=5)
# print "Run server on %s:%s" % (options.host, options.port)
# tornado.ioloop.IOLoop.instance().start()
print
"Run server on
%
s:
%
s"
%
(
options
.
host
,
options
.
port
)
main
()
service.sh
View file @
4f979870
...
...
@@ -4,53 +4,43 @@
# chkconfig: - 85 12
# description: Open source detecting system
# processname: jumpserver
# Date: 201
5-04-12
# Version:
2.0.0
# Date: 201
6-02-27
# Version:
3.0.1
# Site: http://www.jumpserver.org
# Author: Jumpserver Team
base_dir
=
$(
dirname
$0
)
.
${
base_dir
}
/functions
export
PATH
=
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin
jumpserver_dir
=
PROC_NAME
=
"jumpsever"
base_dir
=
$(
dirname
$0
)
jumpserver_dir
=
${
jumpserver_dir
:-
$base_dir
}
export
PATH
=
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
if
[
-f
${
jumpserver_dir
}
/install/functions
]
;
then
.
${
jumpserver_dir
}
/install/functions
elif
[
-f
/etc/init.d/functions
]
;
then
.
/etc/init.d/functions
else
echo
"No functions script found in [./functions, ./install/functions, /etc/init.d/functions]"
exit
1
fi
PROC_NAME
=
"jumpserver"
lockfile
=
/var/lock/subsys/
${
PROC_NAME
}
start
()
{
jump_start
=
$"Starting
${
PROC_NAME
}
service:"
if
[
-f
$lockfile
]
;
then
echo
"jumpserver
is running..."
echo
-n
"jumpserver
is running..."
success
"
$jump_start
"
echo
else
# daemon python $base_dir/manage.py runserver 0.0.0.0:80 &>> /tmp/jumpserver.log 2>&1 &
daemon python
$base_dir
/manage.py crontab add &>> /tmp/jumpserver.log 2>&1
daemon python
$base_dir
/run_websocket.py &> /dev/null 2>&1 &
sleep
4
daemon python
$jumpserver_dir
/manage.py crontab add &>> /var/log/jumpserver.log 2>&1
daemon python
$jumpserver_dir
/run_server.py &> /dev/null 2>&1 &
sleep
1
echo
-n
"
$jump_start
"
nums
=
0
for
i
in
manage.py run_websocket.py
;
do
if
ps aux |
grep
"
$i
"
|
grep
-v
'grep'
&> /dev/null
;
then
nums
=
$[
nums+1]
else
echo
"
$i
not running"
fi
done
if
[
"x
$nums
"
==
"x2"
]
;
then
ps axu |
grep
'run_server'
|
grep
-v
'grep'
&> /dev/null
if
[
$?
==
'0'
]
;
then
success
"
$jump_start
"
if
[
!
-e
$lockfile
]
;
then
lockfile_dir
=
`
dirname
$lockfile
`
mkdir
-pv
$lockfile_dir
fi
touch
"
$lockfile
"
echo
else
...
...
@@ -58,19 +48,14 @@ start() {
echo
fi
fi
}
stop
()
{
echo
-n
$"Stopping
${
PROC_NAME
}
service:"
daemon python
$base_dir
/manage.py crontab remove &>> /tmp/jumpserver.log 2>&1
ps aux |
grep
-E
'manage.py|run_websocket.py'
|
grep
-v
grep
|
awk
'{print $2}'
| xargs
kill
-9
&> /dev/null
daemon python
$jumpserver_dir
/manage.py crontab remove &>> /var/log/jumpserver.log 2>&1
ps aux |
grep
-E
'run_server.py'
|
grep
-v
grep
|
awk
'{print $2}'
| xargs
kill
-9
&> /dev/null
ret
=
$?
if
[
$ret
-eq
0
]
;
then
echo_success
echo
...
...
@@ -83,6 +68,20 @@ stop() {
}
status
(){
ps axu |
grep
'run_server'
|
grep
-v
'grep'
&> /dev/null
if
[
$?
==
'0'
]
;
then
echo
-n
"jumpserver is running..."
success
touch
"
$lockfile
"
echo
else
echo
-n
"jumpserver is not running."
failure
echo
fi
}
restart
(){
...
...
@@ -103,7 +102,10 @@ case "$1" in
restart
;;
status
)
status
;;
*
)
echo
$"Usage:
$0
{start|stop|restart}"
echo
$"Usage:
$0
{start|stop|restart
|status
}"
exit
2
esac
templates/jlog/log_online.html
View file @
4f979870
...
...
@@ -136,13 +136,8 @@
{
#
})
#
}
{
#
});
#
}
function
init
(
obj
){
var
protocol
=
"ws://"
;
if
(
window
.
location
.
protocol
==
'https:'
)
{
protocol
=
'wss://'
;
}
var
file_path
=
obj
.
attr
(
'file_path'
);
var
wsUri
=
protocol
+
'{{ web_monitor_uri
}}'
;
var
wsUri
=
'{{ web_monitor_url
}}'
;
var
socket
=
new
WebSocket
(
wsUri
+
'?file_path='
+
file_path
);
var
term
=
new
Terminal
({
...
...
@@ -211,7 +206,7 @@
function
cut
(
num
,
login_type
){
console
.
log
(
login_type
);
if
(
login_type
==
'web'
){
var
g_url
=
'{{ web_kill_ur
i
}}'
+
'?id='
+
num
;
var
g_url
=
'{{ web_kill_ur
l
}}'
+
'?id='
+
num
;
}
else
{
var
g_url
=
"{% url 'log_kill' %}?id="
+
num
;
}
...
...
templates/jlog/web_terminal.html
View file @
4f979870
...
...
@@ -43,12 +43,7 @@
}
WSSHClient
.
prototype
.
connect
=
function
(
options
)
{
var
protocol
=
"ws://"
;
if
(
window
.
location
.
protocol
==
'https:'
)
{
protocol
=
'wss://'
;
}
var
endpoint
=
protocol
+
document
.
URL
.
match
(
RegExp
(
'//(.*?)/'
))[
1
]
+
'{{ web_terminal_uri }}'
;
var
endpoint
=
'{{ web_terminal_url }}'
;
if
(
window
.
WebSocket
)
{
this
.
_connection
=
new
WebSocket
(
endpoint
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment