[DEV/Add-On]bash for android. - Nexus 4 General

Hello all.
This is my first share at the Android forums:
On my first device -- Samsung Galaxy S2 - I9100 Intl. -- I have BASH shell, so I've got used to working with it so i was missing it on my second device -- LG Nexus 4 -- the installer from the market was not working on the last one...
So I've remembered seeing here a post by nubecoder saying he compiled bash 4.2.2 for android, ang gave it a shot, but it was not working as expected on my device...
I've decided to recreate it for my Nexus 4.
All credit goes to nubecoder, I've only re-created the ZIP installer.
So, I hope someone else will enjoy nubecoder (I've tested it on my device and it is working) work remake by me.
Highlights and remarks are most welcome...
1.1:
Fixed mounting order error...
If it worth a donation, PM me and I'll give my paypal donation details (I have not done it ever, so when it will be relevant, I will...)

dmagician said:
Hello all.
This is my first share at the Android forums:
On my first device -- Samsung Galaxy S2 - I9100 Intl. -- I have BASH shell, so I've got used to working with it so i was missing it on my second device -- LG Nexus 4 -- the installer from the market was not working on the last one...
So I've remembered seeing here a post by nubecoder saying he compiled bash 4.2.2 for android, ang gave it a shot, but it was not working as expected on my device...
I've decided to recreate it for my Nexus 4.
All credit goes to nubecoder, I've only re-created the ZIP installer.
So, I hope someone else will enjoy nubecoder (I've tested it on my device and it is working) work remake by me.
Highlights and remarks are most welcome...
If it worth a donation, PM me and I'll give my paypal donation details (I have not done it ever, so when it will be relevant, I will...)
Click to expand...
Click to collapse
thank you for this! i tried to install it. however i am running in to some problems. the installation partially fails with twrp. the update script tries to set the permission on some files in /data/local but the files are not there:
Code:
set_perm(0, 2000, 0666, "/data/local/.bash_history");
set_perm(0, 2000, 0666, "/data/local/.editor");
set_perm(0, 2000, 0666, "/data/local/.inputrc");
set_perm(0, 2000, 0666, "/data/local/.minttyrc");
these files are in the zip, but no permissions are set via the update-script:
Code:
.bashrc
.bashrc_support
.bashrc_user
.profile
can you help me out?

-- 1st Reserved --
-- 1st Reserved --

-- 2nd Reserved --
-- 2nd Reserved --

Fixed -- I Hope
UnitedOceanic said:
thank you for this! i tried to install it. however i am running in to some problems. the installation partially fails with twrp. the update script tries to set the permission on some files in /data/local but the files are not there:
Code:
set_perm(0, 2000, 0666, "/data/local/.bash_history");
set_perm(0, 2000, 0666, "/data/local/.editor");
set_perm(0, 2000, 0666, "/data/local/.inputrc");
set_perm(0, 2000, 0666, "/data/local/.minttyrc");
these files are in the zip, but no permissions are set via the update-script:
Code:
.bashrc
.bashrc_support
.bashrc_user
.profile
can you help me out?
Click to expand...
Click to collapse
Fixed mounting.
Explanation:
The data partition was mounted AFTER expanding contents, so the content was lost on mounting data partition.

Some changes failed
Hi there, I've tried to apply it on my N4 (4.4.2 stock with MultiROM, Dalvik / Bionic patches and 4Way Reboot / Volume Wake) and I got stuck in an error.
Here is my log:
* Mounting '/system'
* Mounting '/data'
/data is already mounted.
Extracting files
minzip: Extracted 318 file(s)
minzip: Extracted 2 file(s)
Setting permissions on /system/xbin/bash4.2.0.1
Setting different instalation shell scripts to be used...
about to run program [/sbin/sh] with 2 args
Creating 'b' shell excutable file for quick launching BASH
in /system/bin/
run_program: child exited with status 1
Created '/system/bin/b'
Creating symlink for BASH as /system/bin/bash
Setting permissions on directories:
/system/etc/terminfo
Setting permissions for /system/etc/bash.bashrc
and /system/etc/profile
Creating symlink for BASH as /system/xbin/bash
Settings '/data/local' owner to UID to 0 (root) and GID to 2000 (shell)
Settings '/data/local' owner to UID to 0 (root) and GID to 2000 (shell)
Settings permissions on '/data/local/bin' to 0755 (a=rwx)
Settings permissions on '/data/local/sbin' to 0755 (a=rwx)
Settings permissions on '/data/local/xbin' to 0755 (a=rwx)
Settings permissions on '/data/local' to 0755 (u+rwx,go+rx)
set_perm: chown of /data/local/.bash_history to 0 2000 failed: No such file or directory
set_perm: chmod of /data/local/.bash_history to 666 failed: No such file or directory
script aborted: set_perm: some changes failed
Settings permissions on '/data/local/.*' to 0666 (a=rw)
set_perm: some changes failed
E:Error executing updater binary in zip '/sdcard/Bash4.2.x-Installer(Nexus4)-v1.1.zip'
Error flashing zip '/sdcard/Bash4.2.x-Installer(Nexus4)-v1.1.zip'
Updating partition details...
Iata backup size is 2098MB, size: 13231MB, used: 8904MB, free: 4326MB.
I:Unable to mount '/usb-otg'
I:Actual block device: '', current file system: 'vfat'
I:Set page: 'flash_done'
I:Set page: 'clear_vars'
I:Set page: 'main2'
I:Set page: 'settings'
I:Set page: 'main'
I:Set page: 'clear_vars'
I:Set page: 'main2'
I:Set page: 'advanced'
I:Set page: 'confirm_action'
I:Set page: 'action_page'
I:Copying file /tmp/recovery.log to /data/media/0/recovery.log
Click to expand...
Click to collapse
Thank you for your help!

@dmagician thank you for the update. i just noticed the zip files contains ssh, scp, vim, nano, 7z and more :good::good: thats really aewsome!
i took a look at the scripts and i can't find anywhere a reference to these files.
Code:
/data/local/.bash_history
/data/local/.editor
/data/local/.inputrc
/data/local/.minttyrc
i need your help configuring bash. if i start bash from the default shell with "bash" the profiles is not loaded. is it possible to "symlik bash to "bash -l"? the
@Grushteniak
easiest quick fix
open terminal add this commands:
Code:
su
cd /data/local/
touch .editor
touch .inputrc
touch .minttyrc
after that flash the zip again

Worked now
@UnitedOceanic
I have created the files you asked and I had to create the '.bash_history' file too.
After that, successfully flashed it. Thank you for your help!

UnitedOceanic said:
@dmagician thank you for the update. i just noticed the zip files contains ssh, scp, vim, nano, 7z and more :good::good: thats really aewsome!
i took a look at the scripts and i can't find anywhere a reference to these files.
Code:
/data/local/.bash_history
/data/local/.editor
/data/local/.inputrc
/data/local/.minttyrc
Click to expand...
Click to collapse
These are mainly not required (I think I've packed them accidentally...), the files .bash_history and .editor are created automatically, so all of these can be safely deleted (from the device).
I will remove then sometime later - when I'll have some free time - from the ZIP...
UnitedOceanic said:
i need your help configuring bash. if i start bash from the default shell with "bash" the profiles is not loaded. is it possible to "symlik bash to "bash -l"? the
Click to expand...
Click to collapse
1st:
You can't...
Unless it is a multi-call binary like BusyBox (I'm not Linux expert... but as of my understanding -- By far: Any EXPERT that knows Linux better than me, PLEASE: Correct me if I'm wrong) -- You cannot link a binary with its switches in any way...
You can only link the the binary itself, any command line switch should be via the command line or shell script.
2nd:
There should be a small executable shell script named “b” located in /system/bin/ (its whole target is executing “/system/xbin/su -c /system/bin/bash --login” -- for ease of running and saving some taps).
Check if it exists, as the installer itself SHOULD have created it.
In case the file does not exist, you can try the following:
Open terminal emulator - any of those are good:
If you don't have any terminal emulator installed and/or don't want to install one...
ADB shell
PuTTY Tray - by Chris West (Faux):good:<--strongly recommended
If you have one installed already, open it.
If you don't have any (and/or you want one to be always available to you), IT'S TIME TO GET ONE
Open Google Play Store and search "terminal emulator", pick one and install it.
Then execute (one by one):
In case of using ADB command (option 1 listed above)
Code:
adb root
adb remount
In case of using terminal emulator (e.g. any one of options 2 or 3 as listed above)
Code:
su
mount -o remount,rw /system
and the rest: (if using ADB (e.g. option 1 listed above), prefix the commands with "adb shell" noobs: [no quotes, and with trailing space])
Code:
cd /system/bin
rm /system/bin/b
echo '#!/system/bin/sh' > /system/bin/b
echo '/system/xbin/su -c /system/bin/bash --login' >> /system/bin/b
chown 0.0 /system/bin/b
chmod 0755 /system/bin/b
remount -o remount,ro /system
exit
In some (pretty rare - I believe...) cases, you may need to add /sbin/busybox or /system/xbin/busybox
before the commands above:
As exmple, line 3:
instead of echo '#!/system/bin/sh' > /system/bin/b would be something like
/system/xbin/busybox echo '#!/system/bin/sh' > /system/bin/b​OR
/sbin/busybox echo '#!/system/bin/sh' > /system/bin/b​
UnitedOceanic said:
easiest quick fix
open terminal add this commands:
Code:
su
cd /data/local/
touch .editor
touch .inputrc
touch .minttyrc
after that flash the zip again
Click to expand...
Click to collapse
If so, (and I'm not sure of it because you are basically extracting files from a ZIP archive to location and then executing commands over them... BUT I'm neither Linux nor Edify expert... Enlightments, Corrections and Learning new things ARE ALWAYS welcome!), It is good to know that executing touch on the files will cause the installer to forcibly update them...
You meant "execute these commands" not "add this commands" -- right?
Sorry, I've misunderstood -- You ware CREATING the file by the touch command, NOT CHANGING DATE/TIME....

Could I ask what does this do? Isnt this the same thing that we can have using terminal emulator?

bamsbamx said:
Could I ask what does this do? Isnt this the same thing that we can have using terminal emulator?
Click to expand...
Click to collapse
It is not related to terminal emulator itself, but to the underlying Android shell layer.
To be specific:
It is adding SOME of the advanced BASH style capabilities to Android's shell scripting.
SOME - since not ALL (as I remember, but the most important and used, do exist) - of bash capabilities are implemented in this (small) binary.
It is an alternative to the Android's basic shell.

dmagician said:
It is not related to terminal emulator itself, but to the underlying Android shell layer.
To be specific:
It is adding SOME of the advanced BASH style capabilities to Android's shell scripting.
SOME - since not ALL (as I remember, but the most important and used, do exist) - of bash capabilities are implemented in this (small) binary.
It is an alternative to the Android's basic shell.
Click to expand...
Click to collapse
Thanks for the quick reply!!!
I do not understand too much about linux...
Could you tell me some examples of how this would benefit us??
Thanks

bamsbamx said:
Thanks for the quick reply!!!
I do not understand too much about linux...
Could you tell me some examples of how this would benefit us??
Thanks
Click to expand...
Click to collapse
It is mainly used by users - some may add - who've rooted their devices, - and ment as a low level for doing stuff that cannot be done via GUI (graphical user interface).
This is what you probably know as "hacking" - not necessarily for doing bad suff,
but for low level control of the device or for learning purposes.

Related

[Script] App/Data Backup

Hello all,
I have updated the script further to allow for arguments to be accepted as well as having the script placed in /system/bin. This works pretty much like Titanium Backup except that it's a script and uses a CLI. No pretty GUI . You can backup, restore, and fix app and data permissions from this script. 'fix_permissions' is embedded within this script and it will be install in the /system/bin folder if the startup script does not already find it. The script does not really work like an Apps2SD other than it backs up apps from /data/app and their appropriate data folders from /data/data.
This script can be very useful when switching between ROMs as your app and data can be reinstalled with the script's restore feature.
The script currently looks for APKs to backup from /data/app, /data/app-private, and /mnt/asec.
My first creation of this script was based upon a modified version of Firerat's Apps2SD script so naturally many thanks goes to him. Also the fix_permissions script comes from Koush and the Cyanogen Team.
No EXT partition required! Just download the file and run on an Android device.
STEPS:
1. Put the attached file on your SD card and run. It will install app_backup to /system/bin. From there you can type the following to start the program:
Code:
app_backup
Here's an example of backing up a couple apps with a data backup:
Code:
C:\Users\zlippard\Documents>adb shell
# app_backup
app_backup
Welcome to AppBackup 1.1
OPTIONS
--------------------------------
'b' to backup
'r' to restore
'f' to fix all app permissions
'd' to delete app_backup folder
'x' to reboot
'q' to quit: b
b
Creating app list to /dev/applist.txt...
Done!
[1] sd com.DefiantDev.RocketBunnies
[2] sd com.rovio.angrybirds
[3] sd com.rovio.angrybirdsseasons
[4] sd sts.pl
[5] app android.tether
[6] app com.alfray.timeriffic
[7] app com.androidemu.gbalite
[8] app com.aurorasoftworks.quadrant.ui.standard
[9] app com.batterypoweredgames.lightracer3dbasic
[10] app com.bfs.papertoss
[11] app com.chase.sig.android
[12] app com.chung.compasslevel
[13] app com.citrix.Receiver
[14] app com.facebook.katana
[15] app com.faziklogic.scripter
[16] app com.fede.launcher
[17] app com.forthegamer.android.scheduler
[18] app com.google.android.apps.chrometophone
[19] app com.google.android.apps.googlevoice
[20] app com.google.android.apps.maps
[21] app com.google.android.apps.unveil
[22] app com.google.android.carhome
[23] app com.google.android.gm
[24] app com.google.android.stardroid
[25] app com.google.android.street
[26] app com.google.android.voicesearch
[27] app com.google.android.youtube
[28] app com.google.zxing.client.android
[29] app com.gravitymobile.app.hornbill
[30] app com.icenta.sudoku.ui
[31] app com.intuit.instantreturn
[32] app com.intuit.instantreturn.filing.key
[33] app com.joelapenna.foursquared
[34] app com.koushikdutta.rommanager.license
[35] app com.metago.astro
[36] app com.mhuang.overclocking
[37] app com.mobitv.client.nfl2010
[38] app com.pandora.android
[39] app com.paypal.android.p2pmobile
[40] app com.shazam.android
[41] app com.sirma.mobile.bible.android
[42] app com.southwestairlines.mobile
[43] app com.sporadicsoftware.NetQFree
[44] app com.twitter.android
[45] app com.verizon.ams.companion
[46] app com.verizon.android.wifios
[47] app com.vzw.hss.myverizon
[48] app com.zebdor.android.poolCare
[49] app net.flixster.android
[50] app net.rbgrn.lightracer
[51] app org.connectbot
[52] app org.coolcode.emuroms
[53] app ru.orangesoftware.areminder
Enter app #'s to backup or 'a' for all and press [ENTER].
Or 0 to exit (ex: 1 5 15): 1 3 4
1 3 4
Copy data? ('y' or 'n') y
y
1 of 3] - Backing up com.DefiantDev.RocketBunnies...Done!
2 of 3] - Backing up com.rovio.angrybirdsseasons...Done!
3 of 3] - Backing up sts.pl...Done!
OPTIONS
--------------------------------
'b' to backup
'r' to restore
'f' to fix all app permissions
'd' to delete app_backup folder
'x' to reboot
'q' to quit: q
q
Goodbye!
#
When starting the script, you will be brought to the main menu screen where you can choose to either backup, restore, fix permissions, delete /sdcard/app_backup (this is the storage folder), reboot or quit. The rest is pretty self explanatory...
So far I have tested this script on the DROID and DROID Incredible. The DROID was running Bugless Beast 2.2 and the Inc I've tried ran CM6 and CM7.
UPDATES:
1.4
Added "busybox " before each command call within the app_backup script to make sure busybox commands are being called.
1.3
Fixed issue with backup apps not showing up. Thanks to welcomb for notifying me.
Fixed mounting issue for ro/rw in /system
1.2
Fixed backup feature for phones that use Apps2SD. Thanks to welcomb.
Fixed deletion feature of apps and data.
1.1
Arguments: use -b to auto-run a full backup. -r will auto-run a full restore of all apps in android_app_backup
Apps and data are now stored in /sdcard/android_app_backup.
app_backup script is now automatically installed to /system/bin/app_backup when running the new script. The new script is more of an installer.
Let me know of any bugs!
Much of the credit goes to Firerat for creating the initial apps2sdext script. This is what gave me the idea to continue on with an app backup script. Here's Firerat's latest version of apps2sdext in case you want to see it or don't have an incredible: http://forum.cyanogenmod.com/topic/...mount-issues-i-hope/page__p__24386#entry24386
As the usual goes, I'm not responsible for any mishaps that may occur while using this script or bricked phones, data loss, blah blah blah... So, USE AT YOUR OWN RISK.
The script is attached below. Have fun! Please post any findings, bugs, questions, comments, or updates you would like to see here. Feel free to make any modifications to this script.
NOTE TO SAMSUNG RELAY 4G USERS:
A friend of mine has this phone and was getting the following error when running the .sh script:
Code:
can't create temporary file /sqlite_stmt_journals/mksh.<random>
To remedy this, I remounted the root directory / as read-write,created the folder /sqlite_stmt_journals, ran the .sh script, and afterwards remounted to read-only.
anyone tried this? lots of success of nexus one
For future use...
zebdor44 said:
Hello all,
I have modified my script to be more of an app & data backup utility. This works pretty much like Titanium Backup except that it's a script and uses a CLI. No pretty GUI . You can backup, restore, and fix app and data permissions from this script. 'fix_permissions' is embedded within this script and it will be install in the /system/bin folder if the app_backup.sh script does not already find it. Since this is a complete revision, I have set the version back to 1.0. The script does not really work like an Apps2SD other than it backs up apps from /data/app and their appropriate data folders from /data/data.
This script can be very useful when switching between ROMs as your app and data can be reinstalled with the script's restore feature.
The script currently looks for APKs to backup from /data/app, /data/app-private, and /mnt/asec.
<...>
Click to expand...
Click to collapse
This is SO much easier than Titanium, and I am trying to figure out how to automate backup / restore. My end goal:
Run a Nandroid
Run this script (in Backup mode)
Wipe userdata
Install Rom
Install extras (kernel, Gapps, etc)
Restore apps.
Anyone want this?
If people are interested, I may take a look into this.
Woooow, nice work man =]
I was gonna write something really simple, but you beat me to it! Thanks!
EDIT: ooppps, didn't mean that your script was simple! I meant that you beat me to an app backup script, and yours would blow mine out of the water xD
I'm a bit busy right now (haha, but not too busy to post... ), but does anyone know if this supports restoring apps only? I feel like it probably does, but can anyone confirm?
Again, this looks awesome!
Thanks guys for the comments!! Good to hear you like it
alanthemanofchicago said:
This is SO much easier than Titanium, and I am trying to figure out how to automate backup / restore. My end goal...
Click to expand...
Click to collapse
Let me try making an update.zip that'll run the script. Then you could run the update.zip in recovery mode like CWM or AmonRa.
gmichaelow said:
Woooow, nice work man =]...but does anyone know if this supports restoring apps only? I feel like it probably does, but can anyone confirm?
Click to expand...
Click to collapse
The script will restore apps and their data folders. Basically what it does is it reinstalls the app that you selected to restore and then overwrites the appropriate /data/data folder for that app with the backup.
Automating backups and restores
So it seems it may not be that easy to create an update.zip that will work properly. The script will need to mount /system, /data and /datadata to access the apks and data folders while in recovery. That's not difficult to do but apps on the sdcard under /mnt/asec may prove to be a little more difficult. I made a working update.zip that would run 'app_backup -b' to automate the process but there is no output of script so I have not posted that. The output would be kinda nice to see just so you know how far along the backup process is at.
I may need to dig deeper on the update.zip but for now check out the updates!
Thanks!
After finally getting the script into /system and running it, it doesn't work. I get the output:
Code:
[: not found
[: not found
[: not found
Ok nevermind!
Goodbye!
Using a rooted Samsung Galaxy 3. I'm still very new to custom ROMs, etc.
Hi
I get the following error when trying to backup on my Samsung Galaxy S :
data/system/packages.xml no such file or directory
Nothing to backup
What can i do?
Skele Drew said:
After finally getting the script into /system and running it, it doesn't work. I get the output:
Code:
[: not found
[: not found
[: not found
Ok nevermind!
Goodbye!
Using a rooted Samsung Galaxy 3. I'm still very new to custom ROMs, etc.
Click to expand...
Click to collapse
FadeFx said:
Hi
I get the following error when trying to backup on my Samsung Galaxy S :
data/system/packages.xml no such file or directory
Nothing to backup
What can i do?
Click to expand...
Click to collapse
Hmm... If you have Astro lookup /data/system and see if the packages.xml file exists. Better yet, if you have a terminal emulator or ADB do a
Code:
ls /data/system | grep packages.xml
and see if anything comes up. The Galaxy series should have the same file system structure as any other Android phone... What Android OS are you running?
EDIT: It looks like the Galaxy series is using 2.2... Also if one of you could do a
Code:
su
cd /
find -name packages.xml
find -name packages.list
within a terminal emulator or ADB this should show where the packages files are located. It may take a bit of time to do the search since its looking for it from /.
./dbdata/system/packages.xml
find -name packages.list does search forever it seams...
Ok I might have to update the script to look in that directory for the packages.xml file. Stay tuned! Sorry for the delay in getting back. Been pretty busy.
EDIT: Download Busybox Installer from the market (the free one) and try installing the latest busybox for your samsung phone and then try running the script again. Does the script seem to act any better? I'm thinking the :not found] issue has to do with a bad busybox and the script not finding the right commands it needs to use. Let me know how that turns out.
Remember to nandroid backup before installing the busybox just in case
Busybox version is 1.19.0 but i didn't try the script yet. Will when i come home...
FadeFx said:
Busybox version is 1.19.0 but i didn't try the script yet. Will when i come home...
Click to expand...
Click to collapse
Just curious, any luck with the busybox upgrade?
I've updated the script to version 1.3. Welcomb noticed that there was an issue with bringing up the apps when requesting a backup although I'm not sure if that will fix the issue you had Fade...
Also mounting /system to copy the script over should be fixed .
I've added this to the OP already but for those with a Samsung Relay 4G phone:
A friend of mine has this phone and was getting the following error when running the .sh script:
Code:
can't create temporary file /sqlite_stmt_journals/mksh.<random>
To remedy this, I remounted the root directory / as read-write,created the folder /sqlite_stmt_journals, ran the .sh script, and afterwards remounted to read-only.
Is this still going?
I'm getting "There is nothing to backup" in CM11. I'm on the appropriae line fo the script but I can't figure out what's wrong.
So, this is the only script I found to backup and restore app data.
Needs some changes for newer android OS
Needs a check, as out of the box toybox is used, not busybox
Mount point needs something:
As
Code:
# busybox grep /system /proc/mounts | busybox awk '{print $1}'
/dev/block/bootdevice/by-name/system
/dev/block/bootdevice/by-name/system
It is doubled.
Removing $DEVICE seems to work. I removed $DEVICE from all mount commands:
From:
Code:
$MOUNT -o remount,rw $DEVICE /system
To:
Code:
$MOUNT -o remount,rw /system
backup needs a fix for app list
$EGREP "^< seems to cause issues. I removed ^ and it worked, meaning applist success.
I was able to backup data, but the apks were missing. Maybe because it used to be app.apk now it is base.apk?
restore does not work at the moment
As applist returns empty. Checked /dev/applist.txt and it was empty for some reason.
Also, fix_permissions file not in some devices, /dev/fix_permissions not found.
Some issues:
Code:
{system("busybox cat /data/system/packages.list | busybox grep $2")}
causes errors
Some errors when creating applist, but apps are displayed afterwards. So, might be same issue as above
Code:
Creating app list to /dev/applist.txt...
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
sh: /data/system/packages.list: can't execute: Permission denied
Done!
[1] app a...
[2] app a...
[3] app c...
...
[35] app o...
[36] app o...
[37] app o...
[38] app o...
[39] app o...
[40] app x...
Last thing is that the commands used to generate applist
Code:
$ECHO "Creating app list to /dev/applist.txt..."
$CAT /data/system/packages.xml | $EGREP "<package.*serId" | $GREP -v framework-res.apk | \
$GREP -v com.htc.resources.apk | $SED 's/<package name=\"//' | $SED 's/\" codePath="/ /' | \
$SED 's/\"//g' | $SED -e 's/\/data\/app-private\//private /' | $SED 's/\/data\/app\//app /' | \
$SED 's/\/system\/app\//system /' | $SED 's/\/mnt\/asec\//sd /' | \
$AWK '{if($2 !~ /system/) printf "%10s %s %s",$2,$1,$3"\n"}' | sort | \
$AWK '(++count) {printf "%5s %7s %s %s\n","["count"]",$1,$2,$3} \
{system("$CAT /data/system/packages.list | $GREP $2")}' | $SED 's/\/data\/data\///' | \
$AWK '{printf "%5s %7s %s %s %s\n",$1,$2,$3,$4,$8}' > $applist
causes some errors, even though apps are displayed at the end:
Code:
BusyBox v1.22.1 bionic (2017-04-22 22:10 +0300) multi-call binary.
Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...
Search for PATTERN in FILEs (or stdin)
-H Add 'filename:' prefix
-h Do not add 'filename:' prefix
-n Add 'line_no:' prefix
-l Show only names of files that match
-L Show only names of files that don't match
-c Show only count of matching lines
-o Show only the matching part of line
-q Quiet. Return 0 if PATTERN is found, 1 otherwise
-v Select non-matching lines
-s Suppress open and read errors
-r Recurse
-i Ignore case
-w Match whole words only
-x Match whole lines only
-F PATTERN is a literal (not regexp)
-E PATTERN is an extended regexp
-m N Match up to N times per file
-A N Print N lines of trailing context
-B N Print N lines of leading context
-C N Same as '-A N -B N'
-e PTRN Pattern to match
-f FILE Read pattern from file
cat: write error: Broken pipe
BusyBox v1.22.1 bionic (2017-04-22 22:10 +0300) multi-call binary.
Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...
Search for PATTERN in FILEs (or stdin)
-H Add 'filename:' prefix
-h Do not add 'filename:' prefix
-n Add 'line_no:' prefix
-l Show only names of files that match
-L Show only names of files that don't match
-c Show only count of matching lines
-o Show only the matching part of line
-q Quiet. Return 0 if PATTERN is found, 1 otherwise
-v Select non-matching lines
-s Suppress open and read errors
-r Recurse
-i Ignore case
-w Match whole words only
-x Match whole lines only
-F PATTERN is a literal (not regexp)
-E PATTERN is an extended regexp
-m N Match up to N times per file
-A N Print N lines of trailing context
-B N Print N lines of leading context
-C N Same as '-A N -B N'
-e PTRN Pattern to match
-f FILE Read pattern from file

[INFO] Edify scripts in CWM recovery

Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Intro
Inside your typical CWM zip there is a folder called META-INF, inside that there is a folder called com and come CERT files, inside that com folder there is a google folder, inside that is an android folder containing an update-binary file and an updater-script. If you only see an update-script, that means you are back in the Android 1.5 era and need to move on.
The updater-script
The updater-script file is a text file, it is linux formatted with regard to end of line conventions. If you use Windows then you have to edit the file using a program that keeps line feeds the way they are and has options for doing the conversion from <CR><LF> to just <LF>.
Like lisp, the contents of the text file evaluate to one big expression, but it does have the ";" end of command convention to make things more familiar, it just means perform the action on the left. (ref. google source README) You can ignore that and just treat everything as a series of commands for all practical purposes. I mention it because you need not worry about having too large a procedural block or worry about having extra spaces or worry about ending on a line boundary. You could have your entire script on one giant line and it wouldn't matter.
There are around a dozen commands, it's not terribly difficult to learn.
The updater-binary
There are a lot of updater-binary files out there in the wild, each manufacturer basically compiles there own with every other OTA update. Success in flashing your CWM zip is determined by picking the right one that works with what you are trying to do. If your knowledge says mount needs 4 arguments and the binary only supports 3, then you need to change your script to use 3 and vice versa. If you are trying to flash a radio, the updater-binary might have been recompiled to allow for that specific functionality and you will get a status 6 error when trying to flash it unless you use that update-binary. You will see the write_raw_image() function not supporting "/dev/block/mmcblk0p8" but instead "logo.bin".
However, by and large, the generic functionality is the same across the board.
​Updater-script functions (In order of interest)​
ui_print(msg1, .. msgN); This is the means you have to display something on the screen in CWM, it takes a series of comma separated arguments, each comma needs to have a space after it, this applies to all commands.
Ex. ui_print("Your version is: ", file_getprop("/system/build.prop", "ro.build.id"));
show_progress(TOTALAMOUNT, TIMEINSEC); This command and the following command control what you see in the progress bar at the bottom. It is not necessary to use it, it's just another way to display information.TIMEINSEC refers to how long it will take for the progress bar to move to the AMOUNT specified. You would use this perhaps when something is taking a long time, you know approximately how long and want the screen to keep showing something while it is going on. If you use zero for TIME then nothing is done, you have just set the maximum amount for use with set_progress. The amount is a decimal number, 0.5 would be half the progress bar being filled.
Ex. show_progress("0.300000", 10);
set_progress(AMOUNT); This command sets the pointer or fill amount of the progress bar according to the last show_progress command. It should never be greater than the total of the show_progress amount.
Ex. show_progress("0.300000", 0);
set_progress("0.15");
mount(TYPE, DEV, PATH); This is one version of the mount command. The TYPE arg is usually "MTD", which refers to memory technology device. The DEV for a MTD would be something like "system", "userdata", "cache", and the PATH would be "/system", "/data", or "/cache". You will also see TYPE be "vfat".
mount(FSTYPE, TYPE, DEV, PATH); This seems to be the more current mount command. It adds in the file system type. Ex. "ext3", "yaffs". TYPE with this command can be "MTD" or "EMMC". You would use "EMMC" with "/dev/block/mmcblk0p8".
umount(PATH); This simply removes a previous mounted PATH from the system. Ex. umount("/system"); You'll notice the double quotes around command arguments, they are not strictly necessary. Unless it's a reserved word (if then else endif) then they can be anything. "consisting of only letters, numbers, colons, underscores, slashes, and periods". So if you just spend 10 minutes uploading your zip to your phone and notice that your unmount command is umount(/system);, it will work just fine.
sleep(SECS); Simply pauses for SECS seconds.
package_extract_file(FILE, FILEWITHPATH); This command extracts one of your files from the CWM zip package and save it to the phone.
Ex. package_extract_file("bootanimation.zip", "/system/media/bootanimation.zip");
package_extract_dir(ZIPPATH, PATH); This command extracts an entire folder in your CWM zip to a folder on your phone.
Ex. package_extract_dir("system", "/system"); *This is where having system mounted would be handy, without it being mounted, the files would be copied to the ramdisk /system.
write_raw_image(PATH, PARTITION); This is one of those tricky ones, the PATH is somewhere on your phone with the image to be flashed to a PARTITION on your phone. The trouble is, how do you specify what partition gets flashed? Is there any restriction on where the file has to be? If MTD conventions are used, you are looking for "system", "boot", "recovery", "logo.bin". (All this means that each partition has a name stored somewhere, and if you know it, you can write to it.) Maybe it will accept device references like /dev/block/mmcblk0p8. This depends on the update-binary file you are using.
Ex. write_raw_image("/tmp/logo.bin", "logo.bin");
Ex. write_raw_image("/tmp/logo.bin", "/dev/block/mmcblk0p8");
write_firmware_image(PATH, PARTITION); You would think it would be the same as write_raw_image. Not sure what the difference is.
run_program(PROG, ARG1, .., ARGN); Pretty self explanatory, This command allows you to execute a program or script on the phone. Instead of all the bits of the command being separated by spaces, commas are used. It returns an error code as a string.
Ex. run_command("ls", "-R", "/system");
Assert(condition); You'll see this one a lot in OTA updates, all it does is abort the script if something goes wrong. If condition is false, the script ends displaying a description on the phone of what command caused the exit. You can put in more than one statement here, separated by ";", if any one of them returns with an error, the script exits.
Ex. Assert(mount("ext3", "EMCC", "/dev/block/mmcblk0p12", "/system")); *If you can't mount /system and your CWM zip only writes to system, you might as well stop it before continuing on to write to the ramdisk.
ifelse(condition, true path, false path); This is your basic conditional statement, the tricky bit is to figure out what statements in edify can trigger a true of false condition. As for the rest of it, the commas separate the two blocks.
Ex. ifelse(file_getprop("/system/default.prop", "ro.build.id") == "OLYFR1.2.3.4", ui_print("yes"), ui_print("false"));
abort(); This stops the script, useful with ifelse.
file_getprop(PATH, VALUE); This command looks for a text file containing A=B pairs and returns B if it can find an A.
Ex. file bob.txt exists in /tmp, it contains cool=yes, and dorky=true123 each on separate lines.
file_getprop("/tmp/bob.txt", "cool") == "yes"
file_getprop("/tmp/bob.txt", "dorky") == "true123"
getprop(VALUE); Functions the same as file_getprop, without the file part. It looks through the system value pairs for a matching value.
Ex. getprop("ro.build.id") == "OLYEM1.2.3.4"
delete(PATH1, ...,PATHN); Nothing to see here, just a delete command, full path to the file(s) as argument(s).
delete_recursive(PATH1, ...,PATHN); It's a delete everything in a folder, including subfolders command. The folder itself is deleted as well.
set_perm(UID, GID, MODE, PATH1, ..., PATHN); Set the linux permissions on a file, ownership and flags at the same time. Equivalent to chown and chmod in the one command.
Ex. set_perm(0, 0, 06755, /system/bin/su, /system/bin/shsu); *0 stands for root, so it would be owned by root, of the group root, with suid bit set and standard executable bits set.
set_perm_recursive(UID, GID, DIRMODE, FILEMODE, PATH1, ...,PATHN); Same as above except with folders instead of files. Use the DIRMODE to set the permissions and ownership of the folders themselves, and FILEMODE to set the permissions of the files within them.
symlink(TARGET, LINK1, ...,LINKN); It's the equivalent to the linux ln -s command. For our purposes, it might as well be called busybox install.
Ex. symlink("/system/bin/busybox", "/system/bin/awk", "/system/bin/wget", "/system/bin/sed");
To Be Continued..
​
References
http://devphone.org/development/edify-script-syntax-explained/
http://www.synfulgeek.com/main/index.php/articles/76-scratchpad-documenting-edify-commands-for-android-updater-scritps-based-off-of-kernel-source-code
https://github.com/koush/android_bootable_recovery/blob/eclair/edify/README
http://tjworld.net/wiki/Android/UpdaterScriptEdifyFunctions​
Tips:
You can use the abort() command to step through your updater script, for instance if you wanted to check various combinations on syntax for write_raw_image();
In /tmp there is a text file called recovery.log, do a cat /tmp/recovery.log to see extra output of your script from failed commands.
NFHimself said:
The updater-script file is a text file, it is linux formatted with regard to end of line conventions. If you use Windows then you have to edit the file using a program that keeps line feeds the way they are and has options for doing the conversion from <CR><LF> to just <LF>.
Click to expand...
Click to collapse
If you are in windows, I have found that notepad++ does the job just fine.
http://notepad-plus-plus.org/
what about the FORMAT command?
actually i have error on a CM installation, its says
Code:
format() expects 3 args, got 2.
but my format command have 3 args:
Code:
format("ext4", "/dev/block/mmcblk0p10", "/system");
NFHimself said:
Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Intro​
Click to expand...
Click to collapse
Thanks for this... but I do have a question....
I am attempting to see if busybox is installed on a device, and if not install it, or proceed
so, so far I have:
Code:
ifelse(
BUSYBOX DOESNT EXIST,
(
ui_print("* Did not find it. Installing...");
set_perm(0, 1000, 0755, "/system/xbin/busybox");
symlink("/system/xbin/busybox", "/system/bin/busybox");
run_program("/system/xbin/busybox", "--install", "-s", "/system/xbin");
),
(
ui_print("* Found it. Proceeding...");
)
);
You can see where I'm lost I was thinking of using assert to run_program("/system/xbin/busybox", "vi", "/system/xbin"); just as a simple check... but from what I can see, if the assertion fails it will stop the script, and print out the failure message, which of course is not what I am after here... or maybe I am, can it be used to do a check rather than stop the script?​
Just an idea (ie. untested):
Code:
ifelse(
run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox")
...
)
ravilov said:
Just an idea (ie. untested):
Code:
ifelse(
run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox")
...
)
Click to expand...
Click to collapse
trying to run that in adb sheel, and don't get a response, but it does seem like a good idea... I assume Edify would return a 1/0 or true/false string from it, and I can just check for that?
EDIT: Maybe I do get something back... after running that in adb shell my next line looks like the following:
Code:
1|[email protected]:/ #
Am I right in assuming that "1" is the output?
Yes. The command won't ever return any output, it only returns the exit status. Your shell is obviously set so it includes a non-zero exit status in the prompt. (Non-zero traditionally means error.)
ravilov said:
Yes. The command won't ever return any output, it only returns the exit status. Your shell is obviously set so it includes a non-zero exit status in the prompt. (Non-zero traditionally means error.)
Click to expand...
Click to collapse
that prompt means that the test failed, and I don't have busybox installed?
I'm just a tad confused... (this is my first full-on edify script), and I do have busybox installed
I appreciate the help, and once I get my tapatalk working right on my phone, I'll give ya all the "thanks" for the help with this
Eh... everything I 'test' returns the same thing
Code:
1|[email protected]:/ #
Hm, weird. It works for me...
Code:
# /system/bin/sh -c 'test -e /system/xbin/busybox'; echo $?
0 [color=silver]<-- no error - file exists[/color]
# /system/bin/sh -c 'test -e /system/xbin/busybox1'; echo $?
1 [color=silver]<-- error - file does not exist[/color]
I didn't try it in an edify script because I don't feel like rebooting my phone right now, but I don't see why it wouldn't work.
Try running the "sh -c test ..." command in adb shell while in recovery and see what happens.
Also, just a side note: backslash is NOT the same as slash. If you are going to write shell/edify scripts, you need to know at least that distinction. That is why your
Code:
tags are not working right.[/b][/i][/size]
ravilov said:
Hm, weird. It works for me...
Code:
# /system/bin/sh -c 'test -e /system/xbin/busybox'; echo $?
0 [color=silver]<-- no error - file exists[/color]
# /system/bin/sh -c 'test -e /system/xbin/busybox1'; echo $?
1 [color=silver]<-- error - file does not exist[/color]
I didn't try it in an edify script because I don't feel like rebooting my phone right now, but I don't see why it wouldn't work.
Try running the "sh -c test ..." command in adb shell while in recovery and see what happens.
Also, just a side note: backslash is NOT the same as slash. If you are going to write shell/edify scripts, you need to know at least that distinction. That is why your
Code:
tags are not working right.[/b][/i][/size][/QUOTE]
I see, I wasn't doing the echo, and what you posted shows exactly what you posted. DOH on the CODE :good:
So I have it on record (for my own personal reference)
[CODE]
ifelse(
((run_program("/system/bin/sh", "-c", "test -e /system/xbin/busybox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/bin/busybox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/xbin/busibox; echo $?") == 1 ||
(run_program("/system/bin/sh", "-c", "test -e /system/bin/busibox; echo $?") == 1),
(
ui_print("* Did not find it. Installing...");
set_perm(0, 1000, 0755, "/system/xbin/busybox");
symlink("/system/xbin/busybox", "/system/bin/busybox");
run_program("/system/xbin/busybox", "--install", "-s", "/system/xbin");
),
(
ui_print("* Found it. Proceeding...");
)
);
and yes, I meant the 'busibox' part, because I have seen that in some roms
Click to expand...
Click to collapse
You guys know way more about this stuff than I do... although i am a programmer
could I get some insight over here: http://forum.xda-developers.com/showthread.php?t=2796055
having an issue getting my shell scripts to actually run...
Rockin' it from my Smartly GoldenEye 35 NF1 (muchas gracias:* @iB4STiD @loganfarrell @muniz_ri @Venom0642 @ted77usa @rebel1699* @iB4STiD) ~ 20GB free cloud https://copy.com?r=vtiraF
Check me out online @ http://kevin.pirnie.us
note: the scripts do run in adb shell
published API docs
NFHimself said:
Hi, I haven't seen any good resources for how to edit edify scripts, so I thought I would create this thread so we can pool our knowledge on the subject.
Click to expand...
Click to collapse
I found some official documentation of the API on the Android Web site here:
https://source.android.com/devices/tech/ota/inside_packages.html
NFHimself said:
[*]write_raw_image(PATH, PARTITION); This is one of those tricky ones, the PATH is somewhere on your phone with the image to be flashed to a PARTITION on your phone. The trouble is, how do you specify what partition gets flashed? Is there any restriction on where the file has to be? If MTD conventions are used, you are looking for "system", "boot", "recovery", "logo.bin". (All this means that each partition has a name stored somewhere, and if you know it, you can write to it.) Maybe it will accept device references like /dev/block/mmcblk0p8. This depends on the update-binary file you are using.
Ex. write_raw_image("/tmp/logo.bin", "logo.bin");
Ex. write_raw_image("/tmp/logo.bin", "/dev/block/mmcblk0p8");
[*]write_firmware_image(PATH, PARTITION); You would think it would be the same as write_raw_image. Not sure what the difference is.
Click to expand...
Click to collapse
I didn't do a line by line comparison between your description and theirs, but I noticed this part because I was trying to find information about these functions. Only write_raw_image() is a published API function. This is the description:
write_raw_image(filename_or_blob, partition)
Writes the image in filename_or_blob to the MTD partition. filename_or_blob can be a string naming a local file or a blob-valued argument containing the data to write. To copy a file from the OTA package to a partition, use: write_raw_image(package_extract_file("zip_filename"), "partition_name");​
Probably write_firmware_image() is used internally. It could be removed at any time, or it even could be a stub - not a good idea to use it.

How to install ubuntu on the Droid 4

How to install ubuntu on the Droid 4
Note to mods: this thread is a branch off of this thread
Huge thanks to zacthespack for creating the ubuntu installer app and original boot script and to zeroktal for modifying the script to work on the D4 and helping me get it working on my device.
I decided to take my experience in setting this up and put it into a how-to so that others could enjoy the experience of having ubuntu on the Droid 4. If zackthespac or zeroktal have any problems with me making and putting this guide up, please let me know and I will remove it.
Knowledge Required:
working knowledge of command line
working knowledge of vi
OR the ability to learn how to use both
Tools Required:
A rooted Motorola Droid 4
BusyBox (Android Market)
Terminal Emulator (Android Market)
Android VNC Viewer (Android Market)
Ubuntu Installer App (Android Market)
zeroktal's ubuntud4.zip file (attached to this post and mediafire)
Vi Cheat Sheet (lagmonster.org)
Step by Step:
Install BusyBox, Terminal, and Android VNC Viewer
Install and run Ubunutu Installer App
Follow the on-screen instructions and click next
Download either the Small or Large image to your phone, (use zeroktal's ubuntud4.zip file instead of the boot script provided in the guide) after the image downloads (will take a while because the file is HUGE) click next
For this screen, the instructions differ from the app.
1. With your D4 plugged into your PC in USB Mass Storage, create a directory (folder) called ubuntu in the EXTERNAL sdcard's root*
2. Extract the image you downloaded to that directory
3. Download and extract the attached .sh (ununtud4.zip) to that directory
4. Disconnect your phone from your PC
5. Open terminal and run the following commands:
su [ENTER]
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext [ENTER]
cd /mnt/sdcard-ext/ubuntu [ENTER]
sh ubuntud4.sh [ENTER]
960x540 [ENTER]**​If you get an error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") see troubleshooting section below.​killall -TERM Xtightvnc [ENTER]
vncserver :1 -geometry 960x540 [ENTER]**​6. Open androidVNC app and enter the following settings:
Nickname: Anything you want
Password: ubuntu
Address: localhost
Port: 5901
Color Format: 24-bit color (4 bpp)
7. Hit connect
8. Hit your menu soft button and then set input mode to touchpad
9. You have ubuntu on your Droid 4!
To "shut down" ubuntu:
press the menu button, select disconnect in VNC
In terminal type this command 3 times (terminal will close itself when you are done):
exit [ENTER]
To "start up" ubuntu again:
Follow steps 5-8 above
Troubleshooting:
If you get the error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") you are about to have fun with vi at the command line.
Do the following from inside terminal:
su [ENTER]
cd /mnt/sdcard-ext/ubuntu [ENTER]
vi ubuntud4.sh [ENTER]​If you see ^M or ^ at the end of any line (remember to scroll all the way to the right to see the end of long lines) remove it. once you do that, everything should work just fine. (See the Vi Cheat Sheet above for help with Vi)
Note: Vol Up + E is [ESC] by default in this terminal emulator
Notes:
* It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
*** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!
greekchampion04 said:
Notes:
* It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
*** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!
Click to expand...
Click to collapse
I actually got it up and running on my internal sdcard partition. Pretty much just have to modify the Mount remount command, and a few lines in the script.
Here's the original command
Code:
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
And the modified one
Code:
mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard
Only things you have to change are the device location(179:57) and mount location(drop the -ext after sdcard)
Now, after that you also have to modify the script a bit. Just go through it, and anywhere that you see sdcard-ext, drop the -ext off the end.
thanks for putting that up for everybody! like i said, if you know what you are doing its not a hard swap to make.
Is anyone else getting just a gray screen when they remote in? What could be causing this?
i had that same problem at first... did you use zeroktal's ubuntud4.zip file? or did you use the ubuntu.sh file included in the app?
I used the sh file included. I did however fix the problem, when mounting at the start i confused vold with void. I did not get the file system mounted properly. This method does work!! however I am currently trying to get bash on my droid to replace sh as the shell. I've checked the forums but have not found anything yet about someone installing bash on the droid 4. With no way for nandroids I feel i should wait before I kill sh.
Sent from my DROID4 using XDA App
If you mod your init.sh in your root directory to the following, your vnc will work on startup without issue. It will also shutdown vnc on exit.
#!/bin/bash
#############################################
# Asks User to screen size and saves as REZ #
#############################################
#echo "Now enter the screen size you want in pixels (e.g. 800x480), followed by [ENTER]:"
#read REZ
##############################################
# Pick which desktop environment to use, this#
# is done by having a xstartup file for each #
# desktop, then renaming the one you want to #
# use to 'xstartup' before boot #
##############################################
echo "Please select which Desktop environment you want to use, type the number to select it then press [ENTER]"
echo "1 - LXDE"
echo "2 - Gnome"
echo "Make your Selection:"
read DESKTOP
if [ $DESKTOP == 1 ]
then
mv /root/.vnc/lxstartup /root/.vnc/xstartup
fi
if [ $DESKTOP == 2 ]
then
mv /root/.vnc/gxstartup /root/.vnc/xstartup
fi
###########################################
# Tidy up previous LXDE and DBUS sessions #
###########################################
rm /tmp/.X* > /dev/null 2>&1
rm /tmp/.X11-unix/X* > /dev/null 2>&1
rm /root/.vnc/localhost* > /dev/null 2>&1
rm /var/run/dbus/pid > /dev/null 2>&1
############################################################
# enable workaround for upstart dependent installs #
# in chroot'd environment. this allows certain packages #
# that use upstart start/stop to not fail on install. #
# this means they will have to be launched manually though #
############################################################
dpkg-divert --local --rename --add /sbin/initctl > /dev/null 2>&1
ln -s /bin/true /sbin/initctl > /dev/null 2>&1
###############################################
# start vnc server with given resolution and #
# DBUS server, (and optionally an SSH server) #
###############################################
dbus-daemon --system --fork > /dev/null 2>&1
/etc/init.d/ssh start
vncserver :1 -geometry 960x540
echo
echo "If you see the message 'New 'X' Desktop is localhost:1' then you are ready to VNC into your ubuntu OS.."
echo
echo "If VNC'ing from a different machine on the same network as the android device use the 1st address below:"
##########################################
# Output IP address of android device #
##########################################
ifconfig | grep "inet addr"
echo
echo "If using androidVNC, change the 'Color Format' setting to 24-bit colour, and once you've VNC'd in, change the 'input mode' to touchpad (in settings)"
echo
echo "To shut down the VNC server and exit the ubuntu environment, just enter 'exit' at this terminal - and WAIT for all shutdown routines to finish!"
echo
###############################################################
# Spawn and interactive shell - this effectively halts script #
# execution until the spawning shell is exited (i.e. you want #
# to shut down vncserver and exit the ubuntu environment) #
###############################################################
/bin/bash -i
#########################################
# Disable upstart workaround and #
# kill VNC server (and optionally SSH) #
# Rename used xstartup to its first file#
#########################################
killall -TERM Xtightvnc
/etc/init.d/ssh stop
Also save the follow lines between ### as remount.sh on your system partition. Then chmod 755 /system/remount.sh. Now you can just run run from a terminal /system/remount.sh and voila it remounts correctly and starts ubuntu(with the above fixes). Im still working on the unmounts.
####### for the internal sd card
mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard
/mnt/sdcard/ubuntu/ubuntu.sh
######
OR
####### for the external sd card
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
/mnt/sdcard-ext/ubuntu/ubuntu.sh
#######
great stuff!
feel free
Feel free and take, modify, repost or edit anything I touch.
QUESTION:
After I delete all the ^M and ^ what do i do next? I try to hit the command ":x" to exit and save changes but it just creates another line. Also when I press VOL UP + E to escape nothing happens.
PhanTuhC said:
QUESTION:
After I delete all the ^M and ^ what do i do next? I try to hit the command ":x" to exit and save changes but it just creates another line. Also when I press VOL UP + E to escape nothing happens.
Click to expand...
Click to collapse
In vi, the command to save and exit is :wq (probably short for write and quit).
remember, read up on the vi quick-reference guide: http://www.lagmonster.org/docs/vi.html
OK I fixed it but now its not letting me connect with androidVNC. All the settings entered is correct but when I try to connect it says:
"VNC connection failed!" localhost/127.0.0.1:5901 - Connection refused"
ok, i've gone thru this a few times (slowly and deliberately) and must be missing something...the directions seem pretty straightforward! here's what i know...
busy/terminal/vnc are all installed
small 2.5gb image is unzipped in /sdcard-ext/ubuntu directory
the attached .sh file from page 1 is in the same directory
i removed all ^M using vi
but when I try sh ubuntud4.sh i get an error...
"mkdir failed for /data/local/mnt/ubun, No such file or directory"
(plus a few other errors)
should the directory be "ubun" or "ubuntu"? am I typing something incorrectly?
copy and paste new script
Copy and paste the new scripts I posted. They will fix your problem. Remember to use the remount script from /system/ the rest will work perfectly if you are root. I'll check back later on your progress.
Ok, well I started from scratch (deleted both .img and .sh files) and it's still not working.
I have all the apps installed (and yes rooted, SU works just fine)
I used Ubuntu Installer app to download the image zip (tried both the large and small img)
I downloaded the .sh file from the first post
The /sdcard-ext/ubuntu/ folder now has two files: "ubuntu.img" and "ubuntud4.sh"
All ^M characters have been removed from .sh file
Still no joy...
Ideas? What am I missing?
In terminal, I can set SU permissions and the mount/cd commands work just fine...it's the last sh command that spits out a bunch of errors about not being able to create/find the directories.
I'm going to format the sdcard and try again...any help is appreciated.
Update: Even after re-formatting the SD and following the steps exactly, no luck!
Did you remember to remount the sdcard with exec and suid permissions?
Andbuntu will work much better than this method. It works on every single phone with modification to the "environmental variables".
http://code.google.com/p/andbuntu/
Follow the directions in the script to make the process much easier than the first post.
instructions:
generate an image with rootstock on an ubuntu computer.
put it on /sdcard/ubuntu/ubuntu.img
run the script on your phone with "sh /path/to/script"
Here is the script. http://andbuntu.googlecode.com/svn/trunk/uboot
Also, run "firstRun" to make things like terminals work properly.
Adamoutler: That didnt work for me. The permissions were incorrect on the mounted partitions.
Sent from my DROID4 using XDA App

[tutorial] install bash command line on your android

it is not tested on galaxy mini so I will say it beta, please its a request to post a reply whether it is working or not
bash:- an advanced command line than sh, it is colorful so you can differentiate the commands easily
steps for installing bash if you have cwm and want automated process
1:- download the bash command line flashable zip from here
2. download bash enabler script from here
3. flash the bash command line dhlalit11.zip in cwm recovery
4. boot the device normally
5. with the help of script manager execute the bash install.sh script with su privilege
and you are done
Click to expand...
Click to collapse
steps for installing bash if you don't have cwm or want to do it manually
1:- download the bash command line flashable zip from here
2. extract the files to a folder
3. go to /extracted folder/system
4. copy all the files to your system as they are placed
5. open terminal and type chmod 0755 /system/xbin/bash
and its done
Click to expand...
Click to collapse
note:- running bash will not give you root privilege automatically, you will need to type "su -c bash" to go directly into bash with root
reserved
if you don't mind...you can add this line into your updater script
Code:
set_perm(0, 0, 0755, "/system/blabla-the file position");
this one will automatically change the file permission for you so that we don't have to run the script anymore. you can also add symlink("/system/bin/bash", "/system/bin/sh"); to replace our old sh with bash so that everytime we use sh command, we will run bash instead. I was using these trick on my old ROM. however, this step will erase our sh binary file. so we must use it carefully. I usually did these step on a fresh rom installation. you might want to test it by yourself to make sure everything is alright.
I like to make scripts and one more reason is the script first looks for bash in /system/xbin to ensure a proper flash, if bash is not found it will tell the owner
didn't wanted to replace sh
if the purpose is to check whether it was installed correctly or not you can use run_program command instead and make the installation a lot simpler. you can put the script temporary in cache and delete it after the installation complete. or else...you can play with aroma installer. you can design the UI with several option like
1. install bash
2. symlink bash to sh
3. check the bash installation status
4. etc etc (as you like)
aroma could make our usual installation stuff into sumething more fun and interactive ^,^v
anyway, this is only a suggestion. if you want to use aroma you can modify my multi tweak installer. you said that you like to make scripts. it will be easy for you to get the basic stuff on aroma and starting to made one for your self. the link is in my sig. check the akuro or one pack tweak thread and got the aroma from the latest version there.
script run in cwm do not print anything on the UI and the user will not see whether the it was done or not
and I had previously used aroma in my rom patch for galaxy s series but this is just a simple task to do
I will think about it, but sure it will take time and I don't have time as I wanted to update the sticky of this forum then I am working on two mods for my karbonn smart tab 1
but I will for sure figure it out
installing bash
hi i have a Galaxy Centura tracphone and i get this error after executing su-c bash into the cmd via adb......I have installed the flashable zip and ran the installer script....
255|[email protected]:/system/bin # su -c bash
su -c bash
link_image[1936]: 7974 could not load needed library 'libncurses.so' for 'bash
(load_library[1091]: Library 'libncurses.so' not found)CANNOT LINK EXECUTABLE
255|[email protected]:/system/bin #
any ideas?
Bash
Hi, I managed to install the ZIP file (Moto G XT1032) and the script worked as well but after it was done, bash didn't have 755.
I tried adding it manually (as root) but it fails with this error:
Unable to chmod /system/xbin/bash: read-only filesystem
I tried remount using this:
su mount -o remount,rw /
But still no luck, any suggestions?
---------------------------------------------------- UPDATE -------------------------------------------------------
managed to get it via ADB Shell with this commands:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
chmod 755 /system/xbin/bash
still not working because of not having "libncurses.so" which will try to install manually.
ThePlayer10 said:
Hi, I managed to install the ZIP file (Moto G XT1032) and the script worked as well but after it was done, bash didn't have 755.
I tried adding it manually (as root) but it fails with this error:
Unable to chmod /system/xbin/bash: read-only filesystem
I tried remount using this:
su mount -o remount,rw /
But still no luck, any suggestions?
---------------------------------------------------- UPDATE -------------------------------------------------------
managed to get it via ADB Shell with this commands:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
chmod 755 /system/xbin/bash
still not working because of not having "libncurses.so" which will try to install manually.
Click to expand...
Click to collapse
You didn't needed to type whole dev block address, what you were missing was
(su
mount -o remount,re /system)
You were actually mountung the root of your device instead of system partition, which was the reason of non-working

[mod][6T] init.d / services.d framework using Magisk [linux]

This thread will allow you to set up init.d (and services.d) scripts on your phone so they can run at boot time.
Prerequisites
- understanding of what "init.d" scripts mean ...
- your phone must be rooted (see https://www.xda-developers.com/oneplus-6t-unlock-bootloader-root/)
- you must have a working Magisk (see https://forum.xda-developers.com/apps/magisk)
- linux knowledge (I am not a Windows guy but instructions below should easily apply to Windows / PowerShell)
- adb knowledge
If this scares you, stop reading and go play with something else.
Attached zip file contains
- a magisk.img file
- a directory with init.d scripts
- a directory with services.d scripts
You can use the scripts provided or not use (some) of them, or write your own.
What's the difference between init.d and services.d scripts?
The idea is to have 2 directories on your phone with scripts:
Code:
/system/etc/init.d/
/system/etc/services.d/
The init.d scripts are run early in the boot (when Magisk initializes). The scripts in /system/etc/services.d/ will run a bit "later", to be precise: when sys.boot_completed = true.
Important warrning: even when sys.boot_completed = true, this does NOT guarantee that /sdcard is mounted. Your script can "sleep" until /sdcard is mounted if it relies on things on /sdcard. See for example the code in /system/etc/services.d/LS99maxvolumewarning which will show how you can do that.
Scripts in init.d should NOT rely on any of the file systems being mounted !
The framework will run all scripts in parallel. So be careful that you do not write scripts which depend on eachother!
The framework will run all scripts as background processes so that they do not hinder the normal boot of your phone.
Prepare the basic setup
To use the scripts (or your own), you must first create the directories init.d and services.d; to do that open a linux shell and do:
Code:
> adb shell
$ su
# mount -o rw,remount /system
# mkdir /system/etc/init.d/
# mkdir /system/etc/services.d/
# chown 0.0 /system/etc/init.d
# chown 0.0 /system/etc/services.d
# chmod 755 /system/etc/init.d
# chmod 755 /system/etc/services.d
# sync; exit
Putting the scripts on your phone
Download the attached zip file (initd.zip); create a directory in your linux file system and unzip, e.g.
Code:
> mkdir mydir
> cd mydir
> unzip ~/initd.zip
> adb push init.d/ /sdcard/
> adb push services.d/ /sdcard/
> adb shell
$ su
# mount -o rw,remount /system
# mv /sdcard/LS00* /system/etc/init.d/
# mv /sdcard/LS99* /system/etc/services.d/
# chown 0.0 /system/etc/init.d/*
# chown 0.0 /system/etc/services.d/*
# chmod 755 /system/etc/init.d/*
# chmod 755 /system/etc/services.d/*
# sync
# exit
$ exit
Installing the magisk image on your phone
First important remark: I need to turn this really into a proper magisk "module" but I need to study that first. Open a linux shell and do:
Code:
> cd mydir
> gunzip magisk.img.gz
> adb push magisk.img /sdcard/
> adb shell
$ su
# cd /data/adb
# mv magisk.img magisk.img.orig
# cp /sdcard/magisk.img .
# chown 0.0 magisk.img
# chmod 644 magisk.img
# sync
# exit
$ exit
That's all !!! If you now reboot your phone your init.d and services.d scripts will run.
How can I tell this is working?
Each script has a log file in /data/; whose name is LS00 (for init.d) or LS99 (for services.d) appended with the name of the script. That log file is passed as "$1" into the script and the script code can write to this log file using:
Code:
LOGFILE=$1
echo "Hi I am writing to the log" | tee -a $LOGFILE
To check that the log files are there, open a linux shell and do:
Code:
> adb shell
$ su
# ls /data/LS*
And you should see something like:
Code:
16 /data/LS00blockdev 4 /data/LS99bootclean 4 /data/LS99maxvolumewarning 4 /data/LS99sysctl
4 /data/LS00governors 4 /data/LS99callrecording 4 /data/LS99network 4 /data/LS99trimcaches
4 /data/LS00kerneltweaks 4 /data/LS99cputweaks 4 /data/LS99overlays 4 /data/LS99turnoffnightmode
4 /data/LS00procgate 4 /data/LS99enablecallrecording 4 /data/LS99remounts 4 /data/LS99workqueue
4 /data/LS00readahead 4 /data/LS99hdparm 4 /data/LS99resetprop
4 /data/LS00resetprop 4 /data/LS99magiskhide 4 /data/LS99sqlite
To check the contents of the log files, do:
Code:
> adb shell
$ su
# cat /data/LS*
And you will see logging info:
Code:
>> Starting /system/etc/init.d/LS00procgate at 19700110-17:21:12
-- remounting: mount -o remount,hidepid=2,gid=3009 /proc
<< Ending /system/etc/init.d/LS00procgate at 19700110-17:21:12
>> Starting /system/etc/services.d/LS99maxvolumewarning at 20181201-07:34:00
-- slept for 4 seconds waiting for /sdcard/Android
-- disabling max volume warning
<< Ending /system/etc/services.d/LS99maxvolumewarning at 20181201-07:33:58
What's next
Write your own scripts (and share them). Note that scripts must be owned by root (chown 0.0) and have 755 linux permissions (chmod) to run.
How does it really work?
No secrets ... magisk.img is actually a magisk module which runs the scripts. To see the inner details, do the following after you have installed the magisk image and rebooted your phone:
Code:
> adb shell
$ su
# ls -l /sbin/.core/img/template/
total 12
0 -rw-r--r-- 1 root root 0 2018-03-12 21:19 auto_mount
4 -rw-r--r-- 1 root root 935 2018-08-06 17:59 post-fs-data.sh
4 -rwxr-xr-x 1 root root 498 2018-08-05 10:11 scriptwrapper*
4 -rw-r--r-- 1 root root 2750 2018-08-11 12:07 service.sh
Magisk will run the post-fs-data.sh first and service.sh later. Check the code of both of these files to understand how init.d and services.d are ran (using run-parts). If you want more details please read: https://topjohnwu.github.io/Magisk/guides.html#scripts.
Disable ALL scripts from running
If you want to disable any script from running do:
Code:
> adb shell
$ su
# touch /data/noinitrd
To undo this and get your scripts running again, do:
Code:
> adb shell
$ su
# rm /data/noinitrd
What do my init.d scripts do?
Code:
LS00blockdev: change properties of block devices (non rotational, no kernel io stats, ...)
LS00governors: set all CPU governers (to schedutil; which is actually the 6T default)
LS00kerneltweaks: a few basic kernel tweaks + stop debug of kernel modules
LS00procgate: protections against the procgate security vulnerability (thanks to @topjohnwu)
LS00readahead: change the readahead amount on logical disk devicesw
LS00resetprop: reset model, brand, manufacturer (only useful if you would want to get your phone appear externally as a Pixel; check the code)
What do my services.d scripts do?
Code:
LS99bootclean: clean junk and log files
LS99cputweaks: improve scaling governor
LS99enablecallrecording: enable call recording (must be done at every device boot)
LS99execonce: a whole series of settings; this is only executed ONCE
LS99hdparm: increase readahead on /system and /data
LS99magiskhide: hide some packages from seeing root
LS99maxvolumewarning: remove the high volume warning (I am not sure this will always work !!!)
LS99network: TCP transmit queue and congestion control
LS99overlays: enable all overlays automatically (if you use substratum then no need to enable them manually)
LS99remounts: improve file system performance of multiple partitions
LS99resetprop: increase memory used by dalvik
LS99sqlite: REINDEX and VACCUM sqlite database files (the script only runs every 3rd day)
LS99sysctl: optimize linux kernel settings and TCP/IP performance
LS99trimcaches: trim android cache files
LS99turnoffnightmode: reset the night mode to OFF (night mode conflicts with dark mode in newer Google apps)
LS99workqueue: tune kernel work queue
Thanks man I have been trying to get boot scripts to run.
jacksummers said:
Thanks man I have been trying to get boot scripts to run.
Click to expand...
Click to collapse
excuse me for the ignorance, but what is the use of this mod?
Sent from my [device_name] using XDA-Developers Legacy app
isoladisegnata said:
excuse me for the ignorance, but what is the use of this mod?
Sent from my [device_name] using XDA-Developers Legacy app
Click to expand...
Click to collapse
At the end of OP he's got a summary of what the different scripts do.
I am stuck here > unzip ~/initd.zip
It keeps saying:
1|OnePlus6T:/mydir # unzip /initd.zip
unzip: can't open /initd.zip[.zip]
Any ideas I extracted initd to the directory where my platform tools are and where I do my system updates am I supposed to extract it somewhere else? How do I create a directory in my linux shell using windows cmd promts?
kirschdog1 said:
I am stuck here > unzip ~/initd.zip
It keeps saying:
1|OnePlus6T:/mydir # unzip /initd.zip
unzip: can't open /initd.zip[.zip]
Any ideas I extracted initd to the directory where my platform tools are and where I do my system updates am I supposed to extract it somewhere else? How do I create a directory in my linux shell using windows cmd promts?
Click to expand...
Click to collapse
Looks like a simple typo "/initd.zip" implies that the file is located in the root directory. "~/initd.zip" would be in your "home" directory. Since I don't know if "/mydir" is defined as your home directory and presuming initd.zip is located there try "unzip /mydir/initd.zip" (no quotes).
Still not working
Base2 said:
Looks like a simple typo "/initd.zip" implies that the file is located in the root directory. "~/initd.zip" would be in your "home" directory. Since I don't know if "/mydir" is defined as your home directory and presuming initd.zip is located there try "unzip /mydir/initd.zip" (no quotes).
Click to expand...
Click to collapse
1|OnePlus6T:/ # cd mydir
OnePlus6T:/mydir # unzip ~/initd.zip
unzip: can't open //initd.zip[.zip]
1|OnePlus6T:/mydir # unzip /mydir/initd.zip
unzip: can't open /mydir/initd.zip[.zip]
Any ideas? How to get this working? I tried both commands to no avail.
kirschdog1 said:
I am stuck here > unzip ~/initd.zip
It keeps saying:
1|OnePlus6T:/mydir # unzip /initd.zip
unzip: can't open /initd.zip[.zip]
Any ideas I extracted initd to the directory where my platform tools are and where I do my system updates am I supposed to extract it somewhere else? How do I create a directory in my linux shell using windows cmd promts?
Click to expand...
Click to collapse
You have to create the directory mydir on your linux machine, not on your phone.
Base2 said:
Looks like a simple typo "/initd.zip" implies that the file is located in the root directory. "~/initd.zip" would be in your "home" directory. Since I don't know if "/mydir" is defined as your home directory and presuming initd.zip is located there try "unzip /mydir/initd.zip" (no quotes).
Click to expand...
Click to collapse
No, not a typo. mydir is on your PC, not on the phone !
foobar66 said:
No, not a typo. mydir is on your PC, not on the phone !
Click to expand...
Click to collapse
How do I create the directory? I'm using a windows device using adb command prompts?
kirschdog1 said:
How do I create the directory? I'm using a windows device using adb command prompts?
Click to expand...
Click to collapse
Search how to create directories in PowerShell ... I am not a Windows guru :crying:
foobar66 said:
Search how to create directories in PowerShell ... I am not a Windows guru :crying:
Click to expand...
Click to collapse
Ok thank you.ill hold off as it appears to be above my pay grade.
foobar66 said:
You have to create the directory mydir on your linux machine, not on your phone.
Click to expand...
Click to collapse
This won't work anymore as magisk doesn't use magisk.img anymore

Categories

Resources