Need help on userinit script. - Nook Color Q&A, Help & Troubleshooting

I want a script that will rename a /system/app on boot in userinit (.d or.sh) in /data/local. This is my first script and was thrilled when I was able to get it to work in SManager. I copied the script to /data/local and renamed to userinit.d. Rebooted, checked the file, not renamed. More research, tried various ways, which also work in SManager, but not as a userinit script. I have included the three ways I have tried with attempt counts and used # on two of them. I didn't use these all at once but included them so you could see what I've tried including a delay o allow time for the "mount" to work. This doesn't work in SManager in boot mode. And returns that it cannot rename because it is ro.
Code:
#!/system/bin/sh
#
#Renames DSPManager.apk to DSPManager.apk.bak
#export PATH=${PATH};/system/bin;/system/xbin
FN=/system/app/DSPManager.apk
if (FN.exists())
then
# attempt one
#busybox mount -o remount,ro -t ext4 /dev/block/mmcblk0p5 /system
# attempt two
#busybox mount -o remount,rw / 2>/dev/null
#busybox mount -o remount,rw rootfs 2>/dev/null
#busybox mount -o remount,rw /system 2>/dev/null
# attempt three
busybox mount -o remount,rw /system
#thread.wait(3000)
mv $FN $FN.bak
busybox mount -o remount,ro /system
#thread.wait(3000)
#
#busybox mount -o remount,ro -t ext4 /dev/block/mmcblk0p5 /system
#
#busybox mount -o remount,ro / 2>/dev/null
#busybox mount -o remount,ro rootfs 2>/dev/null
#busybox mount -o remount,ro /system 2>/dev/null
fi
Maybe I'm trying more than the userinit is supposed to do. I want this to survive and do its thing after Nightly updates. I use Speaker boost for volume and don't want DSPmanager taking extra memory.

Two things, first make sure you are using a root file manager and have set the directory to rw. Second, if you want the file to execute in /data/local you must name it userinit.sh and set the permissions of the file for execute. Or you can create a folder named userinit.d in /data/local and put multiple script files in that folder. Each script file must have its permission set to execute. To understand this, look at the contents of /etc/init.d/90userint.
Sent from my BN NookHD+ using XDA Premium HD app

leapinlar said:
Two things, first make sure you are using a root file manager and have set the directory to rw. Second, if you want the file to execute in /data/local you must name it userinit.sh and set the permissions of the file for execute. Or you can create a folder named userinit.d in /data/local and put multiple script files in that folder. Each script file must have its permission set to execute. To understand this, look at the contents of /etc/init.d/90userint.
Sent from my BN NookHD+ using XDA Premium HD app
Click to expand...
Click to collapse
I have the file permissions set to rwxr-xr-x (755) as well as the folder userinit.d set to the same. I have been using either Speed software's Root explorer (prefered) or Jrummy's Root Browser. I have named the script in the userinit.d folder "90RnamDSP". Again I can run the script in the root browser as a script and it renames the file. After set the file name back to the .apk I reboot, check in the /system/app and the file is not renamed. I have given the specific script I am using in the userinit.d folder.
Code:
#!/system/bin/sh
#
#Renames DSPManager.apk to DSPManager.apk.bak
path=/system/bin:/system/xbin;
FN=/system/app/DSPManager.apk;
if [ -e $fn];
then
busybox mount -o remount,rw -t /dev/block/mmcblk0p5 /system;
sleep 5;
mv $FN $FN.bak;
busybox mount -o remount,ro -t /dev/block/mmcblk0p5 /system;
fi;

You have the mount commands wrong for a userinit script. It should be:
mount -o remount,rw /system
and
mount -o remount,ro /system
And you don't need the path statement. You don't need the busybox in front of mount either. And shouldn't $fn be capitalized in the if statement?
Sent from my BN NookHD+ using XDA Premium HD app

