Last active
September 17, 2021 08:17
-
-
Save kenzo0107/7a51b8055e32ebcf87df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# [環境] | |
# MacOSX | |
# AVD (Android Virtual Device) から接続させたいデスクトップ上のローカルホストへの接続設定 | |
# | |
# MacOSX上で構築した接続先ローカルホストを `local-pl-t-dev.jp` としています。 | |
# AVDから接続させたい接続先ローカルホスト | |
CONNECT_LOCALHOST="local-pl-t-dev.jp" | |
# AVD上のLOCAL IP | |
AVD_LOCAL_IP="10.0.2.2" | |
# 接続先ローカルホストが設定されていない場合エラー発生し停止. | |
if [ "${CONNECT_LOCALHOST}" == "" ]; then | |
echo 'Please set CONNECT_LOCALHOST' | |
exit | |
fi | |
# 起動中AVDをマウント | |
adb remount | |
# AVD上のhostsをlocalにダウンロード | |
adb pull /system/etc/hosts ~/hosts | |
SET=$(grep ${AVD_LOCAL_IP} ~/hosts) | |
if [ "${SET}" == "" ]; then | |
echo 'do not set! ' | |
# 接続先ローカルホスト追加 | |
echo "${AVD_LOCAL_IP} ${CONNECT_LOCALHOST}" >> ~/hosts | |
fi | |
# AVDにhostsをpush | |
adb push ~/hosts /system/etc/hosts | |
db pull /system/etc/hosts ~/_avd_hosts | |
# 念のための設定確認 | |
echo ' | |
[emulator hosts configure]' | |
cat ~/_avd_hosts | |
rm ~/_avd_hosts | |
# AVD上のhosts設定確認 | |
# adb shell | |
# cat /system/etc/hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment