dssh 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dssh +0 -0
  3. data/share/dssh +36 -10
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9457bc9bcd24cf5c44025db3c4cef1f5f0d5cacf
4
- data.tar.gz: be8f47528b8a187da4d41745fb0465a70dbfd6b7
3
+ metadata.gz: 0bba1fcd151307b0e5c3c3ff4b5d357ef086fbcb
4
+ data.tar.gz: c93edd379bccc6f0abc206822705f57ba12b753e
5
5
  SHA512:
6
- metadata.gz: 80d2b3595a2ed7d1c439105fa95b55e393996c0d01f72b8032c77e7f62e402ab733f19e04f503bc4e61ebb30e54d1fffc7fbb50a16aa0796cdcab77ef96e5bbf
7
- data.tar.gz: 822053b7125b71cc44937808bc72cf22222c96e677869976dcbafcc4715b043ade56e1bc61f41849eab179378a864f2499c2d8947b8fb1b83cc2121e8b08ab00
6
+ metadata.gz: 4adbf47f19c019721b12844b3ff377ab5cbfe042324360d300cdc2548c4d223fcca5f10c9f8965c7d1334c16996e2b31c8252eb4ad9b5e49f06d848c1cd9bdf1
7
+ data.tar.gz: 830ecca17c27baabde9251ff1bfc4df3b53c15fed5c5bcb242e7e9ada280a949453dfc7fc6afb067fc5d2075913d5c26a97c796486c696347612d4ca9e4d87cc
data/bin/dssh CHANGED
File without changes
data/share/dssh CHANGED
@@ -14,7 +14,7 @@ Options:
14
14
  -h Show this message
15
15
  -v Verbose
16
16
 
17
- Uses nsenter to provice a terminal to a Docker container.
17
+ Uses nsenter to provide a terminal to a Docker container.
18
18
  Looks and feels like an ssh client.
19
19
 
20
20
  EOF
@@ -22,7 +22,7 @@ EOF
22
22
 
23
23
  VERBOSE=
24
24
 
25
- while getopts hv OPTION
25
+ while getopts "hv" OPTION
26
26
  do
27
27
  case $OPTION in
28
28
  h)
@@ -39,6 +39,16 @@ do
39
39
  esac
40
40
  done
41
41
 
42
+ _abort() {
43
+ echo ""
44
+ echo "Aborting..."
45
+ echo ""
46
+ }
47
+ trap _abort EXIT
48
+
49
+ CheckReturnValue() {
50
+ if [[ "$?" != "0" ]]; then _abort; fi;
51
+ }
42
52
 
43
53
  ##############################################################
44
54
  ####################### Set Options ##########################
@@ -75,12 +85,29 @@ unset CONTAINER_NAMES[0]
75
85
  ########### https://github.com/jpetazzo/nsenter ##############
76
86
  ##############################################################
77
87
 
88
+ mkdir -p log/jpetazzo
89
+ LOG_FILE=log/jpetazzo/nsenter
90
+
78
91
  type docker-enter >/dev/null 2>&1
79
92
  if [[ "$?" != "0" ]]; then
80
- docker-enter() {
81
- boot2docker ssh '[ -f /var/lib/boot2docker/nsenter ] || docker run --rm -v /var/lib/boot2docker/:/target jpetazzo/nsenter'
82
- boot2docker ssh -t sudo /var/lib/boot2docker/docker-enter "$@"
83
- }
93
+
94
+ if [[ ! -f $LOG_FILE ]]; then
95
+ echo "] Pulling down a Docker image containing nsenter..." > log/jpetazzo/nsenter
96
+ docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter
97
+ CheckReturnValue
98
+ fi
99
+
100
+ if [[ "$(uname)" == 'Darwin' ]]; then
101
+ docker-enter() {
102
+ boot2docker ssh '[ -f /var/lib/boot2docker/nsenter ] || docker run --rm -v /var/lib/boot2docker/:/target jpetazzo/nsenter'
103
+ boot2docker ssh -t sudo /var/lib/boot2docker/docker-enter "$@"
104
+ }
105
+ else
106
+ docker-enter() {
107
+ nsenter --target $1 --mount --uts --ipc --net --pid
108
+ }
109
+ fi
110
+
84
111
  fi
85
112
 
86
113
 
@@ -112,12 +139,9 @@ if [[ "$CODE" != "0" ]]; then
112
139
  echo "] Running \`docker ps\` to show available containers"
113
140
  echo ""
114
141
 
115
-
116
-
117
-
118
142
  docker ps -n 5 | tail -n+2 | awk '{FS="[, \t][, \t]+"} BEGIN{ printf("%-20s %-30s %-15s %-10s\n","Container ID","Image","Created","Name")} {printf("%-20s %-30s %-15s %-10s\n",$1,$2,$4,$6)}'
119
143
  fi
120
- echo " "
144
+ echo ""
121
145
  echo "-----------------------------------------------"
122
146
  echo ""
123
147
  else
@@ -125,6 +149,8 @@ if [[ "$CODE" != "0" ]]; then
125
149
  echo "] nsenter said: $PID"
126
150
  fi
127
151
  exit $CODE
152
+ else
153
+ echo ' container found! '"PID $PID"
128
154
  fi
129
155
 
130
156
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2014-08-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Uses nsenter to provice a terminal to a Docker container. Looks and feels
14
14
  like an ssh client.
@@ -31,12 +31,12 @@ require_paths:
31
31
  - lib
32
32
  required_ruby_version: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
37
  required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  requirements: []