[Replicant] [PATCH] screencap: Add naive SSH backend implementation.
Wolfgang Wiedmeyer
wreg at wiedmeyer.de
Tue May 23 21:47:05 UTC 2017
Denis 'GNUtoo' Carikli writes:
> This implementation is not efficent as each command will spawn a
> new ssh command, which has considerable overhead and latency.
>
> Example usage:
> ./screencap.sh -h root at 192.168.43.1 -f OUTPUT.PNG
Thanks, applied! It would be good to document this functionality in the
wiki[1]. I'll have a look at the related issue you opened.
I added a small patch on top that restores the possibility to
set the ADB path at the top of the script.
By the way, do you want to have write access to the repo?
Best regards,
Wolfgang
> Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at no-log.org>
> ---
> screencap/screencap.sh | 29 +++++++++++++++++++++++++++--
> 1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/screencap/screencap.sh b/screencap/screencap.sh
> index 53284b3..7ed7d8c 100755
> --- a/screencap/screencap.sh
> +++ b/screencap/screencap.sh
> @@ -18,13 +18,25 @@
> set -e
>
> FFMEG="ffmpeg"
> -ADB="adb"
> +ADB=""
> FB_PATH="/dev/graphics/fb0"
> +SSH_HOST=""
>
> TMP_FB="fb_raw"
> TMP_FB_RS="fb_raw_rs"
> RECOVERY=false
>
> +ssh_wrapper()
> +{
> + if [ "$1" = "shell" ] ; then
> + shift 1
> + ssh "${SSH_HOST}" "su -c \"$@\""
> + elif [ "$1" = "pull" ] ; then
> + shift 1
> + scp ${SSH_HOST}:$@
> + fi
> +}
> +
> print_usage () {
> echo
> echo "Usage: $0 [OPTIONS] -f OUTPUT.PNG"
> @@ -33,6 +45,7 @@ print_usage () {
> echo "Options:"
> echo "-r, --recovery Device is booted in recovery mode"
> echo "-s, --screen-size Specify screen size (mandatory in recovery mode)"
> + echo "-h, --ssh-host Connect to the given host through SSH"
> echo
> }
>
> @@ -66,7 +79,8 @@ take_screenshot () {
> PIX_FMT="rgb565"
> fi
>
> - $ADB pull $FB_PATH $TMP_FB
> + $ADB shell "cat $FB_PATH > /data/local/tmp/$TMP_FB"
> + $ADB pull /data/local/tmp/$TMP_FB $TMP_FB
> dd bs=$BS count=$SCREEN_SIZE_Y if=$TMP_FB of=$TMP_FB_RS
>
> $FFMEG -vcodec rawvideo -f rawvideo -pix_fmt $PIX_FMT -s $SCREEN_SIZE \
> @@ -91,6 +105,11 @@ do
> SCREEN_SIZE="$2"
> shift 2
> ;;
> + -h|--ssh-host)
> + SSH_HOST="$2"
> + shift 2
> + ;;
> +
> "")
> break
> ;;
> @@ -102,6 +121,12 @@ do
> esac
> done
>
> +if [ -z "${SSH_HOST}" ] ; then
> + ADB="adb"
> +else
> + ADB="ssh_wrapper"
> +fi
> +
> if [ "$OUTFILE" = "" ]; then
> echo "No output file specified"
> print_usage
[1] https://redmine.replicant.us/projects/replicant/wiki/Screenshots
--
Website: https://fossencdi.org
OpenPGP: 0F30 D1A0 2F73 F70A 6FEE 048E 5816 A24C 1075 7FC4
Key download: https://wiedmeyer.de/keys/ww.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/replicant/attachments/20170523/352be199/attachment.asc>
More information about the Replicant
mailing list