[Q] Can someone please help me run this script? - Android Q&A, Help & Troubleshooting

Hi everyone
I am trying to run a script on my android that extracts asec files back to apk's on my phone. The scripts works fine when i put in every line manually into terminal though obviously that is a pain in the ass. So i put it into a .sh file and put the .sh file in system root for ease of execution..
i then do:
su
sh deasec.sh
though it returns:
unexpected syntax error: do
can someone tell me what i am doing wrong? - thank you kindly! (will press thanks!)
Code is below
Code:
#!/system/xbin/sh
LD_LIBRARY_PATH="/system/lib"
PATH="/system/xbin:/system/sbin:/system/bin"
for ASEC in $(find /data/app-asec/ -name '*.asec')
do
echo "Deasec $ASEC"
PKG=$(basename $ASEC|cut -d'-' -f1)
echo "Package name $PKG"
if [ -d /mnt/asec/$PKG*/lib ]
then
echo "Relocate libs"
find /data/data/$PKG/ -type l -name lib -exec rm {} \;
cp -r /mnt/asec/$PKG*/lib /data/data/$PKG/
echo "Fix libs permissions"
chown -R system:system /data/data/$PKG/lib
chmod -R 755 /data/data/$PKG/lib
fi
APK=$(pm path $PKG|cut -d':' -f2)
echo "APK location $APK"
cp $APK /data/local/tmp/pkg.apk
chmod 644 /data/local/tmp/pkg.apk
pm install -r -f /data/local/tmp/pkg.apk && rm /data/local/tmp/pkg.apk
done

Have you done the script under Windows, you don't? You need to write the script under Linux. You can also write the script directly in your phone:
Open Terminal Emulator, and write the lines one by one this way:
Code:
echo line1 >> /sdcard/script.sh
echo line2 >> /sdcard/script.sh
echo line3 >> /sdcard/script.sh
...
Then move the script to its final location, and give it permissions (if needed).

nice one mate Thankyou

Related

need help to translate MIUI V4 (ICS)

