[Q] HELP! Transformer Prime Shell Scripts?? - Asus Eee Pad Transformer Prime

I want a little "home launcher" that opens in my terminal that lets me select various things. i did some research and found that android uses MKSH(default shell of MirOS BSD, FreeWRT, MidnightBSD, Android-x86, Android 3.0 (Honeycomb) and possibly Android 4 (Ice Cream Sandwich......)., a derivation of the korn shell. So i used the source of a korn shell menu, and entered my android commands, it didnt work. I know theyre different shell types and therefore have slightly different syntax, is there anyone who can help me make my script work?? Is there any other commands that can make my script echo the Android version? Kernel version?? Anything?! Also is there perhaps a command reference for MKSH for ANDROID. The regular MKSH dox' dont say anything about android
android says:
[email protected]#android:/mnt/sdcard/# sh test.sh
:No such file Or directory
:not foundsh[8]: }
[email protected]#android:/mnt/sdcard/#
Code:
#!/bin/sh
# declare some vars:
btdir="sdcard/bt5"
# functions for menu:
func_1 () {
sh /sdcard/bt5/bt
}
func_2 () {
su ; cd /sdcard
}
func_3 () {
su ; cd /
}
func_4 (){
su ; sd /sdcard/downloads
}
menu_list () {
clear
echo "######################################################################"
echo "#"
echo "#" " " "Welcome to QuikSkript"
echo "#"
echo "#"" ""A simple ""Home"" app,that can launch various things from trem!"
echo "#"
echo "#" " ""BackTrack Is invoked from $btdir"
echo "#" " ""Shell Is running from $SHELL $KSH_VERSION"
echo "#"
echo "#######################################################################"
echo
echo "To Boot BackTrack press 1 \n"
echo "To drop into a superuser shell @ /sdcard press 2 2 \n"
echo "To go to mount point / , press 3"
echo "To go to downloads, press 4"
echo "To quit, press "q" \n"
}
go_ahead () {
tput smso
echo "Press any key to return to the menu \c"
tput rmso
oldstty=`stty -g`
stty -icanon -echo min 1 time 0
dd bs=1 count=1 >/dev/null 2>&1
stty "$oldstty"
echo
}
func_select () {
tput smso
echo "\nPlease make your selection ( )\b\b\c"
read selection
tput rmso
case $selection in
1) clear ; func_1 ; go_ahead ;;
2) clear ; func_2 ; go_ahead ;;
3) clear ; func_3 ; go_ahead ;;
4) clear ; func_4 ; go_ahead ;;
q|Q) tput rmso ; clear ; exit 0 ;;
esac
}
#
# Here is where is gets looped - basically forever, until
# the "q" option is selected, causing an explicit exit
#
while `true`
do
menu_list
func_select
done
thanks for the help

BUUUUUUUUMP!!!!
i redid the script. it still doesnt work, but it properly echos the system information. i still need help
Code:
runbt="sh /sdcard/bt5/bt"
btdir="/sdcard/bt5"
ch2homefolder="cd /sdcard"
ch2systemroot="cd /"
downloads=" cd /sdcard/download"
func_1 () {
cd /sdcard
}
func_2 () {
cd /
}
echo "Started on:" ; date
cat /proc/version
echo "Running from $SHELL $KSH_VERSION"
grep 'Processor' /proc/cpuinfo
grep 'MemTotal' /proc/meminfo
grep 'MemFree' /proc/meminfo
grep 'PageTables' /proc/meminfo ;echo
echo "---> BackTrack invoked from $btdir <---"
echo "Network interfaces:" ; echo ; ifconfig wlan0 ; echo
echo "##########################################################################"
echo "# #"
echo "# Welcome to quikskript! #"
echo "# #"
echo "# A simple sh "home" app, that can launch various things from the term! #"
echo " ######################################################################## "
echo
echo
echo "Choose An option:"
echo
echo "1) Boot BackTrack"
echo
echo "2) Go to Home folder w/ SU"
echo
echo "3) to the System Root, /"
echo
echo "4) Go to Downloads folder"
read option
case $option in
1) $runbt ;;
2) clear ; func_1 ;;
3) clear ; func_2 ;;
4) $downloads ;;
esac
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}

Shameless self bump!! Cmon people someone has to know something!!?!!?!?!?!?!

0xicl33n said:
Shameless self bump!! Cmon people someone has to know something!!?!!?!?!?!?!
Click to expand...
Click to collapse
i will give a bump in favor of more discussion about working with the stock android shell and filesystem. thus far i have found find very little documentation on these subjects.

0xicl33n said:
Cmon people someone has to know something!!?!!?!?!?!?!
Click to expand...
Click to collapse
i know that you are a lot smarter than me.
Bump

bumping my thread in case someone who knows about MKSH is on the front page!

What exactly is the problem? What action is the script expected to preform that it isn't preforming?
I copied the script and tested it. There doesn't seem to be any errors.
P.S. The sh binary isn't in /bin it's in /system/bin
Edit: Sorry forgot to mention that if you want a script to change the current working directory of the shell you need execute it like the following:
Code:
[localhost /sdcard ]# . test.sh
be sure to include the dot before the file name of the script and this only works in directories not on the external storage or on the "internal" sdcard because android mounts these with an option to disable the executable bit.

xtrnet said:
What exactly is the problem?
I copied the script and tested it. There doesn't seem to be any errors.
P.S. The sh binary isn't in /bin it's in /system/bin
Click to expand...
Click to collapse
None of the options work, I haven't tested this in ages nnow. Your supposed to type in a number and have iit do the function. Did not work last times I tried to do it.
Sent from my MB865 using xda app-developers app

Related

[DEV] [W.I.P.] Universal Debug Script

