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
c01a489d
Commit
c01a489d
authored
Apr 24, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify service.sh bug
parent
0beb683c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
21 deletions
+35
-21
connect.py
connect.py
+23
-15
models.py
jlog/models.py
+8
-2
service.sh
service.sh
+4
-4
No files found.
connect.py
View file @
c01a489d
...
@@ -8,7 +8,6 @@ sys.setdefaultencoding('utf8')
...
@@ -8,7 +8,6 @@ sys.setdefaultencoding('utf8')
import
socket
import
socket
import
os
import
os
import
re
import
re
import
ast
import
select
import
select
import
time
import
time
import
paramiko
import
paramiko
...
@@ -16,25 +15,24 @@ import struct
...
@@ -16,25 +15,24 @@ import struct
import
fcntl
import
fcntl
import
signal
import
signal
import
textwrap
import
textwrap
import
django
import
getpass
import
getpass
import
fnmatch
import
fnmatch
import
readline
import
readline
import
datetime
from
multiprocessing
import
Pool
from
multiprocessing
import
Pool
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'jumpserver.settings'
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'jumpserver.settings'
#django.setup()
from
juser.models
import
User
from
juser.models
import
User
from
jlog.models
import
Log
from
jlog.models
import
Log
from
jumpserver.api
import
*
from
jumpserver.api
import
CONF
,
BASE_DIR
,
ServerError
,
user_perm_group_api
,
user_perm_group_hosts_api
,
get_user_host
from
jumpserver.api
import
AssetAlias
,
get_connect_item
try
:
try
:
import
termios
import
termios
import
tty
import
tty
except
ImportError
:
except
ImportError
:
print
'
\033
[1;31mOnly
postfix
supported.
\033
[0m'
print
'
\033
[1;31mOnly
UnixLike
supported.
\033
[0m'
time
.
sleep
(
3
)
time
.
sleep
(
3
)
sys
.
exit
()
sys
.
exit
()
...
@@ -194,13 +192,16 @@ def verify_connect(username, part_ip):
...
@@ -194,13 +192,16 @@ def verify_connect(username, part_ip):
except
ServerError
,
e
:
except
ServerError
,
e
:
color_print
(
e
,
'red'
)
color_print
(
e
,
'red'
)
return
False
return
False
for
ip_info
in
hosts
:
for
ip_info
in
hosts
:
for
info
in
ip_info
[
1
:]:
for
info
in
ip_info
[
1
:]:
if
part_ip
in
info
:
if
part_ip
in
info
:
ip_matched
.
append
(
ip_info
[
1
])
ip_matched
.
append
(
ip_info
[
1
])
ip_matched
=
list
(
set
(
ip_matched
))
if
len
(
ip_matched
)
>
1
:
if
len
(
ip_matched
)
>
1
:
for
ip
in
ip_matched
:
for
ip
in
ip_matched
:
print
'
%
s --
%
s'
%
(
ip
,
hosts_attr
[
ip
][
2
])
print
'
%
-15
s --
%
s'
%
(
ip
,
hosts_attr
[
ip
][
2
])
elif
len
(
ip_matched
)
<
1
:
elif
len
(
ip_matched
)
<
1
:
color_print
(
'No Permission or No host.'
,
'red'
)
color_print
(
'No Permission or No host.'
,
'red'
)
else
:
else
:
...
@@ -210,7 +211,7 @@ def verify_connect(username, part_ip):
...
@@ -210,7 +211,7 @@ def verify_connect(username, part_ip):
def
print_prompt
():
def
print_prompt
():
msg
=
"""
\033
[1;32m### Welcome Use JumpServer To Login. ###
\033
[0m
msg
=
"""
\033
[1;32m### Welcome Use JumpServer To Login. ###
\033
[0m
1) Type
\033
[32mIP
ADDRESS
\033
[0m To Login.
1) Type
\033
[32mIP
or Part IP, Host Alias or Comments
\033
[0m To Login.
2) Type
\033
[32mP/p
\033
[0m To Print The Servers You Available.
2) Type
\033
[32mP/p
\033
[0m To Print The Servers You Available.
3) Type
\033
[32mG/g
\033
[0m To Print The Server Groups You Available.
3) Type
\033
[32mG/g
\033
[0m To Print The Server Groups You Available.
4) Type
\033
[32mG/g(1-N)
\033
[0m To Print The Server Group Hosts You Available.
4) Type
\033
[32mG/g(1-N)
\033
[0m To Print The Server Group Hosts You Available.
...
@@ -322,18 +323,25 @@ def multi_remote_exec_cmd(hosts, username, cmd):
...
@@ -322,18 +323,25 @@ def multi_remote_exec_cmd(hosts, username, cmd):
def
exec_cmd_servers
(
username
):
def
exec_cmd_servers
(
username
):
hosts
=
[]
color_print
(
"You can choose in the following IP(s), Use glob or ips split by comma. q/Q to PreLayer."
,
'green'
)
color_print
(
"Input the Host IP(s),Separated by Commas, q/Q to Quit.
\n
\
You can choose in the following IP(s), Use Linux / Unix glob."
,
'green'
)
print_user_host
(
LOGIN_NAME
)
print_user_host
(
LOGIN_NAME
)
while
True
:
while
True
:
hosts
=
[]
inputs
=
raw_input
(
'
\033
[1;32mip(s)>:
\033
[0m'
)
inputs
=
raw_input
(
'
\033
[1;32mip(s)>:
\033
[0m'
)
if
inputs
in
[
'q'
,
'Q'
]:
if
inputs
in
[
'q'
,
'Q'
]:
break
break
get_hosts
=
get_user_host
(
username
)
.
keys
()
get_hosts
=
get_user_host
(
username
)
.
keys
()
for
host
in
get_hosts
:
if
fnmatch
.
fnmatch
(
host
,
inputs
):
if
','
in
inputs
:
hosts
.
append
(
host
.
strip
())
ips_input
=
inputs
.
split
(
','
)
for
host
in
ips_input
:
if
host
in
get_hosts
:
hosts
.
append
(
host
)
else
:
for
host
in
get_hosts
:
if
fnmatch
.
fnmatch
(
host
,
inputs
):
hosts
.
append
(
host
.
strip
())
if
len
(
hosts
)
==
0
:
if
len
(
hosts
)
==
0
:
color_print
(
"Check again, Not matched any ip!"
,
'red'
)
color_print
(
"Check again, Not matched any ip!"
,
'red'
)
continue
continue
...
...
jlog/models.py
View file @
c01a489d
...
@@ -14,4 +14,10 @@ class Log(models.Model):
...
@@ -14,4 +14,10 @@ class Log(models.Model):
end_time
=
models
.
DateTimeField
(
null
=
True
)
end_time
=
models
.
DateTimeField
(
null
=
True
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
log_path
return
self
.
log_path
\ No newline at end of file
class
Alert
(
models
.
Model
):
msg
=
models
.
CharField
(
max_length
=
20
)
time
=
models
.
DateTimeField
(
null
=
True
)
is_finished
=
models
.
BigIntegerField
(
default
=
False
)
\ No newline at end of file
service.sh
View file @
c01a489d
...
@@ -28,15 +28,15 @@ start() {
...
@@ -28,15 +28,15 @@ start() {
daemon python
$base_dir
/manage.py runserver 0.0.0.0:80 &>> /tmp/jumpserver.log 2>&1 &
daemon python
$base_dir
/manage.py runserver 0.0.0.0:80 &>> /tmp/jumpserver.log 2>&1 &
daemon python
$base_dir
/log_handler.py &> /dev/null 2>&1 &
daemon python
$base_dir
/log_handler.py &> /dev/null 2>&1 &
cd
$base_dir
/websocket/
;
daemon node index.js &> /dev/null 2>&1 &
cd
$base_dir
/websocket/
;
daemon node index.js &> /dev/null 2>&1 &
sleep
1
sleep
2
echo
"
$jump_start
"
echo
-n
"
$jump_start
"
nums
=
0
nums
=
0
for
i
in
manage.py log_handler.py index.js
;
do
for
i
in
manage.py log_handler.py index.js
;
do
ps aux |
grep
"
$i
"
|
grep
-v
'grep'
&
&
let
nums+
=
1 &> /dev/null
ps aux |
grep
"
$i
"
|
grep
-v
'grep'
&
> /dev/null
&&
let
nums+
=
1
done
done
if
[
"x
$nums
"
=
"x4
"
]
;
then
if
[
"x
$nums
"
=
=
"x3
"
]
;
then
success
"
$jump_start
"
success
"
$jump_start
"
touch
"
$lockfile
"
touch
"
$lockfile
"
echo
echo
...
...
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