Yippee, Yahoo, it works
leapinlar said:
You have the mount commands wrong for a userinit script. It should be:
mount -o remount,rw /system
and
mount -o remount,ro /system
And you don't need the path statement. You don't need the busybox in front of mount either. And shouldn't $fn be capitalized in the if statement?
Sent from my BN NookHD+ using XDA Premium HD app
Click to expand...
Click to collapse
Thanks for your help and patience. Didn't need the sleep either. I will be posting this on my help post noted in my signature below. I will give you thanks there as well. Couple of final questions.
Can you recommend a how to script reference ie: init script for dummies?
Can you recommend a how to make an install zip and install script, (again for the untrained)?
I have included the final code to maybe help someone trying to do something similar.
Code:
#!/system/bin/sh
#
#Renames DSPManager.apk to DSPManager.apk.bak
FN=/system/app/DSPManager.apk;
if [ -e $FN ];
then
mount -o remount,rw /system;
mv $FN $FN.bak;
mount -o remount,ro /system;
fi;

pastordl said:
Thanks for your help and patience. Didn't need the sleep either. I will be posting this on my help post noted in my signature below. I will give you thanks there as well. Couple of final questions.
Can you recommend a how to script reference ie: init script for dummies?
Can you recommend a how to make an install zip and install script, (again for the untrained)?
I have included the final code to maybe help someone trying to do something similar.
Code:
#!/system/bin/sh
#
#Renames DSPManager.apk to DSPManager.apk.bak
FN=/system/app/DSPManager.apk;
if [ -e $FN ];
then
mount -o remount,rw /system;
mv $FN $FN.bak;
mount -o remount,ro /system;
fi;
Click to expand...
Click to collapse
I don't know of any how-to's for those topics. I learned by studying examples of how others did them.
Sent from my SCH-i705 using Tapatalk

leapinlar said:
I don't know of any how-to's for those topics. I learned by studying examples of how others did them.
Sent from my SCH-i705 using Tapatalk
Click to expand...
Click to collapse
Thank you again. This script and a second one that adds the folder and the script are available at this post.
http://forum.xda-developers.com/showpost.php?p=50795653&postcount=6
I was able to make and debug the installer in a couple of hours. I thanked you in the post also.
The post is part of the help/info/reference post that I asked your permission to list your help files on.

Related

Need help with apps2sd on milestone