Hi All Dev's,
In all dev forums we generally face various challenges and as such need to ask users a lot of question's if you have done this or not etc.
I am thinking of creating a simple script which when run on the machine can give us all the details as much as required.
for example for my BT5 and ubuntu work i require output of following commands.
mount
which busybox
echo $PATH
busybox
need inputs from other developers what exact details do they require to debug so that we can make a custom debug script which we can ask user to run once and use that as input for all its queries.....
More i will keep on adding in here... need dev's input here.
Note to MOD : this thread is in Dev section coz work is going on i am working on script just crowdsourcing the content as i don't want to leave anything out....
u will need to check for the following most used commands:
Code:
cat /proc/mtd
which
busybox
mount
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
and so on...
u get the idea...
so u get most info related to the device... MTD blocks, busybox location, mount points, location & symlink info (if any) of most used commands
Thanks for the inital tips ... working in this as i needed it for BT thread thought i would crowdsource the idea.
ohk so here is what i am doing right now.
creating a simple script which will generate all the debug output and dump it in /sdcard/debug_log.txt
then we can ask use to upload this debug_log.txt for our debugging.
To All Dev,
please suggest anything else you need to check frequently which we can add in here.
Will be uploading first version in few minutes.
@DooMLorD : might need your help in creating a recovery zip file of it.
anantshri said:
...
@DooMLorD : might need your help in creating a recovery zip file of it.
Click to expand...
Click to collapse
ya sure let me know...
till then something for u to read/check for creating update.zip
http://forum.xda-developers.com/showthread.php?t=1041064
also some examples of update-script:
http://forum.xda-developers.com/showthread.php?p=13522506#post13522506
First Set of code file
@DooMLorD : shamelessly copied your script to check type of Recovery, although added a bit of my logic in.
Code:
# DEBUG Log generation script created by Anant Shrivastava
# known as anantshri in XDA forum
# credit goes to B,J,Z and other developers.
# any specific code taken from other dev's have credit in place.
# incase i missed something send me a PM and i will add it.
debug()
{
#general debug listing.
echo "********** BUSYBOX *****************"
which busybox
busybox
echo "********** MOUNT *******************"
mount
cat /proc/mtd
echo "*************Command Permissions***************"
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.id"
cat /system/build.prop | grep "ro.build.display.id"
cat /system/build.prop | grep "ro.build.version.incremental"
echo "************* KERNEL INFORMATION ****************"
uname -a
echo "************* DEFAULT PATH **********************"
echo $PATH
}
debug_bt()
{
echo "BackTrack Specific Log"
ls -l /sdcard/bt
}
chk_recovery()
{
#
# Script (v1) to check for type of Recovery
# by DooMLoRD
#
# For Xperia X10 users only
#
echo "Recovery disk's available"
if [ -e /system/bin/xrecovery.tar ]
then
echo "xRecovery FOUND!"
fi
if [ -e /system/recovtools/xrecovery.tar.gz ]
then
echo "FreeXperia Recovery FOUND! [TYPE 1]"
fi
if [ -e /system/recovery/recovery.tar.bz2 ]
then
echo "FreeXperia Recovery FOUND! [TYPE 2]"
fi
echo -n "Chargemon Configured Recovery : "
REC=`cat /system/bin/chargemon | grep tar | grep recovery | cut -f4 -d"/"`
if [ $REC == "xrecovery.tar" ]
then
echo "Xrecovery"
elif [ $REC == "xrecovery.tar.gz" ]
then
echo "FreeXperia Recovery"
elif [ $REC == "recovery.tar.bz2"]
then
echo "FreeXperia Recovery type 2"
fi
}
export LOG_FILE=/sdcard/debug_log.txt
echo "Creating DEBUG LOG please wait"
echo "Collection general information"
debug > $LOG_FILE 2>&1
echo "Checking Recovery installed on phone"
chk_recovery >> $LOG_FILE 2>&1
echo "Collecting BT specific information"
debug_bt >> $LOG_FILE 2>&1
I am right now just attaching the sh file we can add an icon on desktop using gscript lite.
Please suggest if anything i missed.
ooohhhh nice modular functions in shell script!!!
great will be using this trick later for some advance work...
btw do shell scripts allow for "include" commands/scripts
EDIT:
yups i was thinking of including grep code to search for exact "Active" recovery in chargmeon...
EDIT2:
Gscript is weird... the output for ur code will display on device screen:
stderr:
stderr:
stderr:
stderr:
....
lots of them too
DooMLoRD said:
ooohhhh nice modular functions in shell script!!!
great will be using this trick later for some advance work...
btw do shell scripts allow for "include" commands/scripts
EDIT:
yups i was thinking of including grep code to search for exact "Active" recovery in chargmeon...
EDIT2:
Gscript is weird... the output for ur code will display on device screen:
stderr:
stderr:
stderr:
stderr:
....
lots of them too
Click to expand...
Click to collapse
1) just pulling off old shell scripting tricks i used to use.
include bash do support need to check if android shell will support or not.
2) So your task half done...
3) Stderr is what i don't understand at all why they occur in gscript
anantshri said:
1) just pulling off old shell scripting tricks i used to use.
include bash do support need to check if android shell will support or not.
2) So your task half done...
3) Stderr is what i don't understand at all why they occur in gscript
Click to expand...
Click to collapse
u might also want to search for:
Code:
which
on FreeX10-beta4 its a part of busybox (symlinked to busybox)
also some additional stuff u might want to check from build.prop
Code:
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.version.sdk"
cat /system/build.prop | grep "ro.build.version.release"
cat /system/build.prop | grep "ro.product.model"
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I think this is a great idea, as a standard user it will give me a chance to provide useful feedback (rather then just saying "that's a good idea!")
So, forgive me for my ignorance of development, but could you also use the routine to perform common tests. i.e, besides the bug reports are there other sub-routines that can be executed (harmlessly) to provide the dev's with additional info on the phones' make-up.
I suggest this assuming there are some common problems that could be identified by accessing additional date not currently found in the de-bug outputs..?
Hi All,
updated the script with some more codes ....
Please suggest if anything else is needed will try to see if i can make a flashable zip for this.
changelog
1)added logcat's for events main and radio. also added option to get stacktrace of dalvik.
EDIT : script updated.....
anantshri said:
Hi All,
updated the script with some more codes ....
Please suggest if anything else is needed will try to see if i can make a flashable zip for this.
changelog
1)added logcat's for events main and radio. also added option to get stacktrace of dalvik.
Click to expand...
Click to collapse
dude u posted output of script and not the updated script itself
@DooMLorD
thanks for pointing ... correct script updated....
Please check and suggest...
anantshri said:
@DooMLorD
thanks for pointing ... correct script updated....
Please check and suggest...
Click to expand...
Click to collapse
looking good so far....
few more sugestions:
dmesg
kmesg
last_kmesg
DooMLoRD said:
looking good so far....
few more sugestions:
dmesg
kmesg
last_kmesg
Click to expand...
Click to collapse
I DooMLoRD,
Checked about all three
dmesg gives runtime output of kerenel messages.
cat /proc/kmesg is a copy of dmesg output... with a twist. once cat /proc/kmesg is done the output goes out of file and it just keeps waiting for more input.
last_kmesg as i know is for the last session.
Script is done ... will just post the details. here.
Need your help in creating a zipable file for creating this script as a simple command on shell.
Version 1.0 debug script
Code:
# DEBUG Log generation script created by Anant Shrivastava
# known as anantshri in XDA forum
# credit goes to B,J,Z and other developers.
# any specific code taken from other dev's have credit in place.
# incase i missed something send me a PM and i will add it.
debug()
{
#general debug listing.
echo "********** BUSYBOX *****************"
which
which busybox
busybox
echo "********** MOUNT *******************"
mount
cat /proc/mtd
echo "*************Command Permissions***************"
ls -l `which mount`
ls -l `which busybox`
ls -l `which sh`
ls -l `which chmod`
ls -l `which chwon`
ls -l `which grep`
ls -l `which sed`
ls -l `which awk`
echo "********** ROM SPECIFIC SETTINGS ***************"
cat /system/build.prop | grep "ro.build.id"
cat /system/build.prop | grep "ro.build.display.id"
cat /system/build.prop | grep "ro.build.version.incremental"
cat /system/build.prop | grep "ro.build.version.sdk"
cat /system/build.prop | grep "ro.build.version.release"
cat /system/build.prop | grep "ro.product.model"
cat /system/build.prop | grep "ro.modversion"
cat /system/build.prop | grep "ro.rommanager.developerid"
cat /system/build.prop | grep "ro.build.description"
cat /system/build.prop | grep "ro.build.fingerprint"
echo "************* KERNEL INFORMATION ****************"
uname -a
echo "************* DEFAULT PATH **********************"
echo $PATH
}
debug_bt()
{
echo "************* BackTrack Specific Log ************"
ls -l /sdcard/bt
ls -l /data/local/bt
ls -l `which bt`
ls -l `which stopbt`
ls -l `which startbt`
echo "************* VNC Config File *******************"
cat /data/local/bt/root/.vnc/xstartup
}
chk_recovery()
{
#
# Script (v1) to check for type of Recovery
# by DooMLoRD
#
# For Xperia X10 users only
#
echo "*********************** RECOVERY DETAILS ***************"
echo "Recovery disk's available"
if [ -e /system/bin/xrecovery.tar ]
then
echo "xRecovery FOUND!"
fi
if [ -e /system/recovtools/xrecovery.tar.gz ]
then
echo "FreeXperia Recovery FOUND! [TYPE 1]"
fi
if [ -e /system/recovery/recovery.tar.bz2 ]
then
echo "FreeXperia Recovery FOUND! [TYPE 2]"
fi
echo -n "Chargemon Configured Recovery : "
REC=`cat /system/bin/chargemon | grep tar | grep recovery | cut -f4 -d"/"`
if [ $REC == "xrecovery.tar" ]
then
echo "Xrecovery"
elif [ $REC == "xrecovery.tar.gz" ]
then
echo "FreeXperia Recovery"
elif [ $REC == "recovery.tar.bz2"]
then
echo "FreeXperia Recovery type 2"
fi
}
logcats()
{
echo "========== LOGCAT : MAIN ==================="
logcat -b main -d
echo "========== LOGCAT : EVENTS ================="
logcat -b events -d
echo "========== LOGCAT : RADIO =================="
logcat -b radio -d
echo "******** DALVIK STACK TRACE *********************"
cat `cat /system/build.prop | grep "dalvik.vm.stack-trace-file" | cut -f2 -d"="`
echo "******** Kernel Messages DMESG ******************"
dmesg
echo "******** LOG LAST KMESG *************************"
cat /proc/last_kmsg
}
export LOG_FILE=/data/local/debug_log.txt
echo "Creating DEBUG LOG please wait"
echo "Collection general information"
debug > $LOG_FILE 2>&1
echo "Checking Recovery installed on phone"
chk_recovery >> $LOG_FILE 2>&1
echo "Collecting BT specific information"
debug_bt >> $LOG_FILE 2>&1
echo "Collecting logcat's : main, events, radio + stack trace"
logcats >> $LOG_FILE 2>&1

