[SCRIPT] Permissions Init Script

Search This thread

Romanbb

Inactive Recognized Developer
Sep 18, 2009
3,591
6,961
Seattle
aokp.co
Hey guys,

I had a nasty issue with Bi-Winning a couple weeks ago where I pushed custom framework and totally forgot about permissions. Apparently when you don't set the proper permissions it can really slow things down.

So I figured this could easily be avoided. So because of that and our CWM "Fix Permissions" option doesn't really do anything, I wrote this script to fix it!

Upon every boot, it will scan /system/app, /system/framework/, and /data/app and set the proper permissions for all the files in there.

Users
note if you're on Trigger 2.9.1+ or Bi-Winning V1+ you do NOT have to do this. It's built into your ROM already.

Flash the attached zip named "CWM_Flash_Permissions_Script.zip"

Ironically, it may not have the correct permissions after you flash it, so then do either of the following

1) Do these commands in ADB to set the correct permissions
Code:
adb shell
mount -o rw,remount /dev/block/stl9 /system
busybox chmod 777 /system/etc/init.d/*

or
2) Open up Root Explorer (or something similar)
navigate to /system/etc/init.d/
in there find the new file S30edt_perms
long press, and set the permissions
make it look like this
Code:
x x x
x x x
x x x

Here's the init.d script, it's really simple, but also effective :)

Code:
#!/system/bin/sh
# Permission script
# Written by Einherjar Dev Team
# www.edtdev.com

logFile=/data/edt/logs/S30edt_perms.log
if [ -f $logFile ]; then
        rm $logFile
fi
touch $logFile

mount -o rw,remount /dev/block/stl9 /system
echo "Setting permissions" >> $logFile
        for file in /system/app/* /system/framework/* /data/app/*; do
                echo "    setting permissions (644) for $file" >> $logFile
                chmod 644 $file
        done
        
        echo "chmodding init.d folder"
        chmod 777 /system/etc/init.d
        
        for file in /system/etc/init.d/*; do
                echo "    setting permissions (777) for $file" >> $logFile
                chmod 777 $file
        done
echo "Permissions set" >> $logFile
 

Attachments

  • CWM_Flash_Permissions_Script.zip
    2.7 KB · Views: 902
  • S30edt_perms.zip
    350 bytes · Views: 672
Last edited:

Poser

Senior Member
Mar 18, 2008
871
205
The Nether Regions of the Tropics
I'm a Linux noobie myself! :D

[slight OT] Just getting wifi working on an old ideapad y510 in slackware was an epic struggle... (wicd my arse)
[back on topic] I wish more devs would post script contents (though we can easily download and look in vi or notepad)... it helps the learning curve immensely :D

grateful for all the work EDT and rest of dev community does. We all are.

Question: What does the fix permissions CWM do then?
 

Romanbb

Inactive Recognized Developer
Sep 18, 2009
3,591
6,961
Seattle
aokp.co
[slight OT] Just getting wifi working on an old ideapad y510 in slackware was an epic struggle... (wicd my arse)
[back on topic] I wish more devs would post script contents (though we can easily download and look in vi or notepad)... it helps the learning curve immensely :D

grateful for all the work EDT and rest of dev community does. We all are.

Question: What does the fix permissions CWM do then?

I have no clue, lol. Never bothered looking at it

edit: I hate vi.
 
Last edited:

gamefreakgcb

Senior Member
Jan 8, 2007
365
34
Hmm, ok you might need super user permissions do this and let me knkow if it works:

1) type in "adb shell"
2) type in su (don't press enter yet)
3) turn your screen on & unlock it
4) press enter on the su prompt, then his yes on the screen

then try that chmod command again.

Gave permission, still "Bad Mode"
 

gamefreakgcb

Senior Member
Jan 8, 2007
365
34
bad mode in the command line? gotta give me something more here

if it' s when you run chmod +x try this one:

Code:
busybox chmod 777 /system/etc/init.d/*

When I do that, I get

chmod: /system/etc/init.d/S01edt_systcl: Read-only file system
chmod: /system/etc/init.d/S20edt_gps: Read-only file system
chmod: /system/etc/init.d/S30edt_perms: Read-only file system
chmod: /system/etc/init.d/S50edt_zipalign: Read-only file system
chmod: /system/etc/init.d/S98edt_tweaks: Read-only file system
chmod: /system/etc/init.d/S99edt_complete: Read-only file system
 

Romanbb

Inactive Recognized Developer
Sep 18, 2009
3,591
6,961
Seattle
aokp.co
When I do that, I get

chmod: /system/etc/init.d/S01edt_systcl: Read-only file system
chmod: /system/etc/init.d/S20edt_gps: Read-only file system
chmod: /system/etc/init.d/S30edt_perms: Read-only file system
chmod: /system/etc/init.d/S50edt_zipalign: Read-only file system
chmod: /system/etc/init.d/S98edt_tweaks: Read-only file system
chmod: /system/etc/init.d/S99edt_complete: Read-only file system

Oh crap, thanks for pointing that out man. Easy fix

do this

Code:
mount -o rw,remount /dev/block/stl9 /system
busybox chmod 777 /system/etc/init.d/*

should work like a charm


by the way, next time you flash a newer edt rom, they already have this fix built in. since you overwrote the file, you'll need to run the above commands to set the correct permissions as they get messed up sometimes when modifying them.
 
  • Like
Reactions: gamefreakgcb

MikeyMike01

Inactive Recognized Developer
Jul 23, 2010
6,488
2,450
The script in the .zip says

Code:
# Permission script
# Written by Roman (birgertime)
# www.edtdev.com

logFile=/data/edt/logs/S30edt_perms.log
if [ -f $logFile ]; then
	rm $logFile
fi
touch $logFile

echo "Setting permissions" >> $logFile
	for file in /system/app/* /system/framework/* /data/app/*; do
		echo "setting permissions for $file" >> $logFile
		chmod 0644 $file
	done
echo "Permissions set" >> $logFile

Which is different than the OP. I'm confused.
 

fishman0919

Senior Member
Sep 18, 2009
1,879
1,056
Providence, RI
The script in the .zip says

Code:
# Permission script
# Written by Roman (birgertime)
# www.edtdev.com

logFile=/data/edt/logs/S30edt_perms.log
if [ -f $logFile ]; then
	rm $logFile
fi
touch $logFile

echo "Setting permissions" >> $logFile
	for file in /system/app/* /system/framework/* /data/app/*; do
		echo "setting permissions for $file" >> $logFile
		chmod 0644 $file
	done
echo "Permissions set" >> $logFile

Which is different than the OP. I'm confused.

I notice that before... but got side tracked and forgot to mention something... I just pulled the one from in Bi-Winning V2 and have been ADB Push'ing that.

EDIT: Also noticed that the one that's in Dan_Brutal "Metrik Part 1- Pepperkake" is the wrong one.
 
Last edited:

MadJoe

Senior Member
Jul 18, 2007
839
146
Boston
Hey Roman, thanks for yet another improvement for this phone!

Simple question: can I just download and push the S30edt_perms.zip to etc/int.d? And is this any good for CM7 based ROMs? I just checked and that file isn't in my init.d folder on Trigger Redux.

Thanks!

Sent from my rough sketch of a Vibrant on a brick.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    Hey guys,

    I had a nasty issue with Bi-Winning a couple weeks ago where I pushed custom framework and totally forgot about permissions. Apparently when you don't set the proper permissions it can really slow things down.

    So I figured this could easily be avoided. So because of that and our CWM "Fix Permissions" option doesn't really do anything, I wrote this script to fix it!

    Upon every boot, it will scan /system/app, /system/framework/, and /data/app and set the proper permissions for all the files in there.

    Users
    note if you're on Trigger 2.9.1+ or Bi-Winning V1+ you do NOT have to do this. It's built into your ROM already.

    Flash the attached zip named "CWM_Flash_Permissions_Script.zip"

    Ironically, it may not have the correct permissions after you flash it, so then do either of the following

    1) Do these commands in ADB to set the correct permissions
    Code:
    adb shell
    mount -o rw,remount /dev/block/stl9 /system
    busybox chmod 777 /system/etc/init.d/*

    or
    2) Open up Root Explorer (or something similar)
    navigate to /system/etc/init.d/
    in there find the new file S30edt_perms
    long press, and set the permissions
    make it look like this
    Code:
    x x x
    x x x
    x x x

    Here's the init.d script, it's really simple, but also effective :)

    Code:
    #!/system/bin/sh
    # Permission script
    # Written by Einherjar Dev Team
    # www.edtdev.com
    
    logFile=/data/edt/logs/S30edt_perms.log
    if [ -f $logFile ]; then
            rm $logFile
    fi
    touch $logFile
    
    mount -o rw,remount /dev/block/stl9 /system
    echo "Setting permissions" >> $logFile
            for file in /system/app/* /system/framework/* /data/app/*; do
                    echo "    setting permissions (644) for $file" >> $logFile
                    chmod 644 $file
            done
            
            echo "chmodding init.d folder"
            chmod 777 /system/etc/init.d
            
            for file in /system/etc/init.d/*; do
                    echo "    setting permissions (777) for $file" >> $logFile
                    chmod 777 $file
            done
    echo "Permissions set" >> $logFile
    3
    Very cool, thanks roman.

    Very cool to post the code too... lets us linux newbs get our learn on!

    I'm a Linux noobie myself! :D
    3
    [slight OT] Just getting wifi working on an old ideapad y510 in slackware was an epic struggle... (wicd my arse)
    [back on topic] I wish more devs would post script contents (though we can easily download and look in vi or notepad)... it helps the learning curve immensely :D

    grateful for all the work EDT and rest of dev community does. We all are.

    Question: What does the fix permissions CWM do then?

    I have no clue, lol. Never bothered looking at it

    edit: I hate vi.
    1
    roman im gonna add S30edt_perms.zip to my rom ..ill add you to credits
    1

    Hmm, ok you might need super user permissions do this and let me knkow if it works:

    1) type in "adb shell"
    2) type in su (don't press enter yet)
    3) turn your screen on & unlock it
    4) press enter on the su prompt, then his yes on the screen

    then try that chmod command again.