add scritp

This commit is contained in:
Jean-Marie Mineau 2025-03-28 09:43:21 +01:00
commit df5cca3183
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
6 changed files with 90 additions and 0 deletions

13
android_env Normal file
View file

@ -0,0 +1,13 @@
# Various Android directories, see <https://developer.android.com/tools/variables#envar> for more information
export ANDROID_HOME="${HOME}/Android/Sdk"
export ANDROID_USER_HOME="${HOME}/.android"
export ANDROID_EMULATOR_HOME="${HOME}/.android"
# Various directories containing android executables
export PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}"
export PATH="${ANDROID_HOME}/emulator:${PATH}"
export PATH="${ANDROID_HOME}/platform-tools:${PATH}"
# If not set, adb will not see more than 16 emulators
export ADB_LOCAL_TRANSPORT_MAX_PORT=5885

8
delate_emulators.sh Normal file
View file

@ -0,0 +1,8 @@
#!/usr/bin/bash
BASENAME='root34'
MAX_EMU=10
for i in $(seq 1 "${MAX_EMU}"); do
avdmanager delete avd --name "${BASENAME}-${i}"
done

19
emulator_first_boot.sh Normal file
View file

@ -0,0 +1,19 @@
#!/usr/bin/bash
# For some reason, the emulator will only boot in debug mode. Why? no fucking clue, ask google.
# Anyway, once booted a snapshot is created that will be used for the next times that will work
# without debug-init.
BASENAME='root34'
MAX_EMU=10
sdkmanager "${IMG}"
# kill all emulators:
# for e in $(adb devices | grep emulator | sed 's/\t.*//'); do adb -s $e emu kill; done
for i in $(seq 1 "${MAX_EMU}"); do
emulator -avd "${BASENAME}-${i}" -no-window -no-metrics -debug-init -logcat '*:v' &
done
#for i in $(seq 17 32); do
# emulator -avd "${BASENAME}-${i}" -no-window -no-metrics -debug-init -logcat '*:v' &
#done

14
install_android.sh Normal file
View file

@ -0,0 +1,14 @@
#!/usr/bin/bash
mkdir -p "${ANDROID_HOME}" \
&& mkdir -p "${ANDROID_USER_HOME}" \
&& mkdir /tmp/tmpinstall \
&& curl https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o /tmp/tmpinstall/cmdlinetools.zip \
&& unzip /tmp/tmpinstall/cmdlinetools.zip -d /tmp/tmpinstall/ \
&& yes | /tmp/tmpinstall/cmdline-tools/bin/sdkmanager 'cmdline-tools;latest' --sdk_root=${ANDROID_HOME} \
&& rm -rf /tmp/tmpinstall \
&& yes | sdkmanager --licenses \
&& sdkmanager 'platform-tools' \
&& sdkmanager 'emulator' \
&& sdkmanager 'platforms;android-34' \
&& sdkmanager 'system-images;android-34;default;x86_64'

11
make_emulators.sh Normal file
View file

@ -0,0 +1,11 @@
#!/usr/bin/bash
IMG='system-images;android-34;default;x86_64'
BASENAME='root34'
MAX_EMU=10
sdkmanager "${IMG}"
for i in $(seq 1 "${MAX_EMU}"); do
avdmanager create avd --name "${BASENAME}-${i}" --package "${IMG}" --sdcard 512M --device medium_phone
done

25
start_emulators.sh Normal file
View file

@ -0,0 +1,25 @@
#!/usr/bin/bash
BASENAME='root34'
MAX_EMU=10
LOG_DIR=${1:-$(mktemp -d)}
START_PORT=5554
# kill all emulators:
# for e in $(adb devices | grep emulator | sed 's/\t.*//'); do adb -s $e emu kill; done
# and for the few that refuse to die after a few moments:
# pkill -f /home/android/Android/Sdk/emulator/qemu/linux-x86_64/qemu-system-x86_64-headless
echo "Emulator Log DIR: ${LOG_DIR}"
for i in $(seq 1 "${MAX_EMU}"); do
CONSOLE_PORT=$((START_PORT++))
ADB_PORT=$((START_PORT++))
adb devices | grep -q "emulator-${CONSOLE_PORT}"
if [ $? -ne 0 ]
then
echo "start ${BASENAME}-${i} (emulator-${CONSOLE_PORT})"
emulator -avd "${BASENAME}-${i}" -no-window -no-metrics -ports "${CONSOLE_PORT},${ADB_PORT}" > "${LOG_DIR}/emulator-${CONSOLE_PORT}.stdout" 2> "${LOG_DIR}/emulator-${CONSOLE_PORT}.stderr" &
sleep 2
fi
done