Script for killing root apps that don't start properly.

WARNING! THIS SCRIPT REQUIRES YOU TO CREATE AND EDIT IT!!!!
Okay, for everyone who is having issues with root enabled apps not starting correctly, I have created a script that allows me to run it via Script Manager or the command line to kill MY root enabled apps. Please do not ask for a flashable zip or a downloadable file. You will need to CREATE the script for yourself. I am just going to outline the basic parameters that I use.
Now, you will need a GOOD text editor. I recommend one of the following: Jota Text Editor, 920 Text Editor, (or, if you are a Linux-centric kind of person) Vim Touch.
Now, open the text editor and create a file on your phone with the following lines (copy and paste is fine):
Code:
#!/system/xbin/sh
clear
echo "Kill Menu"
# Function to list selections
showMenu () {
clear
echo "1) Ad Free"
echo "2) Button Savior"
echo "3) Droid Wall"
echo "4) File Expert"
echo "5) Lightflow"
echo "6) Plume"
echo "7) Quick Boot"
echo "8) Tasker"
echo "9) Titanium Backup"
echo "Q) Quit (Either q or Q will work)"
echo ""
echo "Select which app to kill and press [ENTER]"
echo ""
}
while [ 1 ]
do
showMenu
read CHOICE
case "$CHOICE" in
"1")
clear
pkill com.bigtincan.android.adfree
pkill com.bigtincan.android.adfree
pkill com.bigtincan.android.adfree
echo "Ad Free has been killed. Please restart the process."
read -p "Press [Enter] to continue." nothing
;;
"2")
clear
pkill com.smart.swkey
pkill com.smart.swkey
pkill com.smart.swkey
echo "Button Savior has been killed. Please restart the process."
read -p "Press [Enter] to continue." nothing
;;
"3")
clear
pkill com.googlecode.droidwall.free
pkill com.googlecode.droidwall.free
pkill com.googlecode.droidwall.free
echo "Droid Wall has been killed. Please restart the process."
read -p "Press [Enter] to continue." nothing
;;
"4")
clear
pkill xcxin.filexpert
pkill xcxin.filexpert
pkill xcxin.filexpert
echo "File Expert has been killed. Please restart the process."
read -p "Press [Enter] to continue." nothing
;;
"5")
clear
pkill com.rageconsulting.android.lightflow
pkill com.rageconsulting.android.lightflow
pkill com.rageconsulting.android.lightflow
echo "Lightflow has been killed. Please restart the process."
read -p "Press [ENTER] to continue." nothing
;;
"6")
clear
pkill com.levelup.touiteur
pkill com.levelup.touiteur
pkill com.levelup.touiteur
echo "Plume has been killed. Please restart the process."
read -p "Press [ENTER] to contiue." nothing
;;
"7")
clear
pkill com.siriusapplications.quickboot
pkill com.siriusapplications.quickboot
pkill com.siriusapplications.quickboot
echo "Quick Boot has been killed. Please restart the process."
read -p "Press [ENTER] to contiue." nothing
;;
"8")
clear
pkill net.dinglisch.android.taskerm
pkill net.dinglisch.android.taskerm
pkill net.dinglisch.android.taskerm
echo "Tasker has been killed. Please restart the process."
read -p "Press [Enter] to continue." nothing
;;
"9")
clear
pkill com.keramidas.TitaniumBackup
pkill com.keramidas.TitaniumBackup
pkill com.keramidas.TitaniumBackup
echo "Titanium Backup has been killed. Please restart the process."
read -p "Press [Enter] to continue." nothing
;;
"q")
exit
;;
"Q")
exit
;;
esac
done
Save it in a directory on your sdcard (I use /sdcard/Scripts) and call it something memorable. I use "Kill_Menu.sh" (without the quotation marks).
The lines you MUST change are in the showmenu function to reflect YOUR root enabled apps. Remember, this is MY list.
You MUST also change the lines in the while/do loop. Each selection corresponds to a menu item. In order to get the full name of the task you want to kill, from a command line type the following:
Code:
pgrep -l PartOfProcessName
The PartOfProcessName is something like "tasker" or "Titan" (again, without the quotation marks).
tasker will bring up something like:
Code:
2443 net.dinglisch.android.taskerm
The numbers is the process ID and WILL BE DIFFERENT. The part that you are concerned with is "net.dinglisch.android.taskerm". Put this in the script in the correct section after the "pkill" command. This way you are killing ONLY that task, and not others. The process (app) is CASE SENSITIVE!!!!
I have the script kill the process three times to make sure it doesn't respawn itself before I have a chance to restart the app.
Please keep in mind that this is a bash shell script and must be run from Script Manager with root access (su) or from the command line with "/system/xbin/sh /sdcard/Scripts/Kill_Menu.sh" (or whatever folder you put it in).
The topic is now open for discussion.
Ciao!
Nice, forgive me if I overlooked, but do I start in Scriptmanager like other .sh / scripts.
This ISN'T my Transformer Prime
Pixelation said:
Nice, forgive me if I overlooked, but do I start in Scriptmanager like other .sh / scripts.
This ISN'T my Transformer Prime
Click to expand...
Click to collapse
You can. Either there or Terminal Emulator.
Sent from my DROID X2 using Tapatalk 2

