[Merge] lp:~ogra/phablet-tools/phablet-tools-fix-phablet-shell into lp:phablet-tools

♫ Robert Bruce Park ♫ robert.park at canonical.com
Wed Sep 17 16:16:04 UTC 2014


Review: Needs Fixing

Mostly lgtm, check one inline comment below.

Diff comments:

> === modified file 'phablet-shell'
> --- phablet-shell	2014-08-15 12:47:01 +0000
> +++ phablet-shell	2014-09-17 13:25:05 +0000
> @@ -82,10 +82,13 @@
>      adb shell "$CMD >/dev/null"
>  }
>  
> +# if sshd is already runing, do not attempt to start it
> +SSH_RUNNING="$(adb shell pgrep sshd)"
> +
>  # Start ssh on the device and use port forwarding to connect to it.
>  # This means that we'll connect to the device through the USB cable
>  # and won't depend on if the device has it's wifi configured or not.
> -toggle_ssh true
> +[ -n "$SSH_RUNNING" ] || toggle_ssh true
>  
>  for PORT in `seq 2222 2299`; do
>      adb forward tcp:$PORT tcp:22 && break
> @@ -99,10 +102,19 @@
>  
>  # Copy your ssh id down to the device so you never need a password.
>  NEWEST_KEY=$(ls -t ~/.ssh/*.pub | grep -v -- -cert.pub | head -1)
> -adb push $NEWEST_KEY /home/phablet/.ssh/authorized_keys
> -adb shell chown phablet:phablet -R /home/phablet/.ssh/
> -adb shell chmod 700 /home/phablet/.ssh
> -adb shell chmod 600 /home/phablet/.ssh/authorized_keys
> +KEY_CONTENT="$(cat $NEWEST_KEY)"
> +
> +# make sure we have a ~/.ssh/ dir before trying to write to it
> +adb shell "[ -d ~/.ssh ] || mkdir ~/.ssh"
> +
> +# append the key to authorized_keys if it is not there already
> +adb shell "touch  ~/.ssh/authorized_keys"
> +if [ -z "$(adb shell "grep \"$KEY_CONTENT\" ~/.ssh/authorized_keys")" ]; then
> +    adb shell "echo $KEY_CONTENT >>~/.ssh/authorized_keys"
> +    adb shell "chown phablet:phablet -R ~/.ssh/"
> +    adb shell "chmod 700 ~/.ssh"
> +    adb shell "chmod 600 ~/.ssh/authorized_keys"

Actually this chown chmod stuff was a workaround for the fact that adb push was creating files owned by root, you can drop this now that a) you're not using adb push, and b) adb isn't root anymore anyway.

> +fi
>  
>  # Copy your bash config down to the device so you get the benefit of your
>  # colourful $PS1 prompt and any bash aliases that you may be used to from your
> @@ -115,4 +127,4 @@
>  ssh $SSH_OPTS phablet at localhost
>  
>  # turn off ssh access again
> -toggle_ssh false
> +[ -n "$SSH_RUNNING" ] || toggle_ssh false
> 


-- 
https://code.launchpad.net/~ogra/phablet-tools/phablet-tools-fix-phablet-shell/+merge/234976
Your team Ubuntu Phablet Team is subscribed to branch lp:phablet-tools.



More information about the Ubuntu-reviews mailing list