Merge lp:~robru/phablet-tools/phablet-shell into lp:phablet-tools

Proposed by Robert Bruce Park
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 277
Merged at revision: 276
Proposed branch: lp:~robru/phablet-tools/phablet-shell
Merge into: lp:phablet-tools
Diff against target: 111 lines (+96/-0)
2 files modified
phablet-shell (+95/-0)
setup.py (+1/-0)
To merge this branch: bzr merge lp:~robru/phablet-tools/phablet-shell
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Sergio Schvezov Approve
Michael Terry Pending
Ubuntu Phablet Team Pending
Review via email: mp+219266@code.launchpad.net

Commit message

Add phablet-shell tool for a nicer shell experience on device.

To post a comment you must log in.
270. By Robert Bruce Park

Install script.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Can we package split this into a ci binary package?

Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Revision history for this message
Robert Bruce Park (robru) wrote :

Lol, did you review the right branch Sergio? This one has nothing to do with CI, it's just a script that whips up some ssh magic to give a (much) nicer shell experience on the phone than you'd get with your typical 'adb shell' command. Seems to fit right in with all the other phablet-* tools to me.

I have no problem taking my *other* branch and splitting it off into it's own -citrain package.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

On Wed, May 14, 2014 at 3:58 PM, Robert Bruce Park <
<email address hidden>> wrote:

> Lol, did you review the right branch Sergio? This one has nothing to do
> with CI, it's just a script that whips up some ssh magic to give a (much)
> nicer shell experience on the phone than you'd get with your typical 'adb
> shell' command. Seems to fit right in with all the other phablet-* tools to
> me.
>

> I have no problem taking my *other* branch and splitting it off into it's
> own -citrain package.
>

yeah, sorry about this, I meant it to send that to the other branch.
Anyways, it's just one script, no need for it so disregard the packaging
split comment

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

It takes to long to login if we do the ssh key dance all the time. Do you mind stripping that? It will be useless soon anyways since ssh would need to be manually enabled soon (or through a flash option) due to security reasons.

We also need to think that forwarding to the same port isn't feasible in a multi connected device scenario

review: Needs Fixing
Revision history for this message
Robert Bruce Park (robru) wrote :

Hmmm I'm using this all the time and the performance isn't bad...

Revision history for this message
Robert Bruce Park (robru) wrote :

Also, the script is already manually starting ssh each time.

You're right about the multi-device setup though, I'm just using this with a single device.

Revision history for this message
Robert Bruce Park (robru) wrote :

it's not hard to imagine a way to programmatically select an available port instead of hard-coding 2222 each time, but one thing I'm not sure about is how to avoid copying down the ssh key and bash config each time... I'm not sure how to check for those in order to avoid doing them redundantly. open to suggestions though.

271. By Robert Bruce Park

Merge trunk.

272. By Robert Bruce Park

Pick a fresh port for each device.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
273. By Robert Bruce Park

Use rsync and reduce code duplication.

274. By Robert Bruce Park

Quiet rsync.

275. By Robert Bruce Park

Add usage help.

276. By Robert Bruce Park

Use check_devices.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Bruce Park (robru) wrote :

Please take another look at this, I think it's starting to shape up.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
277. By Robert Bruce Park

Use adb push instead of ssh-copy-id so password is never needed.

Revision history for this message
Robert Bruce Park (robru) wrote :

Hi Sergio,

I dropped ssh-copy-id in favor of adb push, which means now this tool never does a password login, so it should be safe when password logins get shut off soon.

Please re-review!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
278. By Robert Bruce Park

Do argument parsing.

279. By Robert Bruce Park

Some fixes.

280. By Robert Bruce Park