Samsung Galaxy S10 - Press Bixby for MAX Brightness + Max GPU + CPU **ROOT ONLY**

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Is your S10 rooted? Do you want to make the most out of your CPU+GPU+BRIGHTNESS for the best gaming experience?
I made this little trick myself, I'm a newbie to linux but i finally managed to work. It was for my personal use, but i thought id share it, as im sure someone will find it useful!
## I AM NOT RESPONSIBLE FOR ANY DAMAGES DONE TO YOUR DEVICE ###
What is it?
- Well, the aim of this is convenience, and the best GPU+CPU+ScreenBrightness optimal for gaming.
This little trick allows you to simply press the Bixby Button; you'l see a popup, and your Screen will max out, your CPU will max out, and your GPU will max out. And to restore brightness, GPU and CPU states, you simply hold bixby.
What devices support it?
Well, this works on the S10 Exynos (G973F) XXBTA8 and works just fine. I recommend only using it on STOCK ROM.
It could work for other variants, but if it doesn't you may have to tweak the shell code.
Is it dangerous? ## I AM NOT RESPONSIBLE FOR ANY DAMAGES DONE TO YOUR DEVICE ###
Yes. Because the code forces your screen to a MAX state, and heats your phone up. It also removes GPU throttling, which is essential for max GPU performance in gaming. The CPU, however, is maxed out, but can throttle when needed, as its not essential to keep all cores up for gaming.
Id strongly advise removing the code holding bixby (or whatever button you assigned it to) after use (SPECIALLY WHEN SCREEN IS OFF, as it causes freezes. Probably due to GPU being maxed out)
Is it easy to install?
Yes. Surprisingly so.
# KIND REMINDER #
THIS WAS FOR MY OWN USE, BEAR THAT IN MIND WHEN COMMENTING ABOUT IT. I just shared it if someone found work interesting and helpful
# # INSTALLATION # #
So assuming your on Stock Rom, on the Samsung Galaxy S10 (I tested it on BTA8 software and worked)
1. Install Button Mapper from the developer "flar2" from the playstore.
2. Open, setup, and click BIXBY, then customize
2.1 Click on Advanced, and find the ROOT COMMAND
3. Enter the following code on SINGLE TAP
Code:
print "Game Mode ON" && mount -o remount,rw / && chmod 0000 /sys/devices/platform/18500000.mali/dvfs && chmod 0000 /sys/devices/platform/18500000.mali/dvfs_max_lock & chmod 0000 /sys/devices/platform/18500000.mali/dvfs_min_lock && echo '702000' > /sys/kernel/gpu/gpu_max_clock && echo '702000' > /sys/kernel/gpu/gpu_min_clock && echo 'performance' > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor && echo 'performance' > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor && echo 'performance' > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor && echo '1950000' > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq && echo '2314000' > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq && echo '2730000' > /sys/devices/system/cpu/cpufreq/policy6/scaling_min_freq && echo '48599' > /sys/class/backlight/panel/brightness
4. Press OK
5. Press on Bixby LONG PRESS and enter the following code
Code:
print "RESET GPU/CPU" && mount -o remount,rw / && chmod 0644 /sys/devices/platform/18500000.mali/dvfs && chmod 0664 /sys/devices/platform/18500000.mali/dvfs_max_lock & chmod 0664 /sys/devices/platform/18500000.mali/dvfs_min_lock && echo '702000' > /sys/kernel/gpu/gpu_max_clock && echo '702000' > /sys/kernel/gpu/gpu_min_clock && echo 'schedutil' > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor && echo 'schedutil' > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor && echo 'schedutil' > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor && echo '442000' > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq && echo '507000' > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq && echo '520000' > /sys/devices/system/cpu/cpufreq/policy6/scaling_min_freq && echo '20000' > /sys/class/backlight/panel/brightness
6. Press OK and your all set !
7. Then tap BIXBY and you'l see your screen max out along with the phones perfomance boosted. You wont notice the perfomance boost much, but i can assure you, that on games you'l notice a great deal of diference.
Points to note:
1. If you see an error display after entering the code, or a random bit of code, its probably targetting the wrong files on your device or you made a mistake when copying.
2. If your testing it with a CPU tweaker app, once activated, close and open the app, as some apps dont display the changes straight away.
3. Remember that it might not work on other variants, and that stock rom is recommended.
4. You may not see a confirmation popup when you remove the boost, but if the screen dimms slighly and you see nothing else, then its worked fine most definitely.
5. And lastly, enjoy and i hope its of help for someone. I'm sure the code can be made shorter but I'm a newbie with linux haha
Thanks !
David8960 said:
Is your S10 rooted? Do you want to make the most out of your CPU+GPU+BRIGHTNESS for the best gaming experience?
I made this little trick myself, I'm a newbie to linux but i finally managed to work. It was for my personal use, but i thought id share it, as im sure someone will find it useful!
## I AM NOT RESPONSIBLE FOR ANY DAMAGES DONE TO YOUR DEVICE ###
What is it?
- Well, the aim of this is convenience, and the best GPU+CPU+ScreenBrightness optimal for gaming.
This little trick allows you to simply press the Bixby Button; you'l see a popup, and your Screen will max out, your CPU will max out, and your GPU will max out. And to restore brightness, GPU and CPU states, you simply hold bixby.
What devices support it?
Well, this works on the S10 Exynos (G973F) XXBTA8 and works just fine. I recommend only using it on STOCK ROM.
It could work for other variants, but if it doesn't you may have to tweak the shell code.
Is it dangerous? ## I AM NOT RESPONSIBLE FOR ANY DAMAGES DONE TO YOUR DEVICE ###
Yes. Because the code forces your screen to a MAX state, and heats your phone up. It also removes GPU throttling, which is essential for max GPU performance in gaming. The CPU, however, is maxed out, but can throttle when needed, as its not essential to keep all cores up for gaming.
Id strongly advise removing the code holding bixby (or whatever button you assigned it to) after use (SPECIALLY WHEN SCREEN IS OFF, as it causes freezes. Probably due to GPU being maxed out)
Is it easy to install?
Yes. Surprisingly so.
# KIND REMINDER #
THIS WAS FOR MY OWN USE, BEAR THAT IN MIND WHEN COMMENTING ABOUT IT. I just shared it if someone found work interesting and helpful
# # INSTALLATION # #
So assuming your on Stock Rom, on the Samsung Galaxy S10 (I tested it on BTA8 software and worked)
1. Install Button Mapper from the developer "flar2" from the playstore.
2. Open, setup, and click BIXBY, then customize
2.1 Click on Advanced, and find the ROOT COMMAND
3. Enter the following code on SINGLE TAP
Code:
print "Game Mode ON" && mount -o remount,rw / && chmod 0000 /sys/devices/platform/18500000.mali/dvfs && chmod 0000 /sys/devices/platform/18500000.mali/dvfs_max_lock & chmod 0000 /sys/devices/platform/18500000.mali/dvfs_min_lock && echo '702000' > /sys/kernel/gpu/gpu_max_clock && echo '702000' > /sys/kernel/gpu/gpu_min_clock && echo 'performance' > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor && echo 'performance' > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor && echo 'performance' > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor && echo '1950000' > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq && echo '2314000' > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq && echo '2730000' > /sys/devices/system/cpu/cpufreq/policy6/scaling_min_freq && echo '48599' > /sys/class/backlight/panel/brightness
4. Press OK
5. Press on Bixby LONG PRESS and enter the following code
Code:
print "RESET GPU/CPU" && mount -o remount,rw / && chmod 0644 /sys/devices/platform/18500000.mali/dvfs && chmod 0664 /sys/devices/platform/18500000.mali/dvfs_max_lock & chmod 0664 /sys/devices/platform/18500000.mali/dvfs_min_lock && echo '702000' > /sys/kernel/gpu/gpu_max_clock && echo '702000' > /sys/kernel/gpu/gpu_min_clock && echo 'schedutil' > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor && echo 'schedutil' > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor && echo 'schedutil' > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor && echo '442000' > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq && echo '507000' > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq && echo '520000' > /sys/devices/system/cpu/cpufreq/policy6/scaling_min_freq && echo '20000' > /sys/class/backlight/panel/brightness
6. Press OK and your all set !
7. Then tap BIXBY and you'l see your screen max out along with the phones perfomance boosted. You wont notice the perfomance boost much, but i can assure you, that on games you'l notice a great deal of diference.
Points to note:
1. If you see an error display after entering the code, or a random bit of code, its probably targetting the wrong files on your device or you made a mistake when copying.
2. If your testing it with a CPU tweaker app, once activated, close and open the app, as some apps dont display the changes straight away.
3. Remember that it might not work on other variants, and that stock rom is recommended.
4. You may not see a confirmation popup when you remove the boost, but if the screen dimms slighly and you see nothing else, then its worked fine most definitely.
5. And lastly, enjoy and i hope its of help for someone. I'm sure the code can be made shorter but I'm a newbie with linux haha
Thanks !
Click to expand...
Click to collapse
Damn, i just realised this is best suited for the mod forum , if a moderator could move this forum over that would be great.

