Skip to content

Commit

Permalink
Update ATVServices.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Astu04 authored Mar 17, 2024
1 parent ca7baa6 commit bbf07c4
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions custom/ATVServices.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ setprop net.dns1 1.1.1.1 && setprop net.dns2 4.4.4.4
# Check for the mitm pkg

get_mitm_pkg() { # This function is so hardcoded that I'm allergic to it
busybox ps aux | grep -E -C0 "pokemod|gocheats" | grep -C0 -v grep | awk -F ' ' '/com.pokemod/{print $NF} /com.gocheats.launcher/{print $NF}' | grep -E -C0 "pokemod|gocheats" | sed -e 's/^[0-9]*://' -e 's@:.*@@g' | sort | uniq
busybox ps aux | grep -E -C0 "pokemod|gocheats|sy1vi3" | grep -C0 -v grep | awk -F ' ' '/com.pokemod/{print $NF} /com.sy1vi3/{print $NF} /com.gocheats.launcher/{print $NF}' | grep -E -C0 "gocheats|pokemod|sy1vi3" | sed -e 's/^[0-9]*://' -e 's@:.*@@g' | sort | uniq
}

check_mitmpkg() {
if [ "$(pm list packages com.gocheats.launcher)" = "package:com.gocheats.launcher" ]; then
log -p i -t eMagiskATVService "Found GC!"
MITMPKG=com.gocheats.launcher
elif [ "$(pm list packages com.pokemod.aegis.beta)" = "package:com.pokemod.aegis.beta" ]; then
if [ "$(pm list packages com.pokemod.aegis.beta)" = "package:com.pokemod.aegis.beta" ]; then
log -p i -t eMagiskATVService "Found Aegis developer version!"
MITMPKG=com.pokemod.aegis.beta
elif [ "$(pm list packages com.pokemod.aegis)" = "package:com.pokemod.aegis" ]; then
Expand All @@ -27,6 +24,12 @@ check_mitmpkg() {
elif [ "$(pm list packages com.pokemod.atlas)" = "package:com.pokemod.atlas" ]; then
log -p i -t eMagiskATVService "Found Atlas production version!"
MITMPKG=com.pokemod.atlas
elif [ "$(pm list packages com.sy1vi3.cosmog)" = "package:com.sy1vi3.cosmog" ]; then
log -p i -t eMagiskATVService "Found Cosmog!"
MITMPKG=com.sy1vi3.cosmog
elif [ "$(pm list packages com.gocheats.launcher)" = "package:com.gocheats.launcher" ]; then
log -p i -t eMagiskATVService "Found GC!"
MITMPKG=com.gocheats.launcher
else
log -p i -t eMagiskATVService "No MITM installed. Abort!"
exit 1
Expand Down Expand Up @@ -81,6 +84,10 @@ force_restart() {
elif [[ $MITMPKG == com.pokemod.aegis* ]]; then
am startservice $MITMPKG/com.pokemod.aegis.services.MappingService
fi
elif [[ $MITMPKG == com.sy1vi3* ]]; then
am force-stop $MITMPKG
sleep 5
am start -n $MITMPKG/.MainActivity
fi
log -p i -t eMagiskATVService "Services were restarted!"
}
Expand Down Expand Up @@ -120,9 +127,11 @@ webhook() {

mitmDeviceName="NO NAME"
if [ -f /data/local/tmp/atlas_config.json ]; then
mitmDeviceName=$(cat /data/local/tmp/atlas_config.json | awk -F\" '{print $12}')
mitmDeviceName=$(cat /data/local/tmp/atlas_config.json | awk -F\" '{print $12}')
elif [ -f /data/local/tmp/atlas_config.json ]; then

else
mitmDeviceName=$(cat /data/local/tmp/config.json | awk -F\" '/device_name/ {print $4}')
mitmDeviceName=$(cat /data/local/tmp/config.json | awk -F\" '/device_name/ {print $4}')
fi

# Get mitm version
Expand Down Expand Up @@ -402,6 +411,8 @@ if result=$(check_mitmpkg); then
mitmDeviceName=$(jq -r '.deviceName' /data/local/tmp/atlas_config.json)
elif [[ $MITMPKG == com.pokemod.aegis* ]] && [ -f /data/local/tmp/aegis_config.json]; then
mitmDeviceName=$(jq -r '.deviceName' /data/local/tmp/aegis_config.json)
elif [[ $MITMPKG == com.sy1vi3.cosmog ]] && [ -f /data/local/tmp/cosmog.json]; then
mitmDeviceName=$(jq -r '.device_id' /data/local/tmp/cosmog.json)
elif [[ $MITMPKG == com.gocheats.launcher]] && [ -f /data/local/tmp/config.json]; then
mitmDeviceName=$(jq -r '.device_name' /data/local/tmp/config.json)
else
Expand Down Expand Up @@ -485,11 +496,19 @@ if result=$(check_mitmpkg); then
done
log -p i -t eMagiskATVService "Scheduling next check in 4 minutes..."
else # As rdm variables aren't configured, we'll check the logs last timestamp
log -p i -t eMagiskATVService "Started log file health check!"
log -p i -t eMagiskATVService "Started health check!"
if [[ $MITMPKG == com.pokemod.atlas* ]]; then
log_path="/data/local/tmp/atlas.log"
elif [[ $MITMPKG == com.pokemod.aegis* ]]; then
log_path="/data/local/tmp/aegis.log"
elif [[ $MITMPKG == com.sy1vi3* ]]; then
if ! ps -a | grep -v grep | grep "$MITMPKG"; then
log -p i -t eMagiskATVService "Process is not alive, starting it"
am start -n $MITMPKG/.MainActivity
else
log -p i -t eMagiskATVService "Process is alive. No action required."
fi
continue
elif [[ $MITMPKG == com.gocheats.launcher ]]; then
log_path=$(ls -lt /data/data/com.nianticlabs.pokemongo/cache/Exegg* | grep -E "^-" | head -n 1 | awk '{print $NF}')
else
Expand Down

0 comments on commit bbf07c4

Please sign in to comment.