-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
Package: unetlab-x-integration | ||
Priority: extra | ||
Section: net | ||
Installed-Size: 755 | ||
Installed-Size: 1396 | ||
Maintainer: Sergei Eremenko <[email protected]> | ||
Architecture: all | ||
Version: 0.1.2 | ||
Depends: telnet, wireshark, ssh-askpass-gnome | ssh-askpass, xterm | x-terminal-emulator | ||
Recommends: vinagre, docker-engine | docker.io | ||
Version: 0.2.0 | ||
Depends: python, ssh-askpass-gnome | ssh-askpass, telnet, vinagre, wireshark, xterm | x-terminal-emulator | ||
Recommends: docker-engine | docker.io | ||
Homepage: http://smartfinn.github.io/unetlab-x-integration/ | ||
Description: a tool which helps UNetLab to integrate with Ubuntu/Debian | ||
This package provides the following protocols: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,42 @@ | ||
#!/bin/bash | ||
|
||
URI=(`echo $1 | \ | ||
sed -r 's%^(.*)://([a-Z0-9\\-\\.]+):?([0-9]+)?/?(.*)$%x\1 x\2 x\3 x\4%'`) | ||
|
||
URI_SCHEME=${URI[0]#x} | ||
URI_HOST=${URI[1]#x} | ||
URI_PORT=${URI[2]#x} | ||
URI_PATH=${URI[3]#x} | ||
|
||
case "$URI_SCHEME" in | ||
telnet) | ||
x-terminal-emulator -e "telnet $URI_HOST $URI_PORT" | ||
;; | ||
capture) | ||
ssh -l root $URI_HOST tcpdump -s 0 -U -n -i $URI_PATH -w - | \ | ||
wireshark -k -i - | ||
;; | ||
docker) | ||
x-terminal-emulator -e "docker -H $URI_HOST:$URI_PORT attach \ | ||
${URI_PATH%%\?*}" | ||
;; | ||
esac | ||
#!/usr/bin/env python | ||
# See https://github.com/SmartFinn/unetlab-x-integration/ | ||
|
||
from __future__ import print_function | ||
from subprocess import Popen | ||
|
||
import sys | ||
|
||
|
||
def main(argv): | ||
try: | ||
from urllib.parse import urlparse | ||
except ImportError: | ||
from urlparse import urlparse | ||
|
||
u = urlparse(argv) | ||
|
||
d = { | ||
'host': u.hostname, | ||
'port': u.port, | ||
'path': u.path.lstrip('/'), | ||
} | ||
|
||
if u.scheme == 'capture': | ||
Popen('ssh -l root {host} tcpdump -s 0 -U -n -i {path} -w - | \ | ||
wireshark -k -i -'.format(**d), shell=True) | ||
elif u.scheme == 'docker': | ||
Popen('x-terminal-emulator -e \ | ||
"docker -H {host}:{port} attach {path}"'.format(**d), shell=True) | ||
elif u.scheme == 'telnet': | ||
Popen('x-terminal-emulator -e "telnet {host} {port}"'.format(**d), | ||
shell=True) | ||
else: | ||
return 'URL "{}" is currently not supported.'.format(u.geturl()) | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
sys.exit(main(sys.argv[1])) | ||
except IndexError: | ||
print('usage:', __file__, '<url>', file=sys.stderr) | ||
sys.exit(1) |