dssh 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dssh +6 -93
- data/lib/dssh.rb +6 -0
- data/share/dssh +108 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6c195466d73ad8235b04a1af45db1f59c61ea5c
|
4
|
+
data.tar.gz: 775a91c9e7e56f0df75fb26a5e4bf60f0ba58143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5d011035153ff5bf20575aa1e3797d5315fa38ca9c036c662e5f9ca64f81340bc40801e87490886703d142a8b3b6793681730dfd366d0ea42e7f3e4e60da3b0
|
7
|
+
data.tar.gz: 3d4c2751a5ada363a599fe753df8d685c4f88a109ff79daf6ef8beb7e038d359f046f38bbc9101eb341ec22d325e6bb007ec67b71fd1833cbe7a7cb4cc280a14
|
data/bin/dssh
CHANGED
@@ -1,94 +1,7 @@
|
|
1
|
-
#!/bin/
|
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
|
-
|
1
|
+
#!/usr/bin/env ruby
|
94
2
|
|
3
|
+
name = 'dssh'
|
4
|
+
args = "'#{ARGV.join("','")}'"
|
5
|
+
gempath = Gem::Specification.find_by_name( name )
|
6
|
+
exepath = File.join( gempath.full_gem_path, 'share/dssh' )
|
7
|
+
exec( "/bin/bash #{exepath} #{args} 2>&1" )
|
data/lib/dssh.rb
ADDED
data/share/dssh
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#! /usr/bin/env 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
|
+
######## Set Options ###########
|
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
|
+
CONTAINER_NAMES=( ""${CONTAINER_NAMES[$@]}"" )
|
64
|
+
CONTAINER_NAME=${CONTAINER_NAMES[0]}
|
65
|
+
unset CONTAINER_NAMES[0]
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
################################
|
70
|
+
######### Dependencies #########
|
71
|
+
################################
|
72
|
+
|
73
|
+
|
74
|
+
#https://github.com/jpetazzo/nsenter
|
75
|
+
if [[ ! -f /usr/local/bin/nsenter ]]; then
|
76
|
+
echo "################################################################"
|
77
|
+
echo "###################### Fetching nsenter ########################"
|
78
|
+
echo "############# (https://github.com/jpetazzo/nsenter) ############"
|
79
|
+
echo "################################################################"
|
80
|
+
echo ""
|
81
|
+
docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter
|
82
|
+
echo ""
|
83
|
+
fi
|
84
|
+
|
85
|
+
|
86
|
+
################################
|
87
|
+
######## Go do stuff!!!! #######
|
88
|
+
################################
|
89
|
+
|
90
|
+
echo "Searching for a container matching \"$CONTAINER_NAME\""
|
91
|
+
PID=$(docker inspect --format {{.State.Pid}} $CONTAINER_NAME)
|
92
|
+
if [[ "$?" != "0" ]]; then
|
93
|
+
echo ""
|
94
|
+
echo "Run \`docker ps\` to see available containers"
|
95
|
+
docker ps
|
96
|
+
echo ""
|
97
|
+
exit 1
|
98
|
+
fi
|
99
|
+
|
100
|
+
echo "Connecting to container $CONTAINER_NAME with pid $PID..."
|
101
|
+
nsenter --target $PID --mount --uts --ipc --net --pid
|
102
|
+
if [[ "$?" != "0" ]]; then
|
103
|
+
exit 0;#/TODO: iterate?
|
104
|
+
fi
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Johnson
|
@@ -19,6 +19,8 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- bin/dssh
|
22
|
+
- lib/dssh.rb
|
23
|
+
- share/dssh
|
22
24
|
homepage: http://rubygems.org/gems/dssh
|
23
25
|
licenses:
|
24
26
|
- MIT
|