I found a guide to aply apps to sd on my milestone. I got it working, but the problem is, that apps installed in the data/app-private folder doesn't show as installed. I can see that they are placed in ext2 partion on my sd card along with the other apps, that normaly installes in data/app.Here is the guide i used
After creatting a ext2 partition on my SD card, i copied ext2. To sd card along with
mot_boot_mode script
#!/system/bin/sh
export PATH=/system/bin:$PATH
mot_boot_mode.bin
insmod /data/ext2.ko
mount -t ext2 /dev/block/mmcblk0p2 /data/sdapp
Then in recovery mode i entered
adb shell
su
cp /sdcard/ext2.ko /data/ext2.ko
insmod /data/ext2.ko
mkdir /data/sdapp
mount -t ext2 /dev/block/mmcblk0p2 /data/sdapp
cp /data/app/* /data/sdapp/
mkdir /sdcard/sicherung
cp /data/app/* /sdcard/sicherung
rm -r /data/app
umount /data/sdapp
mount -t ext2 /dev/block/mmcblk0p2 /data/sdapp
ls /data/sdapp
ln -s /data/sdapp /data/app
chmod 644 /data/sdapp/*
/data/busybox/chown -h 1000:1000 /data/app
/data/busybox/chown 1000:1000 /data/sdapp/*
/data/busybox/chown 1000:1000 /data/sdapp
insmod /data/ext2.ko
mount -t ext2 /dev/block/mmcblk0p2 /data/sdapp
mount -o remount,rw / /system
mv /system/bin/mot_boot_mode /system/bin/mot_boot_mode.bin
cp /sdcard/mot_boot_mode_script /system/bin/mot_boot_mode
chmod 755 /system/bin/mot_boot_mode
Do i need to make a symbolic link in data/app-private also?
I would realy like to get this working, because i purchased a lot of apps on the marked. But i have only half of them installed. It used to work on my HTC hero. But it was allready enabled in a custom rom. And that is not possible to do on a Milestone
Thanks
Fixed it by changing app-private folder two
hey glaus...
this almost seems like a guide, hehe...
i'm trying to get apps2sd to work on my milestone as well...
i tried booting in recovery mode and entering the chain of commands you just set out....
but when i go into recovery mode, i see the reboot system option, apply sdcard:update.zip, wipe data/factory reset and wipe cache partition....
and under it, i have e: can't open /cache/recovery/command
any ideas on how to fix this or where can i enter those commands you set out?
i tried in adb shell, but i get a /data/busybox/chown is not found error when setting the permissions...
thanks!
do
crap me too and it deleted some apps 2 i really want this been trying for a week oh i have a telus milestone and get the same above error.busybox is installed and hard drive is partioned
ah crap market is gone 2 lol gotta do a nano restore......man i want this bad i even bricked my phone and brought it back to life this week arghhhh
yeah...i don't know where claus is from...but if he has a telus milestone, he's the only one i've seen been able to install apps2sd with a telus milestone
i've seen other countries, even some with the same bands as we have, but none have had the actual "telus" one....the funny thing is that i can get everything else to work..
i have titanium backup pro, emulator, root explorer and everything is at superuser access...
if claus can help, i will bear his children
edit: how the heck do you install/activate the mot_boot_mode script? I see reference to it in a few wikis on basically that's what will allow us to use apps2sd...but I have no clue how to implement it
got app2sd working on milestone using a diff method will post soon
ok i got app2sd working on my telus milestone here is how i did it if u tried this method here ur gunna have to unroot then root or use a nano backup of freshly rooted phone busybox need mot to be installed so use titanium for back up and proceed http://forum.xda-developers.com/showthread.php?t=692367
ClausG76 said:
I found a guide to aply apps to sd on my milestone. I got it working, but the problem is, that apps installed in the data/app-private folder doesn't show as installed. I can see that they are placed in ext2 partion on my sd card along with the other apps, that normaly installes in data/app.Here is the guide i used
After creatting a ext2 partition on my SD card, i copied ext2. To sd card along with
mot_boot_mode script
#!/system/bin/sh
export PATH=/system/bin:$PATH
mot_boot_mode.bin
insmod /data/ext2.ko
mount -t ext2 /dev/block/mmcblk0p2 /data/sdapp
Then in recovery mode i entered
adb shell
su
cp /sdcard/ext2.ko /data/ext2.ko
insmod /data/ext2.ko
mkdir /data/sdapp
mount -t ext2 /dev/block/mmcblk0p2 /data/sdapp
cp /data/app/* /data/sdapp/
mkdir /sdcard/sicherung
cp /data/app/* /sdcard/sicherung
rm -r /data/app
umount /data/sdapp
mount -t ext2 /dev/block/mmcblk0p2 /data/sdapp
ls /data/sdapp
ln -s /data/sdapp /data/app
chmod 644 /data/sdapp/*
/data/busybox/chown -h 1000:1000 /data/app
/data/busybox/chown 1000:1000 /data/sdapp/*
/data/busybox/chown 1000:1000 /data/sdapp
insmod /data/ext2.ko
mount -t ext2 /dev/block/mmcblk0p2 /data/sdapp
mount -o remount,rw / /system
mv /system/bin/mot_boot_mode /system/bin/mot_boot_mode.bin
cp /sdcard/mot_boot_mode_script /system/bin/mot_boot_mode
chmod 755 /system/bin/mot_boot_mode
Do i need to make a symbolic link in data/app-private also?
I would realy like to get this working, because i purchased a lot of apps on the marked. But i have only half of them installed. It used to work on my HTC hero. But it was allready enabled in a custom rom. And that is not possible to do on a Milestone
Thanks
Click to expand...
Click to collapse
fixed http://forum.xda-developers.com/showthread.php?t=692367

Terminal command help remount help

I have an Atrix on AT&T. Which means there's a bootloader encryption, and the carrier prevents non-market apk installations, which I have resolved since my phone is rooted and I have changed the boot animation already.
In order to do these things, I found Ghost Commander that would let me chmod my system directories...which is fine, but I feel kind of gimped that I can't do it on terminal.
Basically, what I want to be able to do is remount /system as rw using terminal.
This method doesn't work on both terminal and emulator on my phone. I have done:
Terminal:
Code:
sudo su
cd [sdk directory]
./adb devices
./adb shell
su
mount -o remount,rw -t ext3 /dev/block/mmcblk0p12 /system
and this is where I get stuck because I just get an Invalid argument error.
Here is some info about my sytem -
Usage: mount [-r] [-w] [-o options] [-t type] device directory
/dev/block/mmcblk0p12 /system ext3 ro,noatime,nodiratime, data=ordered 0 0
Been searching for the answers for a while now, and now I'm here. What am I doing wrong? Thanks
there
Code:
mount -o remount,rw /dev/mmcblk0p12 /system
back
Code:
mount -o remount,ro /dev/mmcblk0p12 /system
Hmm, well at least I didn't get any errors this time.
I didn't get a confirmation or that it did anything at all. Is that normal?
Run mount with no parameters and look for the line with that device name, should see rw in that line instead of ro.
Sent from my MB860 using XDA App
Thanks guys, but I resorted to busybox chmod command instead lol
I tried this and got no errors, and using cat /proc/mounts/ I see the path as rw. But when I try to copy I still get the read only file system error.
**Lol, I had the phone in usb storage mode and had to switch it to Windows Media Sync**

[Q][possable solution found??][universal??] data2ext

I have made a file to mount an sdcard second partition to "/data". It needs to go in "/system/etc/init.d/". Can some have a look to tell me if it would work or not as I don't have a partition sdcard.
-Download link: http://db.tt/paxqo1b
Code:
#!/system/bin/sh
if [ -e /dev/block/platform/msm_sdcc.1/by-num/p2 ]
then
busybox mount -o rw,remount -t yaffs2 /dev/block/mtdblock10 /;
busybox umount /data;
busybox mount /dev/block/platform/msm_sdcc.1/by-num/p2 /data;
busybox chown system system /data;
busybox chmod 771 /data;
busybox mount -o ro,remount -t yaffs2 /dev/block/mtdblock10 /;
fi;
Why would you want the whole data partition on the sdcard? It will ruin it a lot quicker, and also slow the phone down if the card isn't fast enough.
Jack

[Q] Mount system in adb to read and write on Nexus 7?

Hi guys,
For the Nexus 7, is there a command I can execute in adb shell root to mount the /system/ to enable reading and writing?
For example for the Galaxy Nexus it was...
mount -o rw,remount -t ext4 /dev/block/platform/omap/omap_hsmmc.0/by- name/system /system
What is it for the Nexus 7?
Thanks!
mdrdroid said:
Hi guys,
For the Nexus 7, is there a command I can execute in adb shell root to mount the /system/ to enable reading and writing?
For example for the Galaxy Nexus it was...
mount -o rw,remount -t ext4 /dev/block/platform/omap/omap_hsmmc.0/by- name/system /system
What is it for the Nexus 7?
Thanks!
Click to expand...
Click to collapse
Shot in the dark:
Code:
adb shell
su
mount -o remount rw /system
then, for example, you should be able to do:
Code:
cp /system/build.prop [destination]
cp [source] /system/
cwoggon said:
Shot in the dark:
Code:
adb shell
su
mount -o remount rw /system
then, for example, you should be able to do:
Code:
cp /system/build.prop [destination]
cp [source] /system/
Click to expand...
Click to collapse
Thank you for replying!
I did try your shot in the dark, however when I tried to do a mkdir test for example I still got:
[email protected]:/ # mkdir test
mkdir failed for test, Read-only file system
I believe the format is like:
Usage: mount [-r] [-w] [-o options] [-t type] device directory
But I don't know the specifics. Any thoughts is appreciated!
What I posted above works on my GNex, was /system your active directory when you tried to mkdir?
I would try on my N7, but its ready to be RMA'd...
Code:
[email protected]:/system # mount -o remount rw /system
mount -o remount rw /system
[email protected]:/system # mkdir test
mkdir test
[email protected]:/system # ls
ls
app
bin
build.prop
etc
fonts
framework
lib
media
test
usr
vendor
xbin
[email protected]:/system # rmdir test
rmdir test
[email protected]:/system # ls
ls
app
bin
build.prop
etc
fonts
framework
lib
media
usr
vendor
xbin
[email protected]:/system #
cwoggon said:
What I posted above works on my GNex, was /system your active directory when you tried to mkdir?
I would try on my N7, but its ready to be RMA'd...
Code:
[email protected]:/system # mount -o remount rw /system
mount -o remount rw /system
[email protected]:/system # mkdir test
mkdir test
[email protected]:/system # ls
ls
app
bin
build.prop
etc
fonts
framework
lib
media
test
usr
vendor
xbin
[email protected]:/system # rmdir test
rmdir test
[email protected]:/system # ls
ls
app
bin
build.prop
etc
fonts
framework
lib
media
usr
vendor
xbin
[email protected]:/system #
Click to expand...
Click to collapse
Your advice worked, I over complicated it. I just did this again on my N7 and worked perfectly. Thank you very much!!!

Unable to mount System as rw in 7.1.1 DP

I am trying to create an overlay folder under /system/vendor so that I can throw a layers apk there to hide the nav bar. I am currently using the build.prop method which doesn't work nicely with the Now on Tap action of Swipe Navigation which is what I am ultimately trying to fix.
I tried using Solid Explorer to simply create the new directory like I did previously in 7.0 and 6.x but was unable to do so (action failed). I decided to try using the terminal and create the folder and move files from there but got the message that the system was read-only. I then attempted to mount system a few different ways all of which failed. I did use su before entering these commands.
Code:
angler:/system/vendor $ mkdir overlay
mkdir: 'overlay': Read-only file system
angler:/system/vendor $ mount -o rw,remount,rw /system
mount: '/dev/block/platform/soc.0/f9824900.sdhci/by-name/system' not user mountable in fstab
angler:/system/vendor $ /system/bin/mount -o rw,remount,rw /system /system
mount: '/system' not in /proc/mounts
angler:/system/vendor $ /system/bin/mount /system
mount: bad /etc/fstab: No such file or directory
Googling around didn't yield much in the way of solutions other than these different methods of mounting system. Am I just unable to mount system as rw in 7.1.1 currently, and if so, is there another way to accomplish what I want?
I'm trying to find thread I read this from, so if I find it I'll post link to it. When I was on early 7 previews that was set up with systemless root I went into twrp and then went to terminal and typed the following, touch su. When your in terminal cd to both bin and xbin and type command "touch su" without quotes. Then reboot and you should be able to use something like es file explorer to get into and write in /system. Hope that helps.
Found it, look to post = 15
http://forum.xda-developers.com/nexus-6p/help/es-file-explorer-doesnt-understand-t3242775
Unfortunately that did not end up working for me, thanks for looking up the link for me though!
On Nougat the rw mount command should be typed like this:
mount -o rw,remount /system
then for touch:
touch sbin/su
Thank you blitz for clarifying.
Hmm... it seems like the mount worked but the touch did not. I ended up using just "touch su" but ran into a different error with mkdir. I think I may just be out of luck for now. Thank you both for your help!
Code:
~ # mount -o rw,remount /system
~ # cd /system/bin
/system/bin # touch sbin/su
touch: sbin/su: No such file or directory
/system/bin # touch su
/system/bin # cd /system/xbin
/system/xbin # touch su
/system/xbin # cd /system/vendor
/vendor # mkdir overlay
mkdir: cannot create directory 'overlay': No space left on device
AbuShabanov said:
Hmm... it seems like the mount worked but the touch did not. I ended up using just "touch su" but ran into a different error with mkdir. I think I may just be out of luck for now. Thank you both for your help!
Code:
~ # mount -o rw,remount /system
~ # cd /system/bin
/system/bin # touch sbin/su
touch: sbin/su: No such file or directory
/system/bin # touch su
/system/bin # cd /system/xbin
/system/xbin # touch su
/system/xbin # cd /system/vendor
/vendor # mkdir overlay
mkdir: cannot create directory 'overlay': No space left on device
Click to expand...
Click to collapse
I'm not sure what you're trying to accomplish but still:
The touch sbin/su means creating an empty file called su in the sbin subdirectory under the current directory. So if there is no subdir named sbin under /system/bin, then it's not going to work
Secondly, you should know about the ls command: ls -la lists the files in the current directory, and remember than in unix and linux terminology, a directory is also a file so you'll also see directories (including current "." and parent "..")
Third, you should know about the df command which shows filesystem disk space usage. df -h will show you how much free space you have an all of your filesystems, including system.
Last, with great power comes great responsibilities. Running the wrong command as root will easily make your system unusable.
I have substratum installed and inside /system/vendor there is a link (again a file) called overlay which links to directory /system/overlay where apks are.
rchtk said:
I'm not sure what you're trying to accomplish
Click to expand...
Click to collapse
I am trying to create an overlay folder under /system/vendor so that I can throw a layers apk there to hide the nav bar.
rchtk said:
I have substratum installed and inside /system/vendor there is a link (again a file) called overlay which links to directory /system/overlay where apks are.
Click to expand...
Click to collapse
Are you on the 7.1.1 (NPF10C)? If so it sounds like you have accomplished what I am trying to do. I'm only familiar with the basic unix commands as I haven't actively used it in about 5 years. Would you mind sharing how to create the link to /system/overlay from /system/vendor, or does Substratum take care of that? Offhand it sounds like a symbolic link but my terminology is pretty rusty.
AbuShabanov said:
I am trying to create an overlay folder under /system/vendor so that I can throw a layers apk there to hide the nav bar.
Are you on the 7.1.1 (NPF10C)? If so it sounds like you have accomplished what I am trying to do. I'm only familiar with the basic unix commands as I haven't actively used it in about 5 years. Would you mind sharing how to create the link to /system/overlay from /system/vendor, or does Substratum take care of that? Offhand it sounds like a symbolic link but my terminology is pretty rusty.
Click to expand...
Click to collapse
Yes 7.1.1.
Substratum created the overlay directory and the link to it.
Manually that would be:
mount -o rw,remount -t auto /vendor
mount -o rw,remount -t auto /system
mkdir /system/overlay
cd /system/vendor
ln -s /system/overlay
mount -o ro,remount -t auto /vendor
mount -o ro,remount -t auto /system
But links do take a very small amount of bytes (roughly name and target) so for that, you'll need some space in your vendor partition (no space left on /vendor). check with "df".
I have 3.8MB free (that's an original vendor + overlay link)
rchtk said:
mount -o rw,remount -t auto /vendor
mount -o rw,remount -t auto /system
mkdir /system/overlay
cd /system/vendor
ln -s /system/overlay
mount -o ro,remount -t auto /vendor
mount -o ro,remount -t auto /system
Click to expand...
Click to collapse
Well, this works and I was able to mount system and vendor, create the link, move the apk file, etc but it appears that the apk itself is not working on NPF10C. Thank you for your help and the refresher on the unix commands!

Categories

Resources