dssh 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/share/dssh +65 -39
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9457bc9bcd24cf5c44025db3c4cef1f5f0d5cacf
|
4
|
+
data.tar.gz: be8f47528b8a187da4d41745fb0465a70dbfd6b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d2b3595a2ed7d1c439105fa95b55e393996c0d01f72b8032c77e7f62e402ab733f19e04f503bc4e61ebb30e54d1fffc7fbb50a16aa0796cdcab77ef96e5bbf
|
7
|
+
data.tar.gz: 822053b7125b71cc44937808bc72cf22222c96e677869976dcbafcc4715b043ade56e1bc61f41849eab179378a864f2499c2d8947b8fb1b83cc2121e8b08ab00
|
data/share/dssh
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#! /usr/bin/env bash
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
##############################################################
|
5
|
+
####################### Usage & Options ######################
|
6
|
+
##############################################################
|
7
7
|
|
8
8
|
usage() {
|
9
9
|
cat << EOF
|
@@ -40,9 +40,9 @@ do
|
|
40
40
|
done
|
41
41
|
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
##############################################################
|
44
|
+
####################### Set Options ##########################
|
45
|
+
##############################################################
|
46
46
|
|
47
47
|
CONTAINER_NAMES=$1
|
48
48
|
|
@@ -50,13 +50,17 @@ if [[ -z "$CONTAINER_NAMES" ]]; then
|
|
50
50
|
NL=$'\n'
|
51
51
|
CONTAINER_NAMES=$(docker ps -q | sed ':a;N;$!ba;s/\n/ /g')
|
52
52
|
if [[ "$?" != "0" ]]; then
|
53
|
-
|
54
|
-
|
53
|
+
if [[ "$?" == "130" ]]; then
|
54
|
+
echo "] If you're on OSX, make sure boot2docker is working properly"
|
55
|
+
echo "] In all cases, make sure you're using the right user and command (to sudo or not to sudo)"
|
56
|
+
else
|
57
|
+
echo "] Error while trying to list docker containers"
|
58
|
+
fi
|
55
59
|
fi
|
56
60
|
fi
|
57
61
|
|
58
62
|
if [[ -z "$CONTAINER_NAMES" ]]; then
|
59
|
-
|
63
|
+
usage
|
60
64
|
exit 1
|
61
65
|
fi
|
62
66
|
|
@@ -66,43 +70,65 @@ unset CONTAINER_NAMES[0]
|
|
66
70
|
|
67
71
|
|
68
72
|
|
69
|
-
|
70
|
-
|
71
|
-
|
73
|
+
##############################################################
|
74
|
+
####################### Init nsenter #########################
|
75
|
+
########### https://github.com/jpetazzo/nsenter ##############
|
76
|
+
##############################################################
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
echo "################################################################"
|
80
|
-
echo ""
|
81
|
-
docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter
|
82
|
-
echo ""
|
78
|
+
type docker-enter >/dev/null 2>&1
|
79
|
+
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
|
+
}
|
83
84
|
fi
|
84
|
-
|
85
85
|
|
86
|
-
################################
|
87
|
-
######## Go do stuff!!!! #######
|
88
|
-
################################
|
89
86
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
87
|
+
##############################################################
|
88
|
+
####################### Go do stuff!!!! ######################
|
89
|
+
##############################################################
|
90
|
+
|
91
|
+
echo ""
|
92
|
+
echo -n "] Searching for a container matching \"$CONTAINER_NAME\"..."
|
93
|
+
PID=$( docker inspect --format {{.State.Pid}} "$CONTAINER_NAME" 2>&1 & wait $! )
|
94
|
+
|
95
|
+
CODE=$?
|
96
|
+
if [[ "$CODE" != "0" ]]; then
|
97
|
+
|
98
|
+
echo " no such luck."
|
99
|
+
|
100
|
+
if [[ "$CODE" == "2" ]]; then
|
101
|
+
echo "] No valid docker environment found"
|
102
|
+
elif [[ "$CODE" == "130" ]]; then
|
103
|
+
echo "] Invalid permissions"
|
104
|
+
echo "] Tip: You can't alternate between using 'sudo' for some Docker commands and not others."
|
105
|
+
elif [[ "$CODE" == "1" ]]; then
|
106
|
+
RUNNING_COUNT=$(docker ps | tail -n+2 | grep "" -c)
|
107
|
+
if [[ "$RUNNING_COUNT" == "" ]]; then
|
108
|
+
echo ""
|
109
|
+
echo "] You have no running Docker containers"
|
110
|
+
echo "] Start one with \`docker start\` and then try to enter it"
|
111
|
+
echo ""
|
112
|
+
echo "] Running \`docker ps\` to show available containers"
|
113
|
+
echo ""
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
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
|
+
fi
|
120
|
+
echo " "
|
121
|
+
echo "-----------------------------------------------"
|
96
122
|
echo ""
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
if [[ "$?" != "0" ]]; then
|
103
|
-
exit 0;#/TODO: iterate?
|
123
|
+
else
|
124
|
+
echo "] Unknown error with code $CODE"
|
125
|
+
echo "] nsenter said: $PID"
|
126
|
+
fi
|
127
|
+
exit $CODE
|
104
128
|
fi
|
105
129
|
|
106
130
|
|
131
|
+
echo "] Calling docker-enter with \"$CONTAINER_NAME\""
|
132
|
+
docker-enter "$CONTAINER_NAME"
|
107
133
|
|
108
134
|
|