I understood how it do it so I'm posting here for people like me who search this forum for the same reason, first you just have to add the shell script which you want to execute, in your Rom . Add it where meta-inf and system folders are present i.e, the root of the Rom folder . Then you just have to add few lines to the updater-script to run the shell script just once while just flashing the Rom . For example to run a shell script called autoroot.sh only once while flashing the Rom , the lines to be added to the updater-script are,
#this line copies the shell script from the Rom's zip package to the temporary directory in the phone
package_extract_file("autoroot.sh", "/tmp/autoroot.sh");
#setting permission for the shell script to execute it . 777 permission is set to avoid any discrepancy while executing the script. The script will get deleted automatically on next boot as it it placed in the temporary folder.
set_perm(0, 0, 0777, "/tmp/autoroot.sh");
#the script is being executed by issuing the following command in the updater-script.
run_program("/tmp/autoroot.sh");
#to make sure that the script was executed properly you can add a line in the shell script at last , to create a file and display few text in it which you want. By this way you can understand if there is a file created at the directory defined in the script then the script ran perfectly otherwise the script didn't get executed as expected. For example,
echo "autoroot.sh was executed successfully" >> /data/local/tmp/autorootlog.txt
#here the autorootlog.txt file will be created and inside that autoroot.sh was executed successfully will be displayed.
REMEMBER THE ABOVE LINE HAS TO BE INSERTED IN THE SHELL SCRIPT ITSELF ALL THE OTHER LINES HAS TO BE ADDED TO THE UPDATER-SCRIPT WHICH IS PRESENT IN META-INF FOLDER .
Always edit the updater-script as well as shell scripts using notepad++ and keep the eol conversion to Unix format and save . (eol conversion can be found in the edit menu of notepad ++) always add a empty line at the end of scripts and updater-script .
I'm just a noob trying to learn something about linux and android . Just post your questions here. I'll answer if I have the proper knowledge about it.
Thanks for spending your valuable time in reading my post
Sent from my smultron using xda app-developers app
#this line copies the shell script from the Rom's zip package to the temporary directory in the phone
package_extract_file("autoroot.sh", "/tmp/autoroot.sh");
#setting permission for the shell script to execute it . 777 permission is set to avoid any discrepancy while executing the script. The script will get deleted automatically on next boot as it it placed in the temporary folder.
set_perm(0, 0, 0777, "/tmp/autoroot.sh");
#the script is being executed by issuing the following command in the updater-script.
run_program("/tmp/autoroot.sh");
#to make sure that the script was executed properly you can add a line in the shell script at last , to create a file and display few text in it which you want. By this way you can understand if there is a file created at the directory defined in the script then the script ran perfectly otherwise the script didn't get executed as expected. For example,
echo "autoroot.sh was executed successfully" >> /data/local/tmp/autorootlog.txt
#here the autorootlog.txt file will be created and inside that autoroot.sh was executed successfully will be displayed.
REMEMBER THE ABOVE LINE HAS TO BE INSERTED IN THE SHELL SCRIPT ITSELF ALL THE OTHER LINES HAS TO BE ADDED TO THE UPDATER-SCRIPT WHICH IS PRESENT IN META-INF FOLDER .
Always edit the updater-script as well as shell scripts using notepad++ and keep the eol conversion to Unix format and save . (eol conversion can be found in the edit menu of notepad ++) always add a empty line at the end of scripts and updater-script .
I'm just a noob trying to learn something about linux and android . Just post your questions here. I'll answer if I have the proper knowledge about it.
Thanks for spending your valuable time in reading my post
Sent from my smultron using xda app-developers app
Last edited: