dssh 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/dssh +94 -0
  3. metadata +46 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99147f7a1f74d19b0e488e9586fafed807ccdf86
4
+ data.tar.gz: b7d79339483715428da79af582999318e3340fd0
5
+ SHA512:
6
+ metadata.gz: 837d4b948cad73fad2e5607370449348b1b7cabc17383440241364f08c84c0d096bff6b6bd64be3ab5ff7cc80d373cf9bc6672b1312c96bc81119cc6d7698749
7
+ data.tar.gz: 9db0f1ca406d7241140ab9a6644a376073a1e6b631576bf43f8f94a692e6ba495dddea838ad9aa65882e5ddbe6cb83af3eac91efb65aa865b9bc820886f044a5
@@ -0,0 +1,94 @@
1
+ #!/bin/bash
2
+
3
+
4
+ ################################
5
+ ######## Usage & Options #######
6
+ ################################
7
+
8
+ usage() {
9
+ cat << EOF
10
+
11
+ Usage: $0 [options]
12
+
13
+ Options:
14
+ -h Show this message
15
+ -v Verbose
16
+
17
+ Uses nsenter to provice a terminal to a Docker container.
18
+ Looks and feels like an ssh client.
19
+
20
+ EOF
21
+ }
22
+
23
+ VERBOSE=
24
+
25
+ while getopts “hv” OPTION
26
+ do
27
+ case $OPTION in
28
+ h)
29
+ usage
30
+ exit 1
31
+ ;;
32
+ v)
33
+ VERBOSE=1
34
+ ;;
35
+ ?)
36
+ usage
37
+ exit
38
+ ;;
39
+ esac
40
+ done
41
+
42
+
43
+ ################################
44
+ ######## Go do stuff!!!! #######
45
+ ################################
46
+
47
+ CONTAINER_NAMES=$1
48
+
49
+ if [[ -z "$CONTAINER_NAMES" ]]; then
50
+ NL=$'\n'
51
+ CONTAINER_NAMES=$(docker ps -q | sed ':a;N;$!ba;s/\n/ /g')
52
+ if [[ "$?" != "0" ]]; then
53
+ echo "If you're on OSX, make sure boot2docker is working properly"
54
+ echo "Otherwise, use sudo"
55
+ fi
56
+ fi
57
+
58
+ if [[ -z "$CONTAINER_NAMES" ]]; then
59
+ echo "Usage: $0 container_name"
60
+ exit 1
61
+ fi
62
+
63
+ #https://github.com/jpetazzo/nsenter
64
+
65
+ CONTAINER_NAMES=( ""${CONTAINER_NAMES[$@]}"" )
66
+ CONTAINER_NAME=${CONTAINER_NAMES[0]}
67
+ unset CONTAINER_NAMES[0]
68
+ echo "Will use search for a container matching ""$CONTAINER_NAME"""
69
+
70
+ if [[ ! -f /usr/local/bin/nsenter ]]; then
71
+ docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter
72
+ fi
73
+
74
+ echo "Fetching pid of $CONTAINER_NAME..."
75
+ PID=$(docker inspect --format {{.State.Pid}} $CONTAINER_NAME)
76
+
77
+ if [[ "$?" != "0" ]]; then
78
+ echo ""
79
+ echo "Run \`docker ps\` to see available containers"
80
+ docker ps
81
+ echo ""
82
+ exit 1
83
+ fi
84
+
85
+ echo "Connecting to container $CONTAINER_NAME with pid $PID..."
86
+ nsenter --target $PID --mount --uts --ipc --net --pid
87
+
88
+ if [[ "$?" != "0" ]]; then
89
+ exit 0;#/TODO: iterate?
90
+ fi
91
+
92
+
93
+
94
+
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dssh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Johnson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Uses nsenter to provice a terminal to a Docker container. Looks and feels
14
+ like an ssh client.
15
+ email: stevej@ucla.edu
16
+ executables:
17
+ - dssh
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/dssh
22
+ homepage: http://rubygems.org/gems/dssh
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Docker ssh
46
+ test_files: []