Found a (rogue?) script on my J6+ today... could someone tell me if it's nasty? - Android Q&A, Help & Troubleshooting

run.bat [filename]
SET SLEEP=ping 127.0.0.1 -n
echo %1
echo %2
%SLEEP% 5 > nul
%2 -remove
move /Y %1 %2
%2 -install
exit

Related

[Q] Photon Root Problems

I've tried just about every root method I've seen for this phone... with one click root I get this error
deleting all yo ****
error: protocol fault (no status)
error: device not found
error: device not found
error: device not found
error: device not found
error: device not found
Copying files onto phone...
error: device not found
error: device not found
error: device not found
error: device not found
Setting permissions...
error: device not found
error: device not found
error: device not found
error: device not found
error: device not found
Installing busybox...
error: device not found
Cleaning up files...
error: device not found
error: device not found
"You should have root!"
Press any key to continue . . .
I've downloaded the drivers provided in the forums but still no luck... Has anyone else had/fixed this issue??
I had problems like this before so I modified the root batch program.
Right click on the root.bat and choose edit. Ctrl + A to select all and then backspace to delete all the text. Copy this into there and save. All I did was put multiple pauses where the phone needed to reboot so hit space bar whenever your phone successfully is at your home screen. I like to give it a little bit of time to load and what not. Let me know your outcome.
Code:
@echo off
echo based off bliss' moto exploit for the droid 3 published here http://vulnfactory.org/blog/2011/08/25/rooting-the-droid-3/
cls
color 0A
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo The Android Creative Syndicate
echo.
echo Presents to you
ping -n 2 127.0.0.1 > nul
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
color 0C
echo One Click Root
echo for the Moto Photon 4G
ping -n 2 127.0.0.1 > nul
color 0A
echo.
echo.
echo Special shoutout to
echo.
echo. Bliss
echo.
echo.
echo.
pause
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo You need to enable usb debugging first
echo Go to settings - applications - development
color 0A
ping -n 2 127.0.0.1 > nul
color 0C
ping -n 2 127.0.0.1 > nul
color 0C
echo.
echo.
pause
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
cls
adb.exe kill-server
adb.exe start-server
COLOR E0
echo Getting temp root
pause
adb shell rm /data/local/12m.bak > NUL
adb shell mv /data/local/12m /data/local/12m.bak > NUL
adb shell ln -s /data /data/local/12m > NUL
echo Will Reboot phone
pause
adb reboot
echo.
echo RE-boot-en
COLOR 47
adb kill-server > NUL
adb wait-for-device > NUL
adb wait-for-device > NUL
echo.
echo Hackin Things
COLOR A0
pause
adb shell rm /data/local/12m > NUL
adb shell mv /data/local/12m.bak /data/local/12m > NUL
adb shell rm /data/local.prop.bak > NUL
adb shell mv /data/local.prop /data/local.prop.bak > NUL
adb shell echo "ro.sys.atvc_allow_netmon_usb=0" ^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_netmon_ih=0" ^>^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_res_core=0" ^>^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_res_panic=0" ^>^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_all_adb=1" ^>^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_all_core=0" ^>^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_efem=0" ^>^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_bp_log=0" ^>^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_ap_mot_log=0" ^>^> /data/local.prop
adb shell echo "ro.sys.atvc_allow_gki_log=0" ^>^> /data/local.prop
adb reboot
echo.
echo deleting all yo ****
COLOR E0
pause
adb.exe wait-for-device > NUL
adb.exe wait-for-device > NUL
adb.exe remount
COLOR B0
adb.exe push rootsetup /data/local/tmp/rootsetup
adb.exe shell chmod 755 /data/local/tmp/rootsetup
adb.exe shell /data/local/tmp/rootsetup
adb.exe shell rm /data/local/tmp/rootsetup
adb.exe shell sync
echo Copying files onto phone...
adb.exe push su /system/xbin/su
adb.exe push Superuser.apk /system/app/Superuser.apk
adb.exe push busybox /system/xbin/busybox
adb.exe push remount /system/xbin/remount
echo Setting permissions...
adb.exe shell chmod 755 /system/xbin/busybox
adb.exe shell chmod 755 /system/xbin/remount
adb.exe shell chown root.shell /system/xbin/su
adb.exe shell chmod 6755 /system/xbin/su
adb.exe shell ln -s /system/xbin/su /system/bin/su
echo Installing busybox...
adb.exe shell /system/xbin/busybox --install -s /system/xbin
echo Cleaning up files...
@ping 127.0.0.1 -n 6 -w 1000 > nul
adb.exe shell rm /data/local/tmp/*
adb.exe reboot
echo "You should have root!"
COLOR D0
ping -n 1 127.0.0.1 > nul
COLOR 90
ping -n 1 127.0.0.1 > nul
COLOR B0
ping -n 1 127.0.0.1 > nul
COLOR A0
ping -n 1 127.0.0.1 > nul
COLOR E0
ping -n 1 127.0.0.1 > nul
COLOR C0
ping -n 1 127.0.0.1 > nul
COLOR D0
ping -n 1 127.0.0.1 > nul
COLOR 90
ping -n 1 127.0.0.1 > nul
COLOR B0
ping -n 1 127.0.0.1 > nul
COLOR A0
ping -n 1 127.0.0.1 > nul
COLOR E0
ping -n 1 127.0.0.1 > nul
COLOR C0
ping -n 1 127.0.0.1 > nul
COLOR D0
ping -n 1 127.0.0.1 > nul
COLOR 90
ping -n 1 127.0.0.1 > nul
COLOR B0
ping -n 1 127.0.0.1 > nul
COLOR A0
ping -n 1 127.0.0.1 > nul
COLOR E0
ping -n 1 127.0.0.1 > nul
COLOR C0
echo.
pause
adb.exe kill-server
goto:eof
Ok I'm going to try this today
Sent from my MB855 using xda premium

[Ubuntu][How to][4/11/12 Creating a Kernel Build Script

This thread is meant for kernel devs or people who wants to begin building kernels for their first time.
There is a bit of a learning curve to this though, you need to known Linux functions and have android environment setup
This is a UBUNTU script saved as a shell script for any version of UBUNTU
Start off script with executable script definitions
Code:
#!/bin/bash
This next part is important and ultimately optional however it makes coding the script crazy easier
I call these definitions (likely not what they are technically but, it's my interpretation) to enable shortcoding commands which makes the script look cleaner
These can be named whatever you want btw
Kerneldir - is the directory where your kernel files are kept and this is the main place where you build your kernel
Packagedir - is your work environment, this is where your boot.img will be copied to, extra files, updater-script to be later packaged into a zip folder
INITRAMFS_SOURCE - is where the ramdisk should be placed in folder form [Click Here for how to split ramdisk and zimage from boot.img]
Meta - where the updater script is kept so it can be packaged for my kernel to be able to flashed
ARCH - Must stay as this definition as it is needed for compile to become successful
CROSS_COMPILE - Toolchain command, make sure your kernel supports linaro 4.6 and later. Or default to CM's 4.4.3 toolchain. Must stay as this definition as it is needed for compile to become successful
Code:
export KERNELDIR=/home/ayysir/android/kernel/ASDK
export INITRAMFS_DEST=$KERNELDIR/kernel/usr/initramfs
export PACKAGEDIR=/home/ayysir/android/kernel/asdk_out
export INITRAMFS_SOURCE=/home/ayysir/android/kernel
export Meta=/home/ayysir/android/kernel/Ayysir/META-INF
export Drivers=/home/ayysir/android/kernel/Ayysir/Drivers
export App=/home/ayysir/android/kernel/Ayysir/app
export exfat=/home/ayysir/android/kernel/Ayysir/exfat_modules
export ARCH=arm
export CROSS_COMPILE=/home/ayysir/android/kernel/toolchains/android-toolchain-4.7/bin/arm-eabi-
This part are mostly setup commands to clean out workspace deleting previous compile remnants. This is where definitions we made above comes in handy.
The echo commands are like description commands, used for many situations but for our purpose, it tells the user what is currently happening in the script
Assuming you have knowledge about kernel deving so I don't have to hold your hand in describing things
Below commands vary depending on dev as they have their own defconfig setup for their specific device replace my asdk_defconfig with
this is is for configuring what to include the compile build
UPDATE:
OPTIONAL:
Code:
# Colorize and add text parameters
red=$(tput setaf 1) # red
grn=$(tput setaf 2) # green
cya=$(tput setaf 6) # cyan
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldgrn=${txtbld}$(tput setaf 2) # green
bldblu=${txtbld}$(tput setaf 4) # blue
bldcya=${txtbld}$(tput setaf 6) # cyan
txtrst=$(tput sgr0) # Reset
Above Codes Colorize and add text parameters.. it makes it look cleaner and more concise on what is happening in the terminal
The "echo -e" command tells terminal to apply the following text.
"${bldcya}" refers back to colorize table, making it bold (bld) and making text color cyan (cya)
"${txtrst}" closes the statement and resets the color back to terminal default. So the color parameters do not spill over into the next lines
Click to expand...
Click to collapse
the echo "" adds a space in between lines, just so it looks clean and does not jumble things
so here are some example on how to implement this: [Below]
Code:
echo -e "${bldcya} Making Kernel ${txtrst}"
make asdk_defconfig
echo""
echo -e "${bldcya} Clean Environment ${txtrst}"
make menuconfig
Code:
echo "Remove old Package Files"
rm -rf $PACKAGEDIR/*
echo "Setup Package Directory"
mkdir -p $PACKAGEDIR/system/lib/modules
echo "Setup App Directory"
mkdir -p $PACKAGEDIR/data/app
echo "Remove old zImage"
rm $PACKAGEDIR/zImage
echo "Remove old ramdisk"
rm $INITRAMFS_SOURCE/ramdisk.img.gz
echo "Clean Environment"
cd $KERNELDIR
make clean
echo "Make the kernel"
make asdk_defconfig
echo "Clean Environment"
make menuconfig
Before we get to this important section you need two files put into your /bin folder, mkbootfs and mkbootimg Click Here to download these files.
Then you need to cp these files to bin folder [put the files in home folder]
Code:
sudo cp ~/mkbootfs /bin
sudo cp ~/mkbootimg /bin
cd /bin
sudo chmod +x mkbootfs
sudo chmod +x mkbootimg
Now we are ready for next section
Make -j[num] command tells system how much things can be compiled at once, it's dependent on your system (number of processors] so i cay default to -j4
You also notice the script coding wrapped around the make command, this is what I setup to create compile log for compile session just incase you need to go back to review errors or debug some things
Code:
script -q ~/Compile.log -c "
make -j12 "
Below command searches for modules in zimage file and copies the modules files to workplace modules folder for packaging
Code:
cp -a $(find . -name *.ko -print |grep -v initramfs) $PACKAGEDIR/system/lib/modules/
Like I stated before you should of have already split the boot.img file and extracted ramdisk to a ramdisk folder. Below command uses mkbootfs to compress that folder into a .gz formatted file.
Below part is a bit tricky, because it is dependent on device to device basis.
first the code below moves ramdisk to workfolder
Then it cd's to the package folder and uses mkbootimg command to combine zimage and ramdisk together to make a boot.img
What is tricky is the command mkbootimg uses to determine space for the boot.img to be compiled in
The best way to determine the page size, base, & ramdiskaddr is either use the previous tools that you used to split a already compile boot.img commands and it spits out a file info run down or use DSIXDA ANDROID KITCHEN and using it's advanced options to determine boot.img info. Again I am not going to hold your hand on this one since you should research before trying this build script.
Note: many boot.img's use cmdline option in creation
Code:
echo "Make boot.img"
cp $INITRAMFS_SOURCE/ramdisk.img.gz $PACKAGEDIR
cd $PACKAGEDIR
mkbootimg --cmdline 'console = null androidboot.hardware=qcom user_debug=31 zcache' --kernel $PACKAGEDIR/zImage --ramdisk $PACKAGEDIR/ramdisk.img.gz --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 --output $PACKAGEDIR/boot.img
Code:
echo "Packaging Ramdisk"
cd $INITRAMFS_SOURCE/
mkbootfs ./ASDK-ramdisk | gzip > ramdisk.img.gz
Code:
echo "Compiling"
script -q ~/Compile.log -c "
make -j12 "
echo "Copy modules to Package"
cp -a $(find . -name *.ko -print |grep -v initramfs) $PACKAGEDIR/system/lib/modules/
cp $Drivers/* $PACKAGEDIR/system/lib/
echo "Copy zImage to Package"
cp $KERNELDIR/arch/arm/boot/zImage $PACKAGEDIR/zImage
echo "Packaging Ramdisk"
cd $INITRAMFS_SOURCE/
mkbootfs ./ASDK-ramdisk | gzip > ramdisk.img.gz
echo "Make boot.img"
cp $INITRAMFS_SOURCE/ramdisk.img.gz $PACKAGEDIR
cd $PACKAGEDIR
mkbootimg --cmdline 'console = null androidboot.hardware=qcom user_debug=31 zcache' --kernel $PACKAGEDIR/zImage --ramdisk $PACKAGEDIR/ramdisk.img.gz --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 --output $PACKAGEDIR/boot.img
This is where you add files you want packaged into your zip folder
*Remember add new definitions every time you add a new directory to the mix and have them cp all the files to workfolder
Code:
export curdate=`date "+%m-%d-%Y"`
This sets definition to zip to auto-generate dates to date your builds so it takes the work out of renaming the zip file [Your welcome lol]
Code:
zip -r ../ASDK-AOSP-4.2-$curdate.zip
set a name to your build and add $curdate.zip to enable auto dating zip
Code:
echo "Import of META-INF"
cp -R $Meta $PACKAGEDIR
echo "Import Voltage Control"
cp $App/* $PACKAGEDIR/data/app
echo "Importing Exfat fix"
cp $exfat/* $PACKAGEDIR/system/lib/modules
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/Compile-$curdate.log
rm ~/Compile.log
cd $PACKAGEDIR
rm ramdisk.img.gz
rm zImage
rm ../ASDK-AOSP-4.2*.zip\
rm -R .fr-7q5stU
zip -r ../ASDK-AOSP-4.2-$curdate.zip .
read -p "Press ENTER to Exit"
UPDATE:
Not to confuse anyone, Below is based off my new build script I use. PLEASE DO NOT COPY WORD FOR WORD, CODE BY CODE JUST USE IT AS REFERENCE. IF YOUR NOT SMART ENOUGH TO GET WHAT I AM DOING THEN DONT TRY BUILDING KERNELS LOL
Code:
if [ -e $KERNELDIR/arch/arm/boot/zImage ]; then
echo -e "${bldred} Copy modules to Package ${txtrst}"
cp -a $(find . -name *.ko -print |grep -v initramfs) $PACKAGEDIR/system/lib/modules/
echo ""
echo -e "${bldred} Copy zImage to Package ${txtrst}"
cp $KERNELDIR/arch/arm/boot/zImage $PACKAGEDIR/zImage
echo ""
echo -e "${bldred} Ramdisk Readying.. ${txtrst}"
cp $KERNELDIR/mkbootfs $INITRAMFS_SOURCE
cd $INITRAMFS_SOURCE/
./mkbootfs ASDK-krait | gzip > ramdisk.krait.gz
rm mkbootfs
echo ""
echo -e "${bldred} Making Boot.img.. ${txtrst}"
cp $KERNELDIR/mkbootimg $PACKAGEDIR
cp $INITRAMFS_SOURCE/ramdisk.krait.gz $PACKAGEDIR
cd $PACKAGEDIR
./mkbootimg --cmdline 'console = null androidboot.hardware=qcom user_debug=31 zcache' --kernel $PACKAGEDIR/zImage --ramdisk $PACKAGEDIR/ramdisk.krait.gz --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 --output $PACKAGEDIR/boot.img
rm mkbootimg
echo ""
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/compile_logs/Success-Krait-$curdate.log
rm ~/Compile.log
cd $PACKAGEDIR
rm ramdisk.krait.gz
rm zImage
rm ../../ASDK-AOSP-3.4.x-*.zip
rm ../ramdisk.krait.gz
rm ../zImage
zip -r ../ASDK-AOSP-3.4.x-$curdate-EXP.zip .
mv ../ASDK-AOSP-3.4.x-$curdate-EXP.zip ~/android/kernel
echo "ASDK HOT OFF THE PRESS"
else
echo "KERNEL DID NOT BUILD! no zImage exist"
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/compile_logs/Failed-Krait-$curdate.log
fi;
exit 0
Now before you get mind blown Let me explain the update above:
"if [ -e $KERNELDIR/arch/arm/boot/zImage ]; then" is known as the "if, then" commands. Most used in C and scripting it tells system to look for a certain file or directory first, "if" present "then" it will proceed to following commands after it.
so if the zimage does exist then, the code after the statement will go on and end up making the zip folder.
"else" commands tells terminal, well if that file in the if statement does not exist then use following commands instead. In this case if $KERNELDIR/arch/arm/boot/zImage does not exist then else do this:
Code:
else
echo "KERNEL DID NOT BUILD! no zImage exist"
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/compile_logs/Failed-Krait-$curdate.log
This else statement makes a fail log to where you keep your build logs. This allows you to see where in the build did you received an error which caused the zimage to not be produced. Also it wont make a zip folder so no useless zips with no boot.img in there
Click to expand...
Click to collapse
chmod +x your script [make sure you save it as blahblah.sh] and boom your done
CLICK HERE TO SEE MY FULL SCRIPT THAT I USE FOR MY GS3 KERNEL BUILDS [NEEDS REVISING THOUGH]
IF YOU HAVE ANY QUESTIONS LEAVE IT IN THE COMMENTS OR PM ME
IF YOU LIKED MY HOW-TO AND WOULD LIKE TO DONATE TO HELP ME DEV FOR MORE DEVICES [APPRECIATED BUT DONATION NOT REQUIRED] CLICK HERE
Reserved
hm
Another Example for Fun
Well this thread looked like it needed a comment or at least some positive feedback so here it goes.
Thanks so much @ayysir for making this tutorial!!!! I've been using scripts to do lots of things for me for about a year now and it all started when I read this thread. (for some reason the though of bash scripts never really crossed my mind before then)
Here is an example of how creative I've got since the beginning of this. My script now includes some colored logos just for fun as well as final build time, uploading to goo.im, and signing of the final zip. (The logos might not show up right on here but they look great in terminal)
Code:
#!/bin/bash
#Cl3Kener's Hammerhead Script
# Colorize and add text parameters (originally grabbed from Ayysir)
red=$(tput setaf 1) # red
grn=$(tput setaf 2) # green
cya=$(tput setaf 6) # cyan
pnk=$(tput bold ; tput setaf 5) # pink
yel=$(tput bold ; tput setaf 3) # yellow
pur=$(tput setaf 5) # purple
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldgrn=${txtbld}$(tput setaf 2) # green
bldyel=${txtbld}$(tput bold ; tput setaf 3) # yellow
bldblu=${txtbld}$(tput setaf 4) # blue
bldpur=${txtbld}$(tput setaf 5) # purple
bldpnk=${txtbld}$(tput bold ; tput setaf 5) # pink
bldcya=${txtbld}$(tput setaf 6) # cyan
txtrst=$(tput sgr0) # Reset
#Place you defconfig name here:
DEFCONFIG=uber_hammerhead_defconfig
# Change these exports as needed:
export INITRAMFS_DEST=~/android/kernel/usr/initramfs
export PACKAGEDIR=~/android/kernel/OUT
export KERNEL_SOURCE=~/android/kernel
export Meta=~/android/kernel/Cl3Kener/META-INF
export Etc=~/android/kernel/Cl3Kener/etc
export Scripts=~/android/kernel/Cl3Kener/kernel
export Bin=~/android/kernel/Cl3Kener/bin
export Lib=~/android/kernel/Cl3Kener/lib
export GPU=~/android/kernel/Cl3Kener/kcontrol_gpu_msm
export sign=~/android/kernel/Cl3Kener/signapk_files
export ARCH=arm
export CROSS_COMPILE=~/android/kernel/TOOLCHAINS/arm-eabi-4.7/bin/arm-eabi-
# Place your goo.im password here instead of XXXXXX so you don't have to input password (or you can use ssh key if you have one):
export SSHPASS=XXXXXXX
# Start Time
res1=$(date +%s.%N)
# Logo (just for fun)
echo "${bldpur} ${txtrst}"
echo "${bldpur} ________________________________________ ${txtrst}"
echo "${bldpur}| |${txtrst}"
echo "${bldpur}| _| _| _|_|_| _|_|_|_| _|_|_| |${txtrst}"
echo "${bldpur}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldpur}| _| _| _|_|_| _|_|_| _|_|_| |${txtrst}"
echo "${bldpur}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldpur}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldpur}| _|_| _|_|_| _|_|_|_| _| _| |${txtrst}"
echo "${bldpur}|________________________________________|${txtrst}"
echo "${bldpur} ${txtrst}"
echo "${bldcya}Remove Old Package Files ${txtrst}"
rm -rf $PACKAGEDIR/*
echo " "
echo "${bldgrn}Setup Init.d Directory ${txtrst}"
mkdir -p $PACKAGEDIR/system/etc
echo " "
echo "${bldyel}Setup Scripts Directory ${txtrst}"
mkdir -p $PACKAGEDIR/modules
echo " "
echo "${bldblu}Remove old zImage ${txtrst}"
rm $KERNEL_SOURCE/arch/arm/boot/zImage
rm $KERNEL_SOURCE/arch/arm/boot/zImage-dtb
echo " "
echo -e "${bldred}Removing annoying gedit backup files ${txtrst}"
cd ~/android/kernel
find ./ -name '*~' | xargs rm
echo " "
echo "${bldgrn}Clean Environment ${txtrst}"
cd $KERNEL_SOURCE
make $DEFCONFIG
rm $KERNEL_SOURCE/.version
rm $KERNEL_SOURCE/.config.old
rm $KERNEL_SOURCE/.config
make clean
echo " "
echo "${bldpnk}Kernel Menu ${txtrst}"
make menuconfig
echo " "
echo "${bldcya}Compiling.... ${txtrst}"
script -q ~/Compile.log -c "
make -j7"
echo " "
if [ -e $KERNEL_SOURCE/arch/arm/boot/zImage-dtb ]; then
# I used Showp1984 msm_mpdecision hotplug and so I use his KControl Module.
echo "${bldyel}Making GPU Module ${txtrst}"
cd $GPU
make clean
make -j7
echo " "
cd $KERNEL_SOURCE
echo "${bldgrn}Copy Modules to OUT ${txtrst}"
cp -a $(find . -name *.ko -print |grep -v initramfs) $PACKAGEDIR/modules/
echo "${bldblu}Import Scripts ${txtrst}"
cp -R $Scripts $PACKAGEDIR
echo "${bldcya}Copy bin to OUT ${txtrst}"
cp -R $Bin $PACKAGEDIR/system/bin
echo "${bldred}Copy zImage to OUT ${txtrst}"
cp $KERNEL_SOURCE/arch/arm/boot/zImage-dtb $PACKAGEDIR/kernel/zImage
echo "${bldgrn}Import of META-INF ${txtrst}"
cp -R $Meta $PACKAGEDIR
echo "${bldcya}Import Init.d Tweaks ${txtrst}"
cp -R $Etc/init.d $PACKAGEDIR/system/etc
echo "${bldred}Import Dalvik/Bionic Optimized Libs ${txtrst}"
cp -R $Lib $PACKAGEDIR/system
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/Logs/Completed-Uber-hammerhead-$curdate.log
rm ~/Compile.log
cd $PACKAGEDIR
rm ../UBER-Hammerhead*.zip\
rm -R .fr-7q5stU
zip -r ../UBER-Hammerhead-Nightly.zip .
echo " "
echo "${bldblu}Signing Zip ${txtrst}"
cd $KERNEL_SOURCE
cp $sign/signapk.jar $KERNEL_SOURCE
cp $sign/testkey.pk8 $KERNEL_SOURCE
cp $sign/testkey.x509.pem $KERNEL_SOURCE
java -jar ~/android/kernel/signapk.jar testkey.x509.pem testkey.pk8 UBER-Hammerhead-Nightly.zip UBER-Hammerhead-Linaro-4.8.3-$curdate.zip
rm UBER-Hammerhead-Nightly.zip
rm signapk.jar
rm testkey.pk8
rm testkey.x509.pem
echo "${bldgrn} ${txtrst}"
echo "${bldgrn} ${txtrst}"
echo "${bldgrn} ________________________________________ ${txtrst}"
echo "${bldgrn}| |${txtrst}"
echo "${bldgrn}| _| _| _|_|_| _|_|_|_| _|_|_| |${txtrst}"
echo "${bldgrn}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldgrn}| _| _| _|_|_| _|_|_| _|_|_| |${txtrst}"
echo "${bldgrn}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldgrn}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldgrn}| _|_| _|_|_| _|_|_|_| _| _| |${txtrst}"
echo "${bldgrn}|________________________________________|${txtrst}"
echo "${bldgrn} ${txtrst}"
echo "${bldgrn} ${txtrst}"
echo "${bldgrn}Kernel has completed successfully!!! ${txtrst}"
echo " "
echo " "
echo "${bldgrn}Uploading .... ${txtrst}"
echo " "
sshpass -e scp -P 2222 ~/android/kernel/UBER-Hammerhead-Linaro-4.8.3-$curdate.zip [email protected]:/home/Cl3Kener/public_html/HAMMERHEAD/KERNELS/UBER/EXP-LINARO/UBER-Hammerhead-Linaro-4.8.3-$curdate.zip
# Show Elapsed Time
res2=$(date +%s.%N)
echo "${bldgrn}Total elapsed time of ALL BUILDS AND UPLOADS: ${txtrst}${grn}$(echo "($res2 - $res1) / 60"|bc ) minutes ($(echo "$res2 - $res1"|bc ) seconds) ${txtrst}"
else
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/Logs/Failed-Uber-hammerhead-$curdate.log
rm ~/Compile.log
echo "${bldred} ${txtrst}"
echo "${bldred} ${txtrst}"
echo "${bldred} ________________________________________ ${txtrst}"
echo "${bldred}| |${txtrst}"
echo "${bldred}| _| _| _|_|_| _|_|_|_| _|_|_| |${txtrst}"
echo "${bldred}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldred}| _| _| _|_|_| _|_|_| _|_|_| |${txtrst}"
echo "${bldred}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldred}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldred}| _|_| _|_|_| _|_|_|_| _| _| |${txtrst}"
echo "${bldred}|________________________________________|${txtrst}"
echo "${bldred} ${txtrst}"
echo "${bldred} ${txtrst}"
echo "${bldred}KERNEL IMAGE DID NOT BUILD PROPERLY! Check Compile log! ${txtrst}"
echo " "
# Show Elapsed Time
res2=$(date +%s.%N)
echo "${bldred}Total elapsed time of ALL BUILDS AND UPLOADS: ${txtrst}${red}$(echo "($res2 - $res1) / 60"|bc ) minutes ($(echo "$res2 - $res1"|bc ) seconds) ${txtrst}"
fi;
echo " "
read -p "Press ENTER to Exit"
Hope this helps some of you get creative!
If you want to see a finished product so you can figure out how everything came together see here: http://goo.im/devs/Cl3Kener/HAMMERHEAD/KERNELS/UBER
Cheers!
Cl3Kener
Awesome guide. probbaly not seen much because of its placement but his is helpful!
This is very helpful. Thanks!
Tapatalk-kal küldve az én Nexus 5-el
I have kali linux,i am using for two years
can i use it for this?

[TOOL][WIN]Take screenshots of Aroma and Recovery v1.1

This is a tool to capture screenshots while in Recovery or the Aroma Installer.
Support has ended, due to the possibility of pixel formats changing from each recovery update you receive.
But I did make a better Recovery Screenshot that handles this problem, and it can be found here or below.:cyclops:
http://forum.xda-developers.com/showthread.php?p=50029759​
It's no big secret around XDA that you can use the program FFmpeg to convert your raw framebuffer file into a normal image file. I've found the values for the Nexus 5 and made a batch script that incorporates the programs adb, and ffmpeg; to save screenshots to your computer. I don't have a Nexus 5, but thanks to an XDA user, @ikslawlok, who posted his raw framebuffer from TWRP 2.6.3.4 on another website, I was able to get it working. Also thanks to @rootSU for testing in Philz, a CWM based recovery. This should work on all versions of Windows. I have only tested in Windows 7 personally. The process, as far as using ffmpeg and adb, used here is also possible in Linux. Some versions of ffmpeg for Linux are antiquated, hence there isn't really a write one script; work for all.
Why would anyone use this or do this?
Most people, that probably includes you reading this, have actually no use for it, nor can you think of a reason too. The uses of this are limited to people that write tutorials, custom recovery themes, and the rare event that you have an anomaly in your recovery and you can't describe it.
I owe a big thanks to @Whiskey103 with his work in this thread over in the HTC One forum. :good:
You have to have the adb drivers installed before you can do anything. Go here for more information.
This rar file contains the programs adb and ffmpeg. This 32-bit version of ffmpeg is one of the newest versions available on their downloads page. You must have adb.exe, ffmpeg.exe, and the two dll files for adb in the same directory as the batch file. The easiest thing to do is just extract the rar to a new directory, then run the file named "RUNrsn511.bat" The screenshots you capture will be saved in the same folder that you unzipped everything in as 'timestamp'.png
Thank you @weihan1102 for helping me test and providing your framebuffer from the modified version of TWRP for multirom!
Download Recovery Screenshot v1.1
If you have already downloaded the original version, and wish to update with support for the modified twrp for multirom without downloading the whole new rar, then hit the button below.
The only difference is the RUNrs.bat batch script. You may wish to just download the new batch file here, it is only 1.7KB zipped. It is RUNrsn511.rar and can just be unzipped into the folder you originally unzipped the other files into. I would then delete the original batch file.
An easier way, I think, is to click show content below and click anywhere in the box. Hit Ctrl+A to select everything, hit Ctrl+C to copy it to the clipboard. Then right click on your original RUNrs.bat file, and select edit. Click in that screen anywhere, hit Ctrl+A to select everything in there, then Ctrl+V to paste the new batch script into RUNrs.bat.
Code:
@ECHO OFF
CLS
TITLE Recovery Screenshot v1.1
MODE CON:COLS=54 LINES=40
COLOR 0B
SET TS=0
SET "ffshowb=-hide_banner"
SET "ffdebug=-loglevel fatal"
IF "%~1"=="-d" (
REM @ECHO ON
SET "ffdebug=-loglevel debug"
SET "ffshowb=%"
MODE CON:COLS=140 LINES=250
COLOR 07
ECHO __________________________________________________________________
ECHO DEBUG INFO
ECHO __________________________________________________________________
)
:START
ECHO[
ECHO ______________________________________________________
ECHO This will pull a screenshot from your Nexus 5 and
ECHO save it to the directory that you ran this bat
ECHO file in. Connect USB ^& reboot into your recovery.
ECHO ______________________________________________________
ECHO Thanks to Whiskey103 for the idea!!
ECHO Written by makers_mark
ECHO ______________________________________________________
IF NOT EXIST ffmpeg.exe GOTO NOFILES
IF NOT EXIST adb.exe GOTO NOFILES
ADB kill-server -d >nul 2>&1
IF %TS%=="NOGOOD" GOTO SKIPPEDthatPause
ECHO Press 1 or 2
ECHO 1 - Save a screenshot using multirom twrp recovery
ECHO 2 - Save a screenshot using other recoveries
ECHO ______________________________________________________
CHOICE /C:12 >nul
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 SET "pixfmt=-pix_fmt rgb565"
IF %K%==2 SET "pixfmt=-pix_fmt rgb0"
:SKIPPEDthatPause
ECHO[
ECHO Pulling framebuffer from /dev/graphics/fb0
adb pull /dev/graphics/fb0 frmbfr >nul
IF ERRORLEVEL 1 (cls
SET TS="NOGOOD"
ECHO ______________________________________________________
ECHO Adb is not properly connected.
ECHO Try "Safely Removing" your N5 from your computer
ECHO Then unplug your usb cable, and reinsert it.
ECHO ______________________________________________________
ECHO[
ECHO[
ECHO Press any key to try again.
ECHO[
ECHO[
PAUSE >nul
CLS
GOTO START
)
SET TS=%DATE:/=%_%TIME::=_%
SET TS=%TS:.=%
SET TS=%TS: =%.png
FFMPEG %ffdebug% %ffshowb% -f rawvideo -vcodec rawvideo %pixfmt% -s 1088x1920 -i frmbfr -vf crop=1080:1920:0:0 -y %TS%
IF NOT EXIST %TS% GOTO ERRNE
DEL frmbfr >nul
ECHO ______________________________________________________
ECHO Screenshot saved as %TS%
ECHO ______________________________________________________
ECHO Press 1 or 2
ECHO 1 - Save another screenshot
ECHO 2 - Exit
ECHO ______________________________________________________
CHOICE /C:12 >nul
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 GOTO SKIPPEDthatPause
IF %K%==2 GOTO FINISH
:NOFILES
CLS
ECHO The directory that you are running this script in is:
ECHO %~dp0
ECHO[
ECHO You must run this script in the same directory as
ECHO adb.exe and ffmpeg.exe. Press any key to exit
PAUSE >nul
EXIT
:ERRNE
CLS
MODE CON:COLS=108 LINES=200
COLOR 07
FFMPEG -loglevel debug -f rawvideo -vcodec rawvideo %pixfmt% -s 1088x1920 -i frmbfr -vf crop=1080:1920:0:0 -y %TS%
ECHO ____________________________________________________________________________________________________________
ECHO There was a problem converting the framebuffer to a png file.
ECHO[
ECHO To capture the screen of the cmd window, hold down the alt key and press PrtSc on your keyboard. This
ECHO will save an image of the current window in memory on your clipboard. Then open paint or photoshop or
ECHO whatever program you use and hit ctrl+N to open a new file, then ctrl+V to paste an image. Save it and
ECHO please message me it or post in the XDA forum thread.
ECHO[
ECHO[
ECHO If you got to this screen and are not using a Nexus 5, congratulations for successfully pulling the
ECHO framebuffer. To figure out the resolution to use, try adding 4,8, or 16 to your native width to make it
ECHO evenly divisible by 32. Example resolution is 1080x1920..1080^/32^=33.75 ^< not right, so try 1088^/32^=34 ^< good
ECHO Only worry about width (left to right), height is stored orderly in memory.
ECHO[
ECHO To see a list of all of the pix_fmts supported by ffmpeg, run ffmpeg -pix_fmts
ECHO[
ECHO Press 1 or 2
ECHO 1 - Show available pixel formats
ECHO 2 - Exit
CHOICE /C:12
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 (cls
MODE CON:COLS=52 LINES=200
ffmpeg -hide_banner -pix_fmts
pause
GOTO FINISH)
IF %K%==2 GOTO FINISH
:FINISH
ADB kill-server -d
EXIT
I have more screenshots at my 2013 Nexus 7 thread.
Batch script v1.1
Code:
@ECHO OFF
CLS
TITLE Recovery Screenshot v1.1
MODE CON:COLS=54 LINES=40
COLOR 0B
SET TS=0
SET "ffshowb=-hide_banner"
SET "ffdebug=-loglevel fatal"
IF "%~1"=="-d" (
REM @ECHO ON
SET "ffdebug=-loglevel debug"
SET "ffshowb=%"
MODE CON:COLS=140 LINES=250
COLOR 07
ECHO __________________________________________________________________
ECHO DEBUG INFO
ECHO __________________________________________________________________
)
:START
ECHO[
ECHO ______________________________________________________
ECHO This will pull a screenshot from your Nexus 5 and
ECHO save it to the directory that you ran this bat
ECHO file in. Connect USB ^& reboot into your recovery.
ECHO ______________________________________________________
ECHO Thanks to Whiskey103 for the idea!!
ECHO Written by makers_mark
ECHO ______________________________________________________
IF NOT EXIST ffmpeg.exe GOTO NOFILES
IF NOT EXIST adb.exe GOTO NOFILES
ADB kill-server -d >nul 2>&1
IF %TS%=="NOGOOD" GOTO SKIPPEDthatPause
ECHO Press 1 or 2
ECHO 1 - Save a screenshot using multirom twrp recovery
ECHO 2 - Save a screenshot using other recoveries
ECHO ______________________________________________________
CHOICE /C:12 >nul
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 SET "pixfmt=-pix_fmt rgb565"
IF %K%==2 SET "pixfmt=-pix_fmt rgb0"
:SKIPPEDthatPause
ECHO[
ECHO Pulling framebuffer from /dev/graphics/fb0
adb pull /dev/graphics/fb0 frmbfr >nul
IF ERRORLEVEL 1 (cls
SET TS="NOGOOD"
ECHO ______________________________________________________
ECHO Adb is not properly connected.
ECHO Try "Safely Removing" your N5 from your computer
ECHO Then unplug your usb cable, and reinsert it.
ECHO ______________________________________________________
ECHO[
ECHO[
ECHO Press any key to try again.
ECHO[
ECHO[
PAUSE >nul
CLS
GOTO START
)
SET TS=%DATE:/=%_%TIME::=_%
SET TS=%TS:.=%
SET TS=%TS: =%.png
FFMPEG %ffdebug% %ffshowb% -f rawvideo -vcodec rawvideo %pixfmt% -s 1088x1920 -i frmbfr -vf crop=1080:1920:0:0 -y %TS%
IF NOT EXIST %TS% GOTO ERRNE
DEL frmbfr >nul
ECHO ______________________________________________________
ECHO Screenshot saved as %TS%
ECHO ______________________________________________________
ECHO Press 1 or 2
ECHO 1 - Save another screenshot
ECHO 2 - Exit
ECHO ______________________________________________________
CHOICE /C:12 >nul
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 GOTO SKIPPEDthatPause
IF %K%==2 GOTO FINISH
:NOFILES
CLS
ECHO The directory that you are running this script in is:
ECHO %~dp0
ECHO[
ECHO You must run this script in the same directory as
ECHO adb.exe and ffmpeg.exe. Press any key to exit
PAUSE >nul
EXIT
:ERRNE
CLS
MODE CON:COLS=108 LINES=200
COLOR 07
FFMPEG -loglevel debug -f rawvideo -vcodec rawvideo %pixfmt% -s 1088x1920 -i frmbfr -vf crop=1080:1920:0:0 -y %TS%
ECHO ____________________________________________________________________________________________________________
ECHO There was a problem converting the framebuffer to a png file.
ECHO[
ECHO To capture the screen of the cmd window, hold down the alt key and press PrtSc on your keyboard. This
ECHO will save an image of the current window in memory on your clipboard. Then open paint or photoshop or
ECHO whatever program you use and hit ctrl+N to open a new file, then ctrl+V to paste an image. Save it and
ECHO please message me it or post in the XDA forum thread.
ECHO[
ECHO[
ECHO If you got to this screen and are not using a Nexus 5, congratulations for successfully pulling the
ECHO framebuffer. To figure out the resolution to use, try adding 4,8, or 16 to your native width to make it
ECHO evenly divisible by 32. Example resolution is 1080x1920..1080^/32^=33.75 ^< not right, so try 1088^/32^=34 ^< good
ECHO Only worry about width (left to right), height is stored orderly in memory.
ECHO[
ECHO To see a list of all of the pix_fmts supported by ffmpeg, run ffmpeg -pix_fmts
ECHO[
ECHO Press 1 or 2
ECHO 1 - Show available pixel formats
ECHO 2 - Exit
CHOICE /C:12
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 (cls
MODE CON:COLS=52 LINES=200
ffmpeg -hide_banner -pix_fmts
pause
GOTO FINISH)
IF %K%==2 GOTO FINISH
:FINISH
ADB kill-server -d
EXIT
Batch script v1
Code:
@ECHO OFF
CLS
TITLE Recovery Screenshot
MODE CON:COLS=54 LINES=40
COLOR 0B
SET TS=0
SET "ffshowb=-hide_banner"
SET "ffdebug=-loglevel fatal"
IF "%~1"=="-d" (
REM @ECHO ON
SET "ffdebug=-loglevel debug"
SET "ffshowb=%"
MODE CON:COLS=140 LINES=250
COLOR 07
ECHO __________________________________________________________________
ECHO DEBUG INFO
ECHO __________________________________________________________________
)
:START
ECHO[
ECHO ______________________________________________________
ECHO This will pull a screenshot from your Nexus 5 and
ECHO save it to the directory that you ran this bat
ECHO file in. Connect USB ^& reboot into your recovery.
ECHO ______________________________________________________
ECHO Thanks to Whiskey103 for the idea!!
ECHO Written by makers_mark
ECHO ______________________________________________________
IF NOT EXIST ffmpeg.exe GOTO NOFILES
IF NOT EXIST adb.exe GOTO NOFILES
ADB kill-server -d >nul 2>&1
IF %TS%=="NOGOOD" GOTO SKIPPEDthatPause
ECHO Press any key when you are ready.
PAUSE >nul
:SKIPPEDthatPause
ECHO[
ECHO Pulling framebuffer from /dev/graphics/fb0
adb pull /dev/graphics/fb0 frmbfr >nul
IF ERRORLEVEL 1 (cls
SET TS="NOGOOD"
ECHO ______________________________________________________
ECHO Adb is not properly connected.
ECHO Try "Safely Removing" your N5 from your computer
ECHO Then unplug your usb cable, and reinsert it.
ECHO ______________________________________________________
ECHO[
ECHO[
ECHO Press any key to try again.
ECHO[
ECHO[
PAUSE >nul
CLS
GOTO START
)
SET TS=%DATE:/=%_%TIME::=_%
SET TS=%TS:.=%
SET TS=%TS: =%.png
FFMPEG %ffdebug% %ffshowb% -f rawvideo -vcodec rawvideo -pix_fmt rgb0 -s 1088x1920 -i frmbfr -vf crop=1080:1920:0:0 -y %TS%
IF NOT EXIST %TS% GOTO ERRNE
DEL frmbfr >nul
ECHO ______________________________________________________
ECHO Screenshot saved as %TS%
ECHO ______________________________________________________
ECHO Press 1 or 2
ECHO 1 - Save another screenshot
ECHO 2 - Exit
ECHO ______________________________________________________
CHOICE /C:12 >nul
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 GOTO SKIPPEDthatPause
IF %K%==2 GOTO FINISH
:NOFILES
CLS
ECHO The directory that you are running this script in is:
ECHO %~dp0
ECHO[
ECHO You must run this script in the same directory as
ECHO adb.exe and ffmpeg.exe. Press any key to exit
PAUSE >nul
EXIT
:ERRNE
CLS
MODE CON:COLS=108 LINES=200
COLOR 07
FFMPEG -loglevel debug -f rawvideo -vcodec rawvideo -pix_fmt rgb0 -s 1088x1920 -i frmbfr -vf crop=1080:1920:0:0 -y %TS%
ECHO ____________________________________________________________________________________________________________
ECHO There was a problem converting the framebuffer to a png file.
ECHO[
ECHO To capture the screen of the cmd window, hold down the alt key and press PrtSc on your keyboard. This
ECHO will save an image of the current window in memory on your clipboard. Then open paint or photoshop or
ECHO whatever program you use and hit ctrl+N to open a new file, then ctrl+V to paste an image. Save it and
ECHO please message me it or post in the XDA forum thread.
ECHO[
ECHO[
ECHO If you got to this screen and are not using a Nexus 5, congratulations for successfully pulling the
ECHO framebuffer. To figure out the resolution to use, try adding 4,8,16, or 32 to your native width to make
ECHO room for the extra data, ioctrls?, at the end of each pixel row. Experiment with different pixel formats
ECHO also.
ECHO[
ECHO To see a list of all of the pix_fmts supported by ffmpeg, run ffmpeg -pix_fmts
ECHO[
ECHO Press 1 or 2
ECHO 1 - Show available pixel formats
ECHO 2 - Exit
CHOICE /C:12
IF ERRORLEVEL 1 SET K=1
IF ERRORLEVEL 2 SET K=2
IF %K%==1 (cls
MODE CON:COLS=52 LINES=200
ffmpeg -hide_banner -pix_fmts
pause
GOTO FINISH)
IF %K%==2 GOTO FINISH
:FINISH
ADB kill-server -d
EXIT
Great! It worked!
I've just test it on my Nexus5.
Thanks!
Thanks! but seems like the color isn't correct and it content 4 screenshot in a single png file.
weihan1102 said:
Thanks! but seems like the color isn't correct and it content 4 screenshot in a single png file.
Click to expand...
Click to collapse
It looks like the multirom twrp uses a different kernel.
Can you do me a favor and substitute '-pix_fmt rgb0' with '-pix_fmt rgba' in the batch file?
To edit the batch file just right click it and choose edit. Find the lines, there's two of them, that start with ffmpeg..... and replace the part above. Save it and try again.
makers_mark said:
It looks like the multirom twrp uses a different kernel.
Can you do me a favor and substitute '-pix_fmt rgb0' with '-pix_fmt rgba' in the batch file?
To edit the batch file just right click it and choose edit. Find the lines, there's two of them, that start with ffmpeg..... and replace the part above. Save it and try again.
Click to expand...
Click to collapse
No, the color change but still not the correct color
weihan1102 said:
No, the color change but still not the correct color
Click to expand...
Click to collapse
Can you change the pix_fmt to bgra? I could figure it out later if you could upload your framebuffer file later, I won't be able to be around a computer for about 11 or 12 hours from now.
To save the framebuffer to your computer : shift + right click on the folder adb and other files are in, and select run cmd here. In the command window type 'adb pull /dev/graphics/fb0 rawfb0.raw'. The file rawfb0.raw will be in that same folder now.
makers_mark said:
Can you change the pix_fmt to bgra? I could figure it out later if you could upload your framebuffer file later, I won't be able to be around a computer for about 11 or 12 hours from now.
To save the framebuffer to your computer : shift + right click on the folder adb and other files are in, and select run cmd here. In the command window type 'adb pull /dev/graphics/fb0 rawfb0.raw'. The file rawfb0.raw will be in that same folder now.
Click to expand...
Click to collapse
bgra didn't work.
and the rawfb0.raw, here you are
https://drive.google.com/file/d/0B5FN-6JxBhASempFLTFUSDlkX3c/edit?usp=sharing
weihan1102 said:
bgra didn't work.
and the rawfb0.raw, here you are
https://drive.google.com/file/d/0B5FN-6JxBhASempFLTFUSDlkX3c/edit?usp=sharing
Click to expand...
Click to collapse
Thank you so much! I will fix it when I get home.

Script to create swapfile

I save this code as ramswap.sh.. but when I try to execute using Terminal emulator with permission of course, it gives me error
Code:
dd if=/dev/zero of=/mnt/sdcard/swapfile bs=1048576 count=300
mkswap /mnt/sdcard/swapfile
swapon /mnt/sdcard/swapfile
echo "vm.swappiness=80" >> /etc/sysctl.conf
sysctl -p
echo "#!/system/bin/sh" >> /etc/init.d/99swapon
echo "sleep 75" >> /etc/init.d/99swapon
echo "swapon /mnt/sdcard/swapfile" >> /etc/init.d/99swapon
echo "sysctl -p" >> /etc/init.d/99swapon

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