Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup to support emulator only #7

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM alpine:3.4

MAINTAINER Anton Malinskiy <[email protected]>

ENV PATH $PATH:/opt/platform-tools:/opt/gnirehtet-rust-linux64
ENV PATH $PATH:/opt/platform-tools

RUN set -xeo pipefail && \
mkdir -m 0750 /root/.android && \
Expand All @@ -20,14 +20,7 @@ RUN set -xeo pipefail && \
rm "/root/.wget-hsts" && \
rm "/tmp/glibc.apk" "/tmp/glibc-bin.apk" && \
curl https://sh.rustup.rs -sSf | sh -s -- -y && \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this line as well. it installs rust as a requirement for gnirehtet

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

curl -sL -o gnirehtet.zip https://github.com/Genymobile/gnirehtet/releases/download/v2.3/gnirehtet-rust-linux64-v2.3.zip && \
echo "561d77e94d65ecf2d919053e5da6109b8cceb73bffedea71cd4e51304ccaa3d3 gnirehtet.zip" | sha256sum -c && \
mkdir -p /opt && \
unzip gnirehtet.zip -d /opt && \
chmod +x /opt/gnirehtet-rust-linux64/gnirehtet && \
mv /opt/gnirehtet-rust-linux64/* / && \
rm -R /opt/gnirehtet-rust-linux64 && \
rm gnirehtet.zip && \
rm -r /var/cache/apk/APKINDEX.* && \
npm install rethinkdb

Expand Down
8 changes: 1 addition & 7 deletions bin/adb-reconnect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@

while read d
do
if [ -z "$STF_PROVIDER_PUBLIC_IP" ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep in mind that despite the comment below, STF_PROVIDER_PUBLIC_IP variable is not a marker of "real devices".

# real devices
timeout -t 3 adb -s $d reboot
timeout -t 3 adb -s $d reconnect
else
date > /tmp/reboot
fi
adb -s $d reconnect
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would keep the timeout to ensure quicker workaround, because adb command can easily get stuck for a long time

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added timeout

done < "${1:-/dev/stdin}"
9 changes: 0 additions & 9 deletions bin/adb_server.sh

This file was deleted.

28 changes: 0 additions & 28 deletions bin/device_setup.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
#!/usr/bin/env bash

DL=/tmp/devices_list
PKG=com.genymobile.gnirehtet

rm -f $DL
touch -f $DL
sleep 10

cd / || exit

function setup_gnirehtet {
local DEVICE=$1

if (echo -n | adb -s $d shell pm list packages | grep -q $PKG); then
echo Already have $PKG
else
echo Not installed $PKG
echo -n | timeout -t 30 ./gnirehtet install $DEVICE
echo -n | timeout -t 30 adb -s $d reverse localabstract:gnirehtet tcp:31416
echo -n | timeout -t 30 adb -s $d shell am broadcast -a com.genymobile.gnirehtet.START -n com.genymobile.gnirehtet/.GnirehtetControlReceiver --esa dnsServers 10.120.1.123
fi
}

function cleanup_gnirehtet {
local DEVICE=$1
echo -n | timeout -t 30 ./gnirehtet stop $DEVICE
echo -n | timeout -t 30 ./gnirehtet uninstall $DEVICE
}

function clean_agoda_staff {
local DEVICE=$1

Expand Down Expand Up @@ -70,14 +50,6 @@ while sleep 1; do

kick_rebooter $d
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless you install the rebooter app on emulators, this can probably be removed, together with the function definition above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


if [ "$GNIREHTET_ENABLED" = "true" ]; then
echo Gonna setup gnirehtet for $d
setup_gnirehtet $d
else
echo Gonna cleanup gnrehtet for $d
cleanup_gnirehtet $d
fi

clean_agoda_staff $d
done

Expand Down
20 changes: 0 additions & 20 deletions bin/gnirehtet_reconnect.sh

This file was deleted.

28 changes: 0 additions & 28 deletions bin/gnirehtet_reconnect_one.sh

This file was deleted.

9 changes: 0 additions & 9 deletions bin/gnirehtet_start.sh

This file was deleted.

38 changes: 0 additions & 38 deletions bin/metrics-battery.js

This file was deleted.

1 change: 0 additions & 1 deletion cron/root
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
* * * * * /bin/bash /metrics.sh
* * * * * /bin/bash /usb-rebind.sh
* * * * * /usr/bin/node /label.js
* * * * * /usr/bin/node /metrics-battery.js
* * * * * /usr/bin/node /device-status-monitor.js | /bin/bash /adb-reconnect.sh
9 changes: 0 additions & 9 deletions supervisor/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ command=/adb_server.sh
autorestart=true
priority=10000

[program:gnirehtet_start]
command=/gnirehtet_start.sh
autorestart=true
priority=9000

[program:bootstrap]
command=/stf_bootstrap.sh
priority=8000
Expand All @@ -41,9 +36,5 @@ priority=7000
[program:cron]
command=crond -f

[program:gnirehtet_reconnect]
command=/gnirehtet_reconnect.sh
autorestart=true

[include]
files = /etc/supervisord.d/*.conf