A script to get a random file

Dear developers,
I have an issue in my script switching from Android 9 to 10 (devices from a Umidigi s3 Pro to a Umidigi F2)
I have installed Bosybox App on the first and Busybox Magisk module on the latter
Now the script does not work because the command
list=(`busybox find "$dirs" -type f -name *.$ext`)
returns an empty array
This is the complete script:
Bash:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <[email protected]> v1.4 01.01.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
# here we have the ISSUE
list=(`busybox find "$dirs" -type f -name *.$ext`)
# count number of files
num=${#list[@]}
# initialize random generator
RANDOM=$$
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[ran]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext$delim2
Can you please help me why this happens, and how to fix it?
Thank you very much for your attention!
Uranya said:
[...]
Click to expand...
Click to collapse
Having done some tests I have found this:
opening a root privileged terminal and executing
---
echo `find /storage/7BC3-1805/Music/MP3/Abba -type f -name *.mp3`
---
it returns two strings containing the names of files inside that folder, but putting it in my script continues to return an empty array, so the issue is not in the access to the folder, but in the syntax, I guess
try putting that *.$ext into quotes...
Dear friends, CXZa, after a couple of hours debugging the script, finally, I have found the mistake!
The line to be used is:
list=( `find "$dirs" -type f -name "*.$ext"` )
it is a very subtle difference: the space after and before the parenthesis!
(even the word busybox is useless)
Oddly in the Busybox app (I have had on my S3 Pro) the spaces are not mandatory, whilst in the Busybox Magisk module those spaces ARE mandatory!
I'm using that script for almost 8 years to have an every day different music for my wake up.
I'm using Tasker to call it just before my alarm get off, so the same file contains every day, a different song.
I have done a change also in the array index that did not began by 0...
So, here it is the right script:
Bash:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <@uranya7x> v1.5 26.03.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
list=( `find "$dirs" -type f -name "*.$ext"` )
# count number of files
num=${#list[@]}
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[$ran-1]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext
I hope it will be useful to someone else that loves to be waked up by music...
Peace everywhere!

How To Guide Add updated TOYBOX w/ ROOT to Windows Subsystem for Android™️

Preface​
Unfortunately Windows Subsystem for Android (WSA) is missing fully fledged Toybox ( This is a package of over 200 command-line tools, handy for advanced users - it's located in /usr/{bin,sbin} ) - though according to Microsoft WSA is meant to be used by app developers, as development platform, IIRC.
Toybox v0.8.4 ( released 2020-10-24 ) commands currently provided:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
So IMO it's time to install latest fully-fledged version ( at time of this writing it's 0.8.8 released 2022-08-12 ) of Toybox on WSA:
As you can see currently the fully-fledged Toybox command suite contains the SU command ( Toybox as provided with WSA is missing it ) what allows you to root Android, will say give you elevated rights so you get complete access to everything in the operating system, and those permissions allow you to change it all.​
Remarks​USB-Debugging is by default enabled in WSA to implicitly give up your encryption secrets to the connected computer: WSA performs per-file encryption that is software-based.
This suggested updating doesn't replace / remove the pre-installed Toybox version.
Installation into Android's data partition ( recommended )​The roadmap
Connect PC to WSA
Save SELinux context of preinstalled Toybox
Download attached Toybox binary and extract it to any location on PC, e.g. C:\
Download attached SU binary and extract it to any location on PC, e.g. C:\
Next thing to do is to transfer the attached SU binary - assumed it got stored in C:\ - to /sdcard/Download because during the updating process we sometimes need elevated rights
and give executable rights to it
and set its file-ownership-UID 2000 is the default user on WSA
Create a directory named toybox under /data/local/tmp
Transfer the downloaded toybox binary to /sdcard/Download
Disable SElinux what by default in WSA is enabled
Copy the transferred toybox binary to /data/local/tmp what sets its owner to shell:shell
and give executable permission to it. (The default permissions set for other binaries is rwxr-xr-x)
Create symlinks for the all the various tools accessible by toybox binary
Set SELinux context on all files created
Re-enable SELinux because by default in WSA it's enabled
Do some housekeeping ...
and restart WSA
The script - it's a hybrid DOS / Linux coded one
@Echo off & setlocal ENABLEDELAYEDEXPANSION
popd "%CD%"
::
title WSA Toybox Updater
color f0 & mode con: cols=54 lines=40
echo(
echo ####################################
echo # #
echo # WSA Toybox Updater #
echo # #
echo # Updates existing Toybox to #
echo # version 0.8.8 what comes with #
echo # SU-function embeddedd #
echo # #
echo # (c) 2022 [email protected] #
echo # License: BSD 2-Clause #
echo # #
echo ####################################
echo(
echo Press 1 to Continue, 0 to Abort
choice /C 10 /M "Please select"
if !errorlevel! NEQ 1 ( goto :done )
cls
::
set "adb="
set "subin="
set "tbbin="
set "adb_org=adb_r33.0.3.exe"
set "tbbin_org=toybox-x86_64"
set "subin_org=su-x86_64"
set "wsa_svc=WsaService.exe"
set "address=127.0.0.1"
::
:: Sanity checks
echo(
echo Verifying availability of required files ..
for /F "tokens=*" %%t in ('fsutil fsinfo drives') do ( set "drives=%%t" )
:: 1st check folder we are running this bat from, 2nd search all drives
set "drive=%CD:~0,2%"
for /F "tokens=*" %%t in ('where /R !drive! !adb_org! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !adb_org! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb_org )
)
echo FATAL: !adb_org! not found on PC & goto :failed
:done_query_adb_org
for /F "tokens=*" %%t in ('where /R !drive! !subin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !subin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
)
echo FATAL: !subin_org! not found on PC & goto :failed
:done_query_subin_org
for /F "tokens=*" %%t in ('where /R !drive! !tbbin_org! 2^>nul') do ( set "tbbin=%%t" )
if defined tbbin ( goto :done_query_tbbin_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !tbbin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
)
echo FATAL: !tbbin_org! not found on PC & goto :failed
:done_query_tbbin_org
echo OK
echo(
echo Checking if WSA emulator is running ...
for /F "tokens=1 delims= " %%t in ('tasklist /FI "IMAGENAME eq !wsa_svc!" 2^>nul ^| findstr /I /C:"!wsa_svc!"') do (
set "proc=%%t"
if NOT "!proc!"==[] ( goto :done_wsa_check )
)
echo FATAL: WSA is not running & goto :failed
:done_wsa_check
echo OK
tasklist /FI "IMAGENAME eq adb*" | findstr /I /C:"adb" >nul && goto :adb_running || goto :adb_not_running
:adb_running
!adb! disconnect >nul 2>&1
:: Force a fresh start of ADB
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:adb_not_running
echo(
echo Connecting Windows to WSA emulator ...
:: Ports are odd-numbered in the range 5555 to 5585,
:: the default port is 5555
for /L %%a in (5555,2,5585) do (
set "tcpport=%%a"
!adb! connect !address!:!tcpport! >nul 2>&1
:: Verify WSA emulator is connected
for /F "tokens=*" %%t in ('!adb! get-state 2^>nul') do (
set "state=%%t"
echo !state! | findstr /C:"device" >nul
if !errorlevel! EQU 0 ( goto :done_wsa_connection )
)
)
echo FATAL: WSA emulator got not connected & goto :failed
:done_wsa_connection
echo OK
::
::
::
set "subin_fn=su"
set "tbbin_fn=toybox"
set "dldir=/sdcard/Download"
set "sucmd=!dldir!/!subin_fn!"
set "tmpdir=/data/local/tmp"
set "tbdir=!tmpdir!/!tbbin_fn!"
::
::
set "sucmd=!dldir!/!subin_fn!"
set "tbbin=!dldir!/!tbbin_fn!"
:: Check if job already was done
echo(
echo Validating Toybox update already done ...
set /A fc=0
!adb! pull !sucmd! %TEMP%\!subin_fn! >nul 2>&1
if !errorlevel! EQU 0 ( set /A fc+=1 )
!adb! pull !tbbin! %TEMP%\!tbbin_fn! >nul 2>&1
if !errorlevel! EQU 0 ( set /A fc+=1 )
if exist "%TEMP%\!subin_fn!" ( del /F /Q "%TEMP%\!subin_fn!" )
if exist "%TEMP%\!tbbin_fn!" ( del /F /Q "%TEMP%\!tbbin_fn!" )
if !fc! EQU 2 ( echo OK & goto :done_files_transferred )
echo OK
echo(
echo Transferring files ...
:: Transfer SU binary to /sdcard/Download
:: because during the updating process we sometimes need elevated rights
!adb! push !subin_org! !dldir!/
if !errorlevel! NEQ 0 (
echo Failed: Transferring SU failed
goto :failed
)
:: Transfer the downloaded toybox binary to /sdcard/Download
!adb! push !tbbin_org! !dldir!/ >nul 2>&1
if !errorlevel! NEQ 0 (
echo Failed: Transferring Toybox failed
goto :failed
)
:done_files_transferred
echo OK
::
echo(
echo Updating Toybox ...
::
:: start Android shell on the WSA emulator
::
!adb! shell
set -e
#
#
DL_DIR=/sdcard/Download;
TB_DIR=/data/local/tmp/toybox;
TB_BIN=/data/local/tmp/toybox/toybox;
SU_BIN="$DL_DIR"/su;
SU_BIN_ORG=su-x86_64;
TB_BIN_ORG=toybox-x86_64;
cat < SCRIPT > "$DL_DIR"/cat.sh & chmod +x "$DL_DIR"/cat.sh & source < "$DL_DIR"/cat.sh; \
'# Save SELinux context of pre-installed Toybox' \
TOYBOX="$(which 'toybox')"; \
EXPR=$(ls -lZ "$TOYBOX"); \
TB_SECURITY_CONTEXT=$(cut -d " " -f 4 "$EXPR"); \
'# give SU binary executable rights' \
'# Get UID GID from pre-installed toybox' \
EXPR="$(ls -ld "$TOYBOX")"; \
TB_UID=$(cut -d " " -f 3 "$EXPR"); \
TB_GID=$(cut -d " " -f 4 "$EXPR"); \
'# Set these UID GID on SU too' \
chown -f "$TB_UID":"$TB_GID" "$SU_BIN"; \
'# Create a directory named toybox under /data/local/tmp' \
if [ ! -d "$TB_DIR" ]; then ( \
$SU_BIN -c 'mkdir -p "$TB_DIR" 2>/dev/null; touch "$TB_DIR" 2>/dev/null'; \
fi; \
'# rename SU and Toybox binaries provided if not already exist' \
if [[ (! -f "$SU_BIN" || ! -f "$TB_BIN") ]]; then { \
mv -T "$DL_DIR/$SU_BIN_ORG" "$SU_BIN" 2>/dev/null; \
mv -T "$DL_DIR/$TB_BIN_ORG" "$TB_BIN" 2>/dev/null; \
} \
fi; \
'# Temporarily disable SElinux what by default in WSA is enabled' \
$SU_BIN 0 setenforce 0; \
'# Copy the transferred toybox binary to /data/local/tmp/toybox what sets its owner to shell:shell' \
cp -Tp "$TB_BIN_ORG" "$TB_DIR/$TB_BIN" >/dev/null; \
'# and give executable permission to it' \
chmod -f +x "$TB_DIR"; \
'# Create symlinks for the various Linux applets provided by toybox binary' \
for i in $($TB_DIR/$TB_BIN --long); do ln -s $TB_DIR/$TB_BIN $i; done: \
'# Set SELinux context on all files created'
$SU_BIN -c 'chcon -R "$TB_SECURITY_CONTEXT toybox" "$TB_DIR"; \
'# Re-enable SELinux because by default in WSA it's enabled' \
$SU_BIN 0 setenforce 1; \
'# Do some housekeeping ...' \
rm -f "$SU_BIN","$TB_BIN" 2>/dev/null; \
SCRIPT
#
## exit the Android shell
exit
::
::
echo OK
:: and restart
echo(
echo Restarting WSA ...
!adb! reboot
echo OK
:failed
timeout /t 10 /nobreak >nul
::
:done
echo(
echo Job done. Exiting ...
pause
pushd
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
endlocal & DISABLEDELAYEDEXPANSION
exit
Screenshot
Done​Enjoy your Toybox and its applets are ready to be executed.
Validation​
( using ADB code stored in a Windows .BAT-file )
Code:
@echo off & setlocal ENABLEDELAYEDEXPANSION
pushd "%CD%"
::
::
set "adb_exe=adb_r33.0.3.exe" & set "adb="
set "ip4_address=" & set "port=58526"
set "wsa_svc=WsaService.exe"
::
::
title WSA-TOYBOX-UPDATE-VALIDATOR
color f0 & mode con: cols=50 lines=40
echo(
echo ####################################
echo # #
echo # WSA Toybox Update Validator #
echo # #
echo # Verifies Toybox got updated to #
echo # version 0.8.8 what comes with #
echo # SU-function embeddedd #
echo # #
echo # (c) 2022 [email protected] #
echo # License: BSD 2-Clause #
echo # #
echo ####################################
echo(
echo Verifying presence of ADB executable ...
:: check folder we are running this bat from
set "drive=%CD:~0,2%"
for /F "tokens=*" %%t in ('where /R !drive! !adb_exe! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb )
echo FATAL: !adb_exe! not found on PC & goto :failed
:done_query_adb
echo OK & echo(
echo Checking if WSA emulator is already up ...
for /F "tokens=1 delims= " %%t in ('tasklist /FI "IMAGENAME eq !wsa_svc!" 2^>nul ^| findstr /I /C:"!wsa_svc!"') do (
set "proc=%%t"
if NOT "!proc!"==[] ( goto :done_wsa_check )
)
echo FATAL: WSA is not running & goto :failed
:done_wsa_check
echo OK & echo(
:: Force a fresh start of ADBis
tasklist /FI "IMAGENAME eq adb*" | findstr /I /C:"adb" >nul 2>nul && goto :adb_is_running || goto :adb_isnot_running
:adb_is_running
:: disconnect all
!adb! disconnect >nul 2>&1
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:adb_isnot_running
::
:: get our IP4 address
echo Obtaining local IP4 address ...
rem for /F “tokens=1,2 delims=:" %%a in ('ipconfig ^| findstr /I /C:"ipv4" ^>nul') do (
rem if !errorlevel! EQU 0 ( set "ip4_address=%%b" )
rem )
if defined ip4_address ( goto :done_query_ip4_address )
:: workaround
set "ip4_address=127.0.0.1"
:done_query_ip4_address
echo OK ^[ !ip4_address!^] & echo(
echo Connecting to emulator ...
:: start using default port
!adb! connect !ip4_address!:!port! >nul
for /F "tokens=*" %%t in ('!adb! get-state ^>nul 2^>^&1 ^| findstr /C:"device" ^>nul 2^>nul') do (
set "retval=%%t"
if "!retval!"==[] ( echo Internal error occured & timeout /t 5 /nobreak >nul & goto :oops )
)
echo OK & echo(
echo Checking for SU applet is reachable ...
!adb! shell "PATH=/data/local/tmp/toybox:$PATH; su 2>/dev/null; STATUS=$?;[ $STATUS -eq 0 ] && echo "OK" || echo "Failed"; sleep 10s;"
:oops
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:failed
echo(
pause
popd
endlocal DISABLEDELAYEDEXPANSION
exit
Screenshot:
Download​
This package got attached for your convenience
Last Note​Toybox applets are for Terminal and shell scripts - you may use ScriptRunner2 for the latter.
BTW:
Before running a script edit your default shell's configuration file via adding in an DOS coded script saved to a .BAT-file
Code:
adb shell "PATH=/data/local/tmp/toybox:$PATH"
at script's begin what would cause the shell to look into /data/local/tmp/toybox first and execute the binary, if available.
Toybox command help​is here:
Toybox 0.8.9 command help
[reserved]
Can you provide an installer script? It would make it easer for all. Thanks in advance.
Sure. But needs some time. Stay tuned.
jwoegerbauer said:
if !su_found! EQU 1 ( echo SU binary found )
else ( echo SU binary not found )
Click to expand...
Click to collapse
"Else" needs to be on the same line as the "if" in order to be read by interpreter.
Or the ")" + "else" needs to drop to the line below it.
Should be:
if !su_found! EQU 1 ( echo SU binary found ) else ( echo SU binary not found )
OR
if !su_found! EQU 1 ( echo SU binary found
) else ( echo SU binary not found )
EDIT: Also, "@ECHO on" turns on verbose command output, does no good to place at the very end (no harm either)
Thanks for that error notice: implicitely corrected it by a complete revamp of the script.
can you provide a shell script command please

Categories

Resources