Misc fixes.

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'phablet-shell'
2--- phablet-shell 1970-01-01 00:00:00 +0000
3+++ phablet-shell 2014-05-27 15:16:30 +0000
4@@ -0,0 +1,95 @@
5+#!/bin/sh -e
6+# This program is free software: you can redistribute it and/or modify it
7+# under the terms of the the GNU General Public License version 3, as
8+# published by the Free Software Foundation.
9+#
10+# This program is distributed in the hope that it will be useful, but
11+# WITHOUT ANY WARRANTY; without even the implied warranties of
12+# MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
13+# PURPOSE. See the applicable version of the GNU General Public
14+# License for more details.
15+#.
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+# Copyright (C) 2014 Canonical, Ltd.
20+
21+usage () {
22+cat <<EOF
23+Usage: $0 [-s SERIAL]
24+
25+This tool will start ssh on your connected Ubuntu Touch device, forward a local
26+port to the device, copy your ssh id down to the device (so you only have to log
27+in once), rsync down your bash config so you get any nice prompt & aliases you
28+might be used to from your host bash config, and then finally sshs into the
29+device through the locally forwarded port.
30+
31+This results in a very nice shell, which for example can display the output of
32+'top' at the correct terminal size, rather than being stuck at 80x25 like 'adb
33+shell'
34+
35+Like ssh-copy-id, this script will push down the newest ssh key it can find in
36+~/.ssh/*.pub, so if you find the wrong key being pushed down, simply use 'touch'
37+to make your desired key the newest one, and then this script will find it.
38+EOF
39+exit 1
40+}
41+
42+if [ -f "$(dirname $0)/shell-adb-common.sh" ]; then
43+ . "$(dirname $0)/shell-adb-common.sh"
44+else
45+ . "/usr/share/phabletutils/shell-adb-common.sh"
46+fi
47+
48+ARGS=$(getopt -o hs: -n "$0" -- "$@")
49+if [ $? -ne 0 ] ; then
50+ usage
51+fi
52+eval set -- "$ARGS"
53+
54+while true; do
55+ case "$1" in
56+ -h)
57+ usage
58+ ;;
59+ -s)
60+ export ANDROID_SERIAL="$2"
61+ shift 2
62+ break
63+ ;;
64+ *)
65+ break
66+ ;;
67+ esac
68+done
69+
70+check_devices
71+
72+# Start ssh on the device and use port forwarding to connect to it.
73+# This means that we'll connect to the device through the USB cable
74+# and won't depend on if the device has it's wifi configured or not.
75+adb shell start ssh
76+for PORT in `seq 2222 2299`; do
77+ adb forward tcp:$PORT tcp:22 && break
78+done
79+
80+SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p $PORT"
81+
82+# Purge the device host key so that SSH doesn't print a scary warning about it
83+# (it changes every time the device is reflashed and this is expected)
84+ssh-keygen -f ~/.ssh/known_hosts -R [localhost]:$PORT
85+
86+# Copy your ssh id down to the device so you never need a password.
87+NEWEST_KEY=$(ls -t ~/.ssh/*.pub | grep -v -- -cert.pub | head -1)
88+adb push $NEWEST_KEY /home/phablet/.ssh/authorized_keys
89+adb shell chown phablet:phablet -R /home/phablet/.ssh/
90+adb shell chmod 700 /home/phablet/.ssh
91+adb shell chmod 600 /home/phablet/.ssh/authorized_keys
92+
93+# Copy your bash config down to the device so you get the benefit of your
94+# colourful $PS1 prompt and any bash aliases that you may be used to from your
95+# host device.
96+rsync -qae "ssh $SSH_OPTS" ~/.bash* ~/.profile* phablet@localhost:/home/phablet
97+
98+# Now connect to the device and provide the user with a shell.
99+ssh $SSH_OPTS phablet@localhost
100
101=== modified file 'setup.py'
102--- setup.py 2014-05-15 19:59:37 +0000
103+++ setup.py 2014-05-27 15:16:30 +0000
104@@ -21,6 +21,7 @@
105 'phablet-test-run',
106 'click-buddy',
107 'phablet-bootchart',
108+ 'phablet-shell',
109 ]
110
111 DATA_FILES = [

Subscribers

People subscribed via source and target branches