Hi,
i tried to translate a MIUI for Galaxy Nexus rom into french (can also be an other language)
i wrote an unix script to automate the process.
What i do is quite simple:
i get a specific MIUI V4 version for my device and the same translated version for the nexus S (because the nexus S has a french version)
i decompile each apk from the french rom, an put the french files into to decompile galaxy nexus directories
i recompile each apk
and i copy the compiled resources into the origin galaxy nexus apks
and i build the new ROM
but i get a bootloop any ideas ?
here is my script
if there are any part of this script that isn't clear, i could try to explain them.
of course this script could also be used on other device or other translation with some changes.
Thanks in advance .
Code:
#!/bin/bash
# MIUI-FRENCH TRANSLATE SCRIPT FOR GNEX V1.0 By Alain57
BASE_DIR=$PWD
FRENCH_DIR=$BASE_DIR/french_rom
ORIGINAL_DIR=$BASE_DIR/original_rom
OUTPUT_ROM_DIR=$BASE_DIR/output_rom
OUT_DIR=$BASE_DIR/out
WORK_DIR=$BASE_DIR/workdir
ORIGIN_APK_DIR=$WORK_DIR/origin
TRANSLATION_DIR=$WORK_DIR/translation
DECODED_APK_DIR=$WORK_DIR/decoded
LOG_FILE=$BASE_DIR/log.txt
TEMP_DIR=$BASE_DIR/temp
# clean the log file and create the missing directories if they don't exist (for exemple on first run)
function cleanLog(){
rm -fr $LOG_FILE
ARRAY_DIR=( $FRENCH_DIR $ORIGINAL_DIR $OUTPUT_ROM_DIR $OUT_DIR $WORK_DIR $ORIGIN_APK_DIR $TRANSLATION_DIR $DECODED_APK_DIR $TEMP_DIR )
echo "creating missing directoriesi if needed"
for DIR in ${ARRAY_DIR[@]}; do
if [ ! -d $DIR ]; then
mkdir $DIR
fi
done
}
# configure apktool to use framework-res and framework-miui-res
function setFramework(){
cd $FRENCH_DIR
echo "<- apktool if system/framework/framework-res.apk ->" >> $LOG_FILE
apktool if framework-res.apk >> $LOG_FILE 2>&1
echo "<- apktool if system/framework/framework-miui-res.apk ->" >> $LOG_FILE
apktool if framework-miui-res.apk >> $LOG_FILE 2>&1
}
#decompile all apk file from the english Gnex miui rom
function decompileOriginFiles(){
cd $ORIGINAL_DIR
COUNT_ORIGINAL_ZIP=`ls . | grep '.zip' | wc -l`
if [ "$COUNT_ORIGINAL_ZIP" -eq "1" ]; then
mv *.zip en.zip
echo "unzip the original rom"
unzip -q -o en.zip
echo "copy the apks to the origin dir"
cp -a system/framework/*.apk $ORIGIN_APK_DIR
cp -a system/app/*apk $ORIGIN_APK_DIR
cd $ORIGIN_APK_DIR
for F in *.apk; do
echo "decompiling origianl file $F ..." | tee -a $LOG_FILE
apktool d $F $DECODED_APK_DIR/${F%.apk} >> $LOG_FILE 2>&1
done
else
echo "there need to be ONE zip file in the original directory"
exit
fi
}
# decompile all apk files from the french Nexus S ROM
function decompileTranslatedFiles(){
cd $FRENCH_DIR
COUNT_FRENCH_ZIP=`ls . | grep '.zip' | wc -l`
if [ "$COUNT_FRENCH_ZIP" -eq "1" ]; then
mv *.zip fr.zip
echo "unzip the french rom"
unzip -q -o fr.zip
setFramework
echo "copy the apks to the working dir"
cp -a system/framework/*.apk $WORK_DIR
cp -a system/app/*.apk $WORK_DIR
cd $WORK_DIR
for F in *.apk; do
echo "decompiling french file $F ..." | tee -a $LOG_FILE
apktool d $F $TRANSLATION_DIR/${F%.apk} >> $LOG_FILE 2>&1
done
else
echo "there neeed to be ONE zip file in the french directory"
exit
fi
}
# Delete the given directory, because it is not needed
function deleteDirectoryWithoutTranslation(){
echo " ---> directory useless, removed"
cd $TRANSLATION_APK_DIR
rm -fr $1
}
# delete all useless data from the french apks
function cleanTranslatedFiles(){
cd $TRANSLATION_DIR
for d in *; do
echo "cleaning the directory $d"
cd $TRANSLATION_DIR/$d
if [ -d "res" ]; then
ls . | grep -v res | xargs -o rm -fr
cd "res"
CONTAINS_FRENCH_TRANSLATION=`ls .| grep '\-fr' | wc -l`
if [ "$CONTAINS_FRENCH_TRANSLATION" -eq "0" ]; then
deleteDirectoryWithoutTranslation $d
else
echo "---> transltation here, clean it"
ls . | grep -v '\-fr\|\./\|\.\./' | xargs -o rm -fr
fi
else
echo "no res directory"
deleteDirectoryWithoutTranslation $d
fi
if [ ! -f $ORIGIN_APK_DIR/$d.apk ];then
echo "directory not in original rom $d"
deleteDirectoryWithoutTranslation $d
fi
done
}
# merge the decoded translation in the decoded english files
function mergeTranslations(){
cd $DECODED_APK_DIR
mv $TRANSLATION_DIR/* .
cd $WORK_DIR
rm -f *.apk
}
# compile new apks including french files
function compileApk(){
cd $ORIGIN_APK_DIR
for f in *.apk; do
echo "compiling $f"
echo "apktool b $DECODED_APK_DIR/${f%.apk} $WORK_DIR/$f"
apktool b $DECODED_APK_DIR/${f%.apk} $WORK_DIR/$f >> $LOG_FILE 2>&1
done
}
# delete apk in work directory and put the original apks there
function deleteWorkFileAndCopyOriginalApk(){
cd $WORK_DIR
rm -f *.apk
cp -a $ORIGIN_APK_DIR/*.apk .
}
# put the compiled modified files in the original apk files
function finalMerge(){
cd $DECODED_APK_DIR
for F in *.apk; do
echo "doing final build $F"
cd $TEMP_DIR
rm -fr *
unzip -q $DECODED_DIR/$F
ls . | grep -v 'res\|classes.dex\|resources.arsc\|\./\|\.\./' | xargs -o rm -fr
if [ -d res ]; then
cd res
ls . | grep -v '\-fr\|\./\|\.\./' | xargs -o rm -fr
HAS_FR=`ls . | grep '\-fr' | wc -l`
if [ "$HAS_FR" -eq "0" ]; then
cd ..
rm -fr res
else
cd ..
fi
fi
zip -r $WORK_DIR/$F *
done
}
#replace the english apk files with the new french apk files, change the build.prop value and create an unsigned zip that can be flashed
function createRom(){
cd $OUTPUT_ROM_DIR
mv $ORIGINAL_DIR/system $ORIGINAL_DIR/boot.img $ORIGINAL_DIR/META-INF .
mv $WORK_DIR/*.apk system/app
mv system/app/framework*.apk system/framework
mv system/build.prop build.prop
sed 's/=en/=fr/g' build.prop > build1.prop
rm -f build.prop
sed 's/=US/=FR/g' build1.prop > system/build.prop
rm -f build1.prop
zip -r $BASE_DIR/new_rom.zip *
}
cleanLog
decompileTranslatedFiles
decompileOriginFiles
cleanTranslatedFiles
mergeTranslations
compileApk
deleteWorkFileAndCopyOriginalApk
finalMerge
createRom
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums & Read the Forum Rules
Moving to Q&A

Tablet S 4.0.3 r1a rooted

Thanks Yupandra2012, my Tablet S 4.0.3 r1a finally rooted.
Ref: http://forum.xda-developers.com/showpost.php?p=31408901&postcount=12
The original steps(this link) was written in Japanese, I've just translate it into Eng. But sorry for my bad English.
UPDATE:
A semi automatic script can be found at here.
Files you need:
adb tools
SonyTabletICS-2.zip
Superuser-3.1.3-arm-signed.zip
VpnFaker.apk (Attachment)
For those who are no using the US firmware, the attached VpnFaker.apk may not suitable for your tablet.
Please follow this steps(click me) to resign the VpnFaker.apk. Thanks.
***Pls Execute the command line by line***
Unzip those files into a dir, Open cmd console, cd to that dir
Run the following command and press Restore on your tablet
Code:
adb restore settings.ab
Check the result
Code:
adb shell ls -ld /data/data/com.android.settings/a
[I][COLOR="DarkGreen"]drwxrwxrwx system system a[/COLOR][/I]
And continue, ignore the "rm -r a" permission denied error
Code:
adb shell
cd /data/data/com.android.settings
rm -r a
while : ; do ln -s /data a/file99; done
While the loop is running, open another cmd console and run
Code:
adb restore settings.ab
Once the restore process is completed, you can press CTRL+C on the 1st cmd console to break the loop
Check the /data permission
Code:
adb shell ls -ld /data
[I][COLOR="DarkGreen"]drwxrwxrwx system system data[/COLOR][/I]
Then continue
Code:
adb push busybox /data/local/tmp
adb push rootkit.tar.gz /data/local/tmp
adb push Superuser.apk /data/local/tmp
adb push su /data/local/tmp
adb shell
cd /data/local/tmp
chmod 755 busybox
./busybox tar zxf rootkit.tar.gz
exit
Push the resigned VpnFaker.apk(resign by ZipSigner 2) and update the timestamp
Code:
adb push VpnFaker.apk /data/local/tmp
adb shell
touch -t 1346025600 /data/local/tmp/VpnFaker.apk
exit
Now, replace the VpnDialogs, ignore "cp: can't open 'system/xxxxxxx': Permission denied" while you execute "/data/local/tmp/busybox cp -r system system2"
Code:
adb shell
cd /data
/data/local/tmp/busybox cp -r system system2
[COLOR="DarkGreen"]#Pls ignore "cp: can't open 'system/xxxxxxx': Permission denied"[/COLOR]
/data/local/tmp/busybox find system2 -type f -exec chmod 666 {} \;
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \;
mv system system-
mv system2 system
mv app app-
mkdir app
mv /data/local/tmp/VpnFaker.apk /data/app
Make sure the datatime is 2012/08/27 00:00
Code:
TZ=0 ls -l /data/app
[I][COLOR="DarkGreen"]-rw-r--r-- shell shell 198580 2012-08-27 00:00 VpnFaker.apk[/COLOR][/I]
Generate the packages.xml
Code:
/data/local/tmp/busybox sed -f /data/local/tmp/packages.xml.sed system-/packages.xml > system/packages.xml
And double check the result
Code:
/data/local/tmp/busybox grep vpndialogs system/packages.xml
[I][COLOR="DarkGreen"]<updated-package name="com.android.vpndialogs" codepath="/system/app/VpnDialogs.apk" nativelibrarypath="/data/data/com.android.vpndialogs/lib" flags="1" ft="136f14be668" it="136f14be668" ut="136f14be668" version="15" shareduserid="1000">
<package name="com.android.vpndialogs" codepath="/data/app/VpnFaker.apk" nativelibrarypath="/data/data/com.android.vpndialogs/lib" flags="1" ft="1396560b400" it="1396560b400" ut="1396560b400" version="45" shareduserid="1000">[/COLOR][/I]
Exit adb shell and reboot, you should see something like "Android is updating" during startup.
Code:
exit
adb reboot
Start the injected Terminal Emulator
Code:
adb shell am start -n com.android.vpndialogs/.Term
Unlock your tabet, The Terminal Emulator should appeared. If not, post your "adb logcat".
Now, in the Terminal Emulator
Code:
id
You should see the uid is 1000(system)
Still in the Terminal Emulator, ignore the script error
Code:
/data/local/tmp/onload.sh
/data/local/tmp/onload2.sh
Now back to the cmd console
Code:
adb shell
/dev/sh
id
Check the uid is 2000(shell)
And
Code:
chown 0.0 /data/local/tmp/_su
chmod 6755 /data/local/tmp/_su
/data/local/tmp/_su
id
Check the root access uid 0(root)
Backup /system (you may just skip it)
Code:
dd if=/dev/block/mmcblk0p3 of=/mnt/sdcard/system.ext4 bs=128K
Copy su & Superuser.apk to /system
Code:
/data/local/tmp/busybox mount -o rw,remount /system
/data/local/tmp/busybox cp /data/local/tmp/_su /system/xbin
chown 0.0 /system/xbin/_su
chmod 6755 /system/xbin/_su
/data/local/tmp/busybox cp /data/local/tmp/su /system/xbin
chown 0.0 /system/xbin/su
chmod 6755 /system/xbin/su
/data/local/tmp/busybox cp /data/local/tmp/Superuser.apk /system/app
/data/local/tmp/busybox mount -o ro,remount /system
sync
exit
Check the /system _su is working or not
Code:
_su
id
Should be uid 0(root)
And move the original /data/app & /data/system back (the original steps will keep the VpnFaker.apk, but i skip it)
Code:
cd /data
mv app app2
mv app- app
mv system system2
mv system- system
exit
exit
Now, you Tablet S should be rooted.
I'm getting permission denied rm -r a... hopefully someone can make a batch file for this.
SWFlyerUK said:
I'm getting permission denied rm -r a... hopefully someone can make a batch file for this.
Click to expand...
Click to collapse
You may just skip that error.
You can't delete that folder actually, just fake the system.
WonderEkin said:
Thanks Yupandra2012, my Tablet S 4.0.3 r1a finally rooted.
Ref: http://forum.xda-developers.com/showpost.php?p=31408901&postcount=12
The original steps(this link) was written in Japanese, I've just translate it into Eng. But sorry for my bad English.
Click to expand...
Click to collapse
Good job and thank you. You beat me to the finish line, I was also translating (slowly) the original Japanese post into English by tediously using [B]http://www.bing.com/translator/[/B] and [B]http://translate.google.com/[/B] as my translators.
For convenience, those who do this rooting method may also want to copy the ADB files adb.exe, AdbWinApi.dll, and AdbWinUsbApi.dll (or download and extract ADB_v1.0.29.zip) into the same directory where they put the rooting files SonyTabletICS-2.zip, Superuser-3.1.3-arm-signed.zip, and VpnFaker.apk.
Now I just need to get an unrooted Sony Tablet S to test this method on. Perhaps I will unrooted my granddaughter's tablet.
This stopped working for me when I had to launch VpnDialogs, activity not found - also had permission denied which meant I couldn't go further, mkdir app said mkrdir not found:
Code:
/data/local/tmp/busybox cp -r system system2
= Permission Denied.
A couple questions,
Couldthis method brick my tablet, or is safe try it?
Would this work doing it on Ubuntu Linux?
Thanks in advance!
SWFlyerUK said:
This stopped working for me when I had to launch VpnDialogs, activity not found - also had permission denied which meant I couldn't go further, mkdir app said mkrdir not found:
Code:
/data/local/tmp/busybox cp -r system system2
= Permission Denied.
Click to expand...
Click to collapse
Same Problem here, what to do now?
WonderEkin said:
Thanks Yupandra2012, my Tablet S 4.0.3 r1a finally rooted.
Ref: http://forum.xda-developers.com/showpost.php?p=31408901&postcount=12
Now, you Tablet S should be rooted.
Click to expand...
Click to collapse
Thanks a lot for your hard work.
Before I start this root, I want to confirm with you whether this root will wipe out my installed app data?
SWFlyerUK said:
This stopped working for me when I had to launch VpnDialogs, activity not found - also had permission denied which meant I couldn't go further, mkdir app said mkrdir not found:
Code:
/data/local/tmp/busybox cp -r system system2
= Permission Denied.
Click to expand...
Click to collapse
Can you post the full command log?
WonderEkin said:
Can you post the full command log?
Click to expand...
Click to collapse
Sure, i tried it two times: (for any reason i can't copy the full log, sry)
C:\STS>adb shell
[email protected]:/ $ cd /data
cd /data
[email protected]:/data $ /data/local/tmp/busybox cp -r system system2
/data/local/tmp/busybox cp -r system system2
cp: can't create directory 'system2': Permission denied
1|[email protected]:/data $ /data/local/tmp/busybox find system2 -type f -exec chmod
666 {} \
d system2 -type f -exec chmod 666 {} \ <
> /data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \
> mv system system-
mv system system-
find: -exec requires an argument
1|[email protected]:/data $ mv system2 system
mv system2 system
failed on 'system2' - No such file or directory
255|[email protected]:/data $ cd /data
/data/local/tmp/busybox cp -r system system2
/data/local/tmp/busybox find system2 -type f -exec chmod 666 {} \;
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \;
mv system system-
mv system2 systemcd /data
/data/local/tmp/busybox cp -r system system2
/data/local/tmp/busybox find system2 -type f -exec chmod 666 {} \;
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \;
mv system system-
[email protected]:/data $ /data/local/tmp/busybox cp -r system system2
cp: can't create directory 'system2': Permission denied
daniel910821 said:
A couple questions,
Couldthis method brick my tablet, or is safe try it?
Would this work doing it on Ubuntu Linux?
Thanks in advance!
Click to expand...
Click to collapse
Modify /data won't brick the device, you can wipe it if /data really corrupted.
For /system, those steps should be harmless
If you have and for Linux, then yes, should works on Linux
I can't get the restore settings part to work. All the files are extracted to the same folder as adb any ideas
Sent from my Sony Tablet S using xda app-developers app
rrlu21 said:
Thanks a lot for your hard work.
Before I start this root, I want to confirm with you whether this root will wipe out my installed app data?
Click to expand...
Click to collapse
I'm not sure this root will keep the installed app or not, as i've wipe my tablet many times to test the VpnFaker.apk...
But the steps will rename the original app folder and rename it back in the final steps. Should be no data lost.
TomaHawk93 said:
Sure, i tried it two times: (for any reason i can't copy the full log, sry)
C:\STS>adb shell
[email protected]:/ $ cd /data
cd /data
[email protected]:/data $ /data/local/tmp/busybox cp -r system system2
/data/local/tmp/busybox cp -r system system2
cp: can't create directory 'system2': Permission denied
1|[email protected]:/data $ /data/local/tmp/busybox find system2 -type f -exec chmod
666 {} \
d system2 -type f -exec chmod 666 {} \ <
> /data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \
> mv system system-
mv system system-
find: -exec requires an argument
1|[email protected]:/data $ mv system2 system
mv system2 system
failed on 'system2' - No such file or directory
255|[email protected]:/data $ cd /data
/data/local/tmp/busybox cp -r system system2
/data/local/tmp/busybox find system2 -type f -exec chmod 666 {} \;
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \;
mv system system-
mv system2 systemcd /data
/data/local/tmp/busybox cp -r system system2
/data/local/tmp/busybox find system2 -type f -exec chmod 666 {} \;
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \;
mv system system-
[email protected]:/data $ /data/local/tmp/busybox cp -r system system2
cp: can't create directory 'system2': Permission denied
Click to expand...
Click to collapse
Seeme you paste multi lines of command at one time, am I correct?
Those command should execute one by one.
You can simple wipe the device and redo again
or
Can you execute the following code in adb shell so that I can give you the fallback command?
Code:
ls -la /data
My brother has this tablet and I plan on attempting to root this evening...
[/COLOR]video tut maybe ?
Resign VpnFaker.apk
Hi
Do I have to resign the file VpnFaker.apk? If yes can someone explain hoe this is done.
I can do all commands until the replacement of the VpnDialogs. Then I get stuck with 'permission denied'.
Regards Paul
Can we use this method to may root Xperia tablet s on 4.0.3?
im stuck @ replace the VpnDialogs
i get Permission denied for all
c:\sony>adb shell
[email protected]:/ $ cd /data
/data/local/tmp/busybox cp -r system system2
/data/local/tmp/busybox find system2 -type f -exec chmod 666 {} \;
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \;
mv system system-
mv system2 system
c
d /data
mv app app-
mkdir app
mv /data/local/tmp/VpnFaker.apk /data/app /data/local/tmp/busybox
cp -r system system2
/data/local/tmp/busybox find system2 -type f -exec chmod 666 {} \;
/data/local/tmp/busybox find system2 -type d -exec chmod 777 {} \;
mv system system-
mv system2 system
mv app app-
[email protected]:/data $ /data/local/tmp/busybox cp -r system system2
mkdir app
cp: can't create directory 'system2': Permission denied
d system2 -type f -exec chmod 666 {} \; <
find: system2: No such file or directory
d system2 -type d -exec chmod 777 {} \; <
find: system2: No such file or directory
1|[email protected]:/data $ mv system system-
failed on 'system' - Permission denied
255|[email protected]:/data $ mv system2 system
failed on 'system2' - No such file or directory
255|[email protected]:/data $
255|[email protected]:/data $ mv app app-
failed on 'app' - Permission denied
255|[email protected]:/data $ mkdir app
mkdir failed for app, File exists
255|[email protected]:
zorbakun said:
Can we use this method to may root Xperia tablet s on 4.0.3?
Click to expand...
Click to collapse
It says so in the first post and the thread title also referrs to 4.0.3 r1a

[Q] [Root] Wrote a script for mac users, need someone to proofread it.

Hi all,
I'm relatively new to shell scripting and wrote a script I think will work for mac users (yes there are a few of us). I just need someone to proof read it to see if it makes sense and if it will work for the LGOG.
Code:
#!/bin/bash
echo '''
Root LG Optimus G - by Choimobile.vn
Remember. Rooting is dangerous business. XDA and the
authors of the root are not responsible for bricked
devices, damage, poor operational skills, sudden self-
awareness of devices, or anything else. This is at your
own risk. Now get rooting and stay hacky!
1. Enable USB Debugging and Installation from Unknown sources.
2. Connect your phone to your computer.
Cafe.ChoiMobile.vn
Re-written for Mac and Translated to English by bebop_'''
function choice {
set nxt=0
set ric=0
echo Press 'y' to root or 'n' to exit:
set -p type=your choice
if [%type% == y] then function test
if [%type% == n] then exit
}
function test {
echo 'Testing for Device'
stuff/adb-mac wait-for-device
stuff/adb-mac pull system/app/Backup-Restore.apk > null
stuff/adb-mac pull /system/bin/ric > null
if ric
then set (ric = 1)
if ric == 1
then function rootoptimus
else exit
}
function rootoptimus {
echo 'Device will now root. Please be patient, this may take a while'
stuff/adb-mac wait-for-device
echo Pushing Busybox.
stuff/adb-mac push stuff/busybox /data/local/tmp/.
echo Busybox loaded
echo 'Pushing Superuser'
stuff/adb-mac push stuff/su /data/local/tmp/.
stuff/adb-mac push stuff/Superuser.apk /data/local/tmp/.
stuff/adb-mac shell chmod 755 /data/local/tmp/busybox
stuff/adb-mac push stuff/ric /data/local/tmp/ric
stuff/adb-mac restore stuff/fakebackup.ab
stuff/adb-mac shell "while ! ln -s /data/local.prop /data/data/com.android.settings/a/file99; do :; done" > NUL
stuff/adb-mac reboot
stuff/adb-mac wait-for-device
echo Now begining root process
stuff/adb-mac shell "/data/local/tmp/busybox mount -o remount,rw /system && /data/local/tmp/busybox mv /data/local/tmp/su /system/xbin/su && /data/local/tmp/busybox mv /data/local/tmp/Superuser.apk /system/app/Superuser.apk && /data/local/tmp/busybox cp /data/local/tmp/busybox /system/xbin/busybox && chown 0.0 /system/xbin/su && chmod 06755 /system/xbin/su && chmod 655 /system/app/Superuser.apk && chmod 755 /system/xbin/busybox && rm /data/local.prop && reboot"
echo 'Device is now rooted. Enjoy your liberation.'
}
I'm still more or less in the phase of "I have no idea what I'm doing". I ran it by a guy a work with and he said it looked okay. Anyone want to take a closer stab at this? I'd appreciate it.

[Q] Revolution HD add init.d script

Hi all,
I have a problem with the rom in the subject, the headphone amplifier level is too high for me and I want to set a lower value to it.
I created this script:
Code:
#!/system/bin/sh
echo 1 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_eq
echo 40 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_amplifier_level
I have saved it in the /system/etc/init.d/ folder, I have set user and group (root:shell) and permissions (755) like the other scripts in that folder but the script simply isn't started at boot time!
at the end of the file /system/etc/init.post_boot.sh there are these lines:
Code:
# Execute /system/etc/init.d scripts on boot
chgrp -R 2000 /system/etc/init.d
chmod -R 777 /system/etc/init.d
/system/xbin/busybox run-parts /system/etc/init.d
log -p i -t ARHD "init.d support activated"
;;
what I need to do to allow the system to start my script?
thank you!
k4po said:
Hi all,
I have a problem with the rom in the subject, the headphone amplifier level is too high for me and I want to set a lower value to it.
I created this script:
Code:
#!/system/bin/sh
echo 1 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_eq
echo 40 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_amplifier_level
I have saved it in the /system/etc/init.d/ folder, I have set user and group (root:shell) and permissions (755) like the other scripts in that folder but the script simply isn't started at boot time!
at the end of the file /system/etc/init.post_boot.sh there are these lines:
Code:
# Execute /system/etc/init.d scripts on boot
chgrp -R 2000 /system/etc/init.d
chmod -R 777 /system/etc/init.d
/system/xbin/busybox run-parts /system/etc/init.d
log -p i -t ARHD "init.d support activated"
;;
what I need to do to allow the system to start my script?
thank you!
Click to expand...
Click to collapse
actually it seems that no one file inside that directory is started on boot! also the file that already were into the directory!
Ok a developer told me that init.d support will be available from next release!
I'll try something different
Sent from my GT-I9300 using xda app-developers app

[HOW TO]Adding init.d support

This is a quick how to on how to add init.d support to your device. I am posting this as i have had alot of intrest on the subject.
This method has been tested on the n7000 with a rooted rom and philz kernel if you test on other devices and it works(or does not work) please let me know and i will build a compatibility list
you are doing this at your own risk so do not complain when you mess it up.
use this method to test the init.d support if successful then just add your init.d scripts to the init.d folder.
1. Download the file from here: 00test.zip
2. Extract the file, you will get a file named 00test. DO NOT flash!
3. Paste it into /etc/init.d. If there is no init.d folder, most probably you DO NOT have init.d support. However, if you still wanna try, just create the folder named "init.d"
4. Change the permissions of the init.d folder and 00test into rwxrwxrwx.
5. Reboot.
6. If you see a file named Test.log in /data, you have init.d support. If not, you will have to run Uni-init, Term-init or Zip-init.
at step 3 you should have init.d support if you have a rooted rom and a kernel which has init.d support.
if i have helped you please hit thanks button. :good:​
Uhhh, this doesn't tell you at all how to add init.d support. It just tells you how to test and see if you already have init.d support. Thread title is misleading.
1. add this line
exec /system/bin/sysinit
in init.rc (in ramdisk) ,then compile boot.img
2.flash the boot.img
3.extract sysinit (from the attached file) and copy in /system/bin/ with permission rwxr-xr-x (755)
4.reboot
or you can cook it with dsixda kitchen ... ,
just use this apk called uni init.d it work well on my device ...
here is the link http://forum.xda-developers.com/showthread.php?t=1933849
Or, if you really want to learn a little, you can get the VTS (Virtual Ten Studio) from XDA Developers (free), Do a boot project, and add the following in init.rc
Code:
run-parts /etc/init.d
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
disabled
oneshot
Then re-compile your boot image and flash or fastboot it.
MD
There is not init.rc in my boot.img ! What can I do now?
PHP:
# Adds kernel's Init.d
INITD() {
if [[ -e "/PATH/TO/init.rc" ]]; then
sed -i -e '0,/class_start /s//start sysinit\n\n class_start /' "/PATH/TO/init.rc"
sed -i -e 's/service media /service sysinit \/system\/bin\/logwrapper \/system\/xbin\/busybox run-parts \/system\/etc\/init.d\n disabled\n oneshot\n\nservice media /' "/PATH/TO/init.rc"
cd "$(dirname "$0")"
cd ..
# Call other methods
MOUNT
INSTALL_RECOVERY
SYSINT
PERMISSIONS
else
ui_print "ERROR, missing needed contents from the ramdisk?!";
rm -rf "$ACTIVE_PROJECT/TEMP"
return 1
fi
}
# Mount system as R/W
MOUNT() {
busybox mount -o remount,rw -t auto /system
}
# Build and write to install-recovery.sh
INSTALL_RECOVERY() {
if [ -e /system/etc/install-recovery.sh ]
then
busybox echo "# init.d support" >> /system/etc/install-recovery.sh
busybox echo "busybox run-parts /system/etc/init.d/" >> /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
busybox awk '!x[$0]++' /system/etc/install-recovery.sh > /tmp/install-recovery.sh
busybox cat /tmp/install-recovery.sh > /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
else
cat > /system/etc/install-recovery.sh
busybox echo "#!/system/bin/sh" >> /system/etc/install-recovery.sh
busybox echo "# init.d support" >> /system/etc/install-recovery.sh
busybox echo "busybox run-parts /system/etc/init.d/" >> /system/etc/install-recovery.sh
busybox echo "" >> /system/etc/install-recovery.sh
fi
}
# Build and write to systint
SYSINT() {
if [ -e /system/bin/sysint ]
then
busybox echo "#!/system/bin/sh" >> /system/bin/sysint
busybox echo "# init.d support" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
busybox echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/sysint
busybox echo "/system/bin/logwrapper run-parts /system/etc/init.d" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
busybox awk '!x[$0]++' /system/bin/sysint > /tmp/sysint
busybox cat /tmp/sysint > /system/bin/sysint
busybox echo "" >> /system/bin/sysint
else
busybox echo "#!/system/bin/sh" > /system/bin/sysint
busybox echo "# init.d support" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
busybox echo "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> /system/bin/sysint
busybox echo "/system/bin/logwrapper run-parts /system/etc/init.d" >> /system/bin/sysint
busybox echo "" >> /system/bin/sysint
fi
}
# Set permissions accordingly
PERMISSIONS() {
busybox chmod 755 /system/etc/install-recovery.sh
busybox chown 0.0 /system/etc/install-recovery.sh
busybox chmod 755 /system/bin/sysint
busybox chown 0.2000 /system/bin/sysint
}
# Start process here
INITD
Here is a small snippet from my script that I use with MyMinds_Kernel_Swap for flashing in my recovery to pull my boot.img using dd, unpack using my unmkbootimg binary, edit init.rc and amongst other things in /system, swap kernel, build ramdisk with mkbootfs, build boot.img with mkbootimg, and flash using dd. Pretty much like AnyKernel, but I wrote my own because AnyKernel just didn't work.
Anyways, here you go. Remember, some adjustments are needed more in less but should give you an idea for init.rc support. If you wish to see my entire script then just look up my github and find my repo as named above.

Categories

Resources