[Q] Need help writing a script for temporary MVNO support on MIUI - Galaxy S I9000 Q&A, Help & Troubleshooting

Hey folks!
As some probably might have noticed, Galnet's awesome Miui ROM doesn't support MVNO providers. Fortunately some clever guy (thank you very much aziztcf) has found a solution that allows MVNO users like me to use the data connection without having to tick the data roaming checkbox.
Also the R icon is being hidden by this temporary fix. The only problem is that the "fix" only lasts until you restart your phone or enter flightmode. This means a lot of typing.
So aziztcf said a script might be ideal so you don't have to enter adb or your terminal emulator app every startup.
However I am stuck there as I never wrote a script before.
My question. Can anybody point me in the right direction? This is with what i came up so far.
The idea is to change the gsm.sim.operator.numeric/alpha to match the actual provider ones. So in my case i want it to be 23201 and A1, also I want to change the .isroaming to false and alter the beginning of the IMSI to match the original provider.
I placed this "script" in etc/init.d but it isn't working.
#!/system/bin/sh
#
#getprop
#setprop gsm.sim.operator.numeric 23201
#setprop gsm.sim.operator.alpha "A1"
#setprop gsm.operator.isroaming false
#setprop ril.IMSI 23201xxxxxxxxxx
thanks in advance guys!

Good luck!

really? is that everything you have? -.- anybody else?

perfectlysquare said:
really? is that everything you have? -.- anybody else?
Click to expand...
Click to collapse
I have created a file named roam (without extension) with this:
Code:
#!/system/bin/sh
su
setprop gsm.sim.operator.numeric 21407
setprop gsm.sim.operator.alpha "movistar"
setprop gsm.operator.isroaming false
setprop ril.IMSI 21407xxxxxxxxx
then i execute using "sh roam" and then when i close the terminal emulator, it works. but now, I'm using the APN of movistar, not the APN from my operator. I dont know if this is the solution for the MVNOs...
For execute this script every time you reboot, you can put the script in /etc/init.d/roam. ¿?
(sorry for my english)

Solution?
perfectlysquare said:
Hey folks!
As some probably might have noticed, Galnet's awesome Miui ROM doesn't support MVNO providers. Fortunately some clever guy (thank you very much aziztcf) has found a solution that allows MVNO users like me to use the data connection without having to tick the data roaming checkbox.
Also the R icon is being hidden by this temporary fix. The only problem is that the "fix" only lasts until you restart your phone or enter flightmode. This means a lot of typing.
So aziztcf said a script might be ideal so you don't have to enter adb or your terminal emulator app every startup.
However I am stuck there as I never wrote a script before.
My question. Can anybody point me in the right direction? This is with what i came up so far.
The idea is to change the gsm.sim.operator.numeric/alpha to match the actual provider ones. So in my case i want it to be 23201 and A1, also I want to change the .isroaming to false and alter the beginning of the IMSI to match the original provider.
I placed this "script" in etc/init.d but it isn't working.
#!/system/bin/sh
#
#getprop
#setprop gsm.sim.operator.numeric 23201
#setprop gsm.sim.operator.alpha "A1"
#setprop gsm.operator.isroaming false
#setprop ril.IMSI 23201xxxxxxxxxx
thanks in advance guys!
Click to expand...
Click to collapse
I think I have found a solution. (I have the same problem) - You need Root for this to work!
Here's what I did:
1.) Installed Busybox from PlayStore (open downloaded app and hit Install-Button within App)
2.) Installed SManager from PlayStore
3.) With SManager created a script named "netinit.sh" in system/bin
4.) Wrote the script (manually within SManager Editor!!! - didn't work when I pasted the lines into the file.):
#!/system/bin/sh
setprop gsm.sim.operator.alpha "A1"
setprop gsm.operator.isroaming false
getprop | grep operator
5.) With Smanager set the script to execute on boot and notify.
6.) With Smanager set the Permissions on the script to allow all access. (Found in Properties of script)
7.) Did a reboot and waited for the script notification BEFORE I unlocked the SIM.
8.) Voilá!
Hope, it works for you too!
Regards,

YogiwanKenobi said:
I think I have found a solution. (I have the same problem) - You need Root for this to work!
Here's what I did:
1.) Installed Busybox from PlayStore (open downloaded app and hit Install-Button within App)
2.) Installed SManager from PlayStore
3.) With SManager created a script named "netinit.sh" in system/bin
4.) Wrote the script (manually within SManager Editor!!! - didn't work when I pasted the lines into the file.):
#!/system/bin/sh
setprop gsm.sim.operator.alpha "A1"
setprop gsm.operator.isroaming false
getprop | grep operator
5.) With Smanager set the script to execute on boot and notify.
6.) With Smanager set the Permissions on the script to allow all access. (Found in Properties of script)
7.) Did a reboot and waited for the script notification BEFORE I unlocked the SIM.
8.) Voilá!
Hope, it works for you too!
Regards,
Click to expand...
Click to collapse
I follow this steps on miui v5, I don t know what I am doing wrong but it does not work...

razorinc said:
I follow this steps on miui v5, I don t know what I am doing wrong but it does not work...
Click to expand...
Click to collapse
Hi,
Does the script start?
Do you get an error in the console, when you manually run the script?
KR
Yogi

After I make a script I restart the phone, but launcher freezes...

Related

[LB] The definitive root Remount-Reboot fix!

As I've been working on the Stock ROM release of 10.1.1.A.1.307 some of my users started reporting that the issues I fixed for my 10.1.1.A.1.253 release started popping up again: whenever anyone with a locked bootloader tried to remount /system writable (remount,rw) it spontaneously sprung a reboot... very annoying, to say the least!
It gets even better (or worse, depends on how you look at it) when you consider any CWM version ever released for our Z/ZL models will ask us if we want it to prevent the ROM from flashing STOCK recovery...  /system/etc/install-recovery.sh is the culprit here as it is what CWM disables by making it non-executable when you say YES to the question 'ROM may flash stock recovery on boot, fix?'. It actually is an important part of the rooting process we all know. It stopped the RIC service and prevented the reboots from happening. If someone said YES, the issue mentioned in the previous paragraph would also start happening and some users have even reported loss of root and even bootloops because of this...
I've set out to find a fix for it, one that eliminates the chance a regular run-of-the-mill CWM user will ever encounter the question ever again.
For all of the regular users, download one of these:
Warning for Xperia T [ALL VERSIONS] Users: There is a problem with this patch combined with the CWM package for your phones, it seems to be busybox related. @garik.007 found the solution to this issue: BusyBox by Robert Nediyakalaparambil. Install that app, update your busybox and it will fix CWM and the remount-reboot fix
WINDOWS INSTALLER: [NUT]'s definitive remount-reboot fixer!
Make sure you have USB debugging turned ON.
Download the package, save it somewhere you remember
Unzip it somewhere you remember
Run the install.bat file and choose the superuser app you are using.
Done!
The phone should do what the installer tells you it's doing, so if it says your phone will reboot, it will. If it did NOT explicitly say that it would then something went wrong!
RECOVERY FLASHABLE: [NUT]'s definitive remount-reboot fixer!
This is a flashable ZIP, install using CWM or TWRP and you're done!
It is safe to use on any STOCK (Read: NOT CM Based) ROM version released for all Xperia phones with the ric binary incorporated in the ramdisk (/sbin/ric) up to now. To see if this fix will work for your device, check if the 'ctrlaltdel' command is executed from the init.sony[anything].rc scripts. If it is, this will work!
NOTE: As this fix needs busybox to function and will install or update busybox in /system/xbin if no busybox or no busybox binary which supports the 'nohup' applet was found in /system/bin, /system/xbin or /sbin.
NOTE 2: As soon as you have installed this rootfixer and you saw it replace the already installed busybox, remove any and all busybox installer apps you have, it will probably break the rootfixer if you update busybox using that app. The version this rootfixer installs is rock solid and is used by most if not every kernel dev working on Xperia line kernels.
NOTE 3: If you have an unlocked bootloader, you can actually also install it, it won't hurt and you'll be protected from the reboots if you re-lock your phone!
XDA:DevDB Information
The definitive root Remount-Reboot fix!, Tool/Utility for the Sony Xperia Z
Contributors
[NUT]
Version Information
Status: Stable
Stable Release Date: 2013-06-25
Created 2013-06-27
Last Updated 2015-02-05
Reserved
For the ROM chefs and other devs on XDA:
I'm proud to donate the following to the dev-community on XDA, for anyone who wants to integrate it in his/her ROM or rooting tool, there is no need to ask for permissions: you can!
This hijacks the toolbox command 'ctrlaltdel' executed from init.sony-platform.rc line 13. It will take it's place in a similar way as the chargemon gets replaced to make the recoveries possible on locked bootloaders. As it is a symlink to /system/bin/toolbox there is NO need to create a copy to something else to make this work. The script that takes it's place is this:
Code:
#!/system/bin/sh
#####
#
# Completely demolish the RIC service and make sure the phone will survive a remount of /system
#
# Author: [NUT] from XDA
#
ARGS="$1 $2"
# Check busybox path and export it
if [ -x "/system/xbin/busybox" ]; then
export BUSYBOX="/system/xbin/busybox"
elif [ -x "/system/bin/busybox" ]; then
export BUSYBOX="/system/bin/busybox"
elif [ -x "/sbin/busybox" ]; then
export BUSYBOX="/sbin/busybox"
fi
# Mount rootfs rw, if it isn't already
ROOTFSMOUNTEDRO=`$BUSYBOX grep "rootfs ro,relatime" /proc/mounts | $BUSYBOX wc -l`
if [ "$ROOTFSMOUNTEDRO" = "1" ]; then
$BUSYBOX touch /tmp/remountedrootfs
$BUSYBOX mount -o remount,rw /
fi
# Edit the init.rc so the service never gets to start
$BUSYBOX sed -i '/"# Start RIC"/N;s/service ric /sbin/ric/#service ric /sbin/ric/g' /init.sony.rc
$BUSYBOX sed -i '/"#service ric /sbin/ric"/N;s/ class main/# class main/g' /init.sony.rc
$BUSYBOX sed -i '/"# class main"/N;s/ user root/# user root/g' /init.sony.rc
$BUSYBOX sed -i '/"# user root"/N;s/ group root/# group root/g' /init.sony.rc
# chmod the ric binaries so they can't start anymore, as a failsafe
if [ -x "/sbin/ric" ]; then
$BUSYBOX chmod 644 /sbin/ric
fi
if [ -x "/system/bin/ric" ]; then
$BUSYBOX chmod 644 /system/bin/ric
fi
# Make sure the RIC service gets killed if it manages to start up...
# This process will drop in the background and keeps running untill it did!
$BUSYBOX nohup /system/bin/killric.sh &
# Execute the actual command now
exec /system/bin/toolbox ctrlaltdel $ARGS
As you can see I'm spawning a process into the background to kill the RIC service. Even though I commented out the service in init.sony.rc it still manages to start up as init reads and buffers all of it's scripting before it actually starts to do anything... so the service will run regardless of the changes we make to it. This step was just for any form of runlevel change to prevent that from triggering a restart. As a secondary measure it disables the binary all the way by setting 644 permissions on it.
Code:
#!/system/bin/sh
#####
#
# Check RIC looper, it will exit as soon as it found and killed it!
#
# Author: [NUT] from XDA
#
DoesFileExist() {
if [ -f "/tmp/killedric" ]; then
return 0
else
return 1
fi
}
# As the init.rc scripts seem to be running parallel, lets kill ric if it got started.
until DoesFileExist
do
RICCHECK=`$BUSYBOX ps | $BUSYBOX grep "/sbin/ric" | $BUSYBOX wc -l`
if [ $RICCHECK -gt 1 ]; then
$BUSYBOX pkill -f /sbin/ric
fi
if [ $RICCHECK -eq 1 ]; then
$BUSYBOX touch /tmp/killedric
fi
$BUSYBOX sleep 2
done
exit 0
This does a loop every 2 seconds and tries to pkill /sbin/ric. When successful it will exit.
To double check if these 2 scripts did their job you can check /tmp for 2 empty files:
- /tmp/remountedrootfs
and
- /tmp/killedric
If they exist, checking the processlist should end up empty when trying to find killric.sh, ctrlaltdel and /sbin/ric. If so, on a locked bootloader, you can now safely remount /system and rootfs (/) and survive it
This is my gift to the community, enjoy a trouble free root experience with it!
Thanks go to:
@DooMLoRD for the chat about the init process
@RoberM for testing and suggestions, he found out pkill does successfully kill the ric process in .307
@fards for the brainstorming in my .307 ROM thread
@Carceri for the brainstorming in my .307 ROM thread
Has this fix been implemented in latest dual boot recovery for locked boatloader?
Sent from my C6603 using xda app-developers app
shoey63 said:
Has this fix been implemented in latest dual boot recovery for locked boatloader?
Sent from my C6603 using xda app-developers app
Click to expand...
Click to collapse
No, but it will
XZDualRecovery 2.4 will get this fix as well.
In the mean time you can flash this just as well
Ok
Reason I ask is this:-
I Flashed stock .434, rooted it, flashed your dual boot recovery and did an OTA update to .253.
To my amazement, update worked, plus Root and your dual recovery were still intact! Also no reboot when accessing system as R/W:good:
I will apply your patch and see what happens when OTA for .307 comes through (eventually)
My phone switches off after the Xperia wave animation.
Facts:
Locked BL
on .253
Rooted
Did not have the R/W mount issue, but I flashed it anyway
Latest CWM/TWRP recovery
I have Fidelity V4 (If that is of any consequence here)
While flashing it detected that I had busybox (If that is of any consequence as well)
Restoring system from old backup fixed it.
Great job with fixing this and making it easy for other people to use in their ROMs.
At first I thought there was a problem with this fix due to a race condition: As far as I can see rootfs is mounted r/w before ric is killed, so I would expect that sometimes ric might start early, see that / is rw and reboot the phone. I was surprised that this did not happen, but actually it seems that ric does not check permissions on rootfs (I could mount it r/w with ric running without getting a reboot).
chmod 644 /sbin/ric is (for me at least) not just a failsafe. It is needed because otherwise ric keeps being respawned whenever it's killed giving another race condition where sometimes it might have time to reboot the phone before it is killed again.
So: This fix should work as long as ric behaves as it does on the kernel that comes with 307.
As I said I also made my own version of a fix in parallel. I wrote it in C as I needed access to some system calls. Basically it is an executable that can be run from whereever one wants to start a program. It runs as a daemon that waits for /sbin/ric to be started. Once it sees ric, it forces ric and itself to run on the same CPU, schedules itself with realtime priority on that CPU so ric never gets a chance to run, replaces the ric executable in /sbin/ric by a dummy version that justs sleeps and kills the original ric process. I could also have deleted it, but whatever respawns ric now don't have to try to start a new process all the time, since it will see that ric is still running.
I have tested my own solution for the past day or so and it seems to work fine. I'll probably post the binary and source code for it later.
008bond said:
My phone switches off after the Xperia wave animation.
Facts:
Locked BL
on .253
Rooted
Did not have the R/W mount issue, but I flashed it anyway
Latest CWM/TWRP recovery
I have Fidelity V4 (If that is of any consequence here)
While flashing it detected that I had busybox (If that is of any consequence as well)
Restoring system from old backup fixed it.
Click to expand...
Click to collapse
Hmm, maybe your ROM chef built in something that conflicts with this script. His own solution to RIC maybe?
Sent from my C6603 using xda app-developers app
[NUT] said:
Hmm, maybe your ROM chef built in something that conflicts with this script. His own solution to RIC maybe?
Sent from my C6603 using xda app-developers app
Click to expand...
Click to collapse
I'm using stock. I think the issue lies with me flashing Fidelity V4.0.
EDIT: I can confirm that Fidelity patch is the issue.
008bond said:
I'm using stock. I think the issue lies with me flashing Fidelity V4.0.
EDIT: I can confirm that Fidelity patch is the issue.
Click to expand...
Click to collapse
Cr*p, I'm out of thanks to give the usual way today, so:
Thanks for the useful info, you scared me a bit there
Carceri said:
Great job with fixing this and making it easy for other people to use in their ROMs.
At first I thought there was a problem with this fix due to a race condition: As far as I can see rootfs is mounted r/w before ric is killed, so I would expect that sometimes ric might start early, see that / is rw and reboot the phone. I was surprised that this did not happen, but actually it seems that ric does not check permissions on rootfs (I could mount it r/w with ric running without getting a reboot).
chmod 644 /sbin/ric is (for me at least) not just a failsafe. It is needed because otherwise ric keeps being respawned whenever it's killed giving another race condition where sometimes it might have time to reboot the phone before it is killed again.
So: This fix should work as long as ric behaves as it does on the kernel that comes with 307.
As I said I also made my own version of a fix in parallel. I wrote it in C as I needed access to some system calls. Basically it is an executable that can be run from whereever one wants to start a program. It runs as a daemon that waits for /sbin/ric to be started. Once it sees ric, it forces ric and itself to run on the same CPU, schedules itself with realtime priority on that CPU so ric never gets a chance to run, replaces the ric executable in /sbin/ric by a dummy version that justs sleeps and kills the original ric process. I could also have deleted it, but whatever respawns ric now don't have to try to start a new process all the time, since it will see that ric is still running.
I have tested my own solution for the past day or so and it seems to work fine. I'll probably post the binary and source code for it later.
Click to expand...
Click to collapse
The way i do the remount of / is no problem in 2 ways: it only remounts when really needed and as it is indirectly executed by init, it will never cause ric to intervene and trigger a reboot. If you have the reboot issue, remounting rootfs (/) from any root explorer app actually does cause a reboot.
About your ric killer application: nice! I've never programmed in C, otherwise I might have attempted something similar. But I know bash/ash scripting, so I fixed it the way I knew best
From my perspective you could make your daemon exit once it has killed /sbin/ric after changing it's permissions to 644. I've been testing my fix for a few days now (on stock kernel and re-locked bootloader) and the method in this thread completely prevents it from starting /sbin/ric ever again :victory:
My daemon does exit once it has killed ric and made sure it cannot start again.
Whatever respawns init keeps checking, so deleting the file, making it non executable or replacing it with a dummy all works. If you chmod 755 it again, ric does respawn on my phone, so something (probably init) keeps trying to start it if it isn't running.
On my phone (before killing ric) mounting / rw does not cause a reboot, but mounting /system rw does. Weird.
Carceri said:
My daemon does exit once it has killed ric and made sure it cannot start again.
Whatever respawns init keeps checking, so deleting the file, making it non executable or replacing it with a dummy all works. If you chmod 755 it again, ric does respawn on my phone, so something (probably init) keeps trying to start it if it isn't running.
On my phone (before killing ric) mounting / rw does not cause a reboot, but mounting /system rw does. Weird.
Click to expand...
Click to collapse
That would be init indeed, as it's a service without 'oneshot' (fires only once, then init stops monitoring) or 'disabled' (init never fires it but it waits for an explicit call to get that service started).
I've found a guide on the Android init daemon/process, I'll post a link to it in this thread tonight, it's an interesting read
I never tried to restart the init process to be able to disable the service though, might be attempting to do so some day. It is what the recoveries do with the chargemon hijack method, they stop all services, unmount everything, cleans up the ramdisk and then unpacks the recovery to start it's init binary.
I'll try that some time soon and see if that will work as well, that would probably be the cleanest way, it would render killric.sh and your application useless as they would no longer be needed, simplifying and 'niceifying' the entire process.
Yep, this fix works perfectly!
Flashed stock .307, unlocked bootloader, flashed @DooMLoRD kernel then rooted through recovery, flashed root fix, flashed stock .307 kernel and then restored TA partition.
Rebooted and used Root explorer in system with R/W permissions. No reboots
Congrats @[NUT] :good:
@Carceri
[NUT] said:
I never tried to restart the init process to be able to disable the service though, might be attempting to do so some day. It is what the recoveries do with the chargemon hijack method, they stop all services, unmount everything, cleans up the ramdisk and then unpacks the recovery to start it's init binary.
I'll try that some time soon and see if that will work as well, that would probably be the cleanest way, it would render killric.sh and your application useless as they would no longer be needed, simplifying and 'niceifying' the entire process.
Click to expand...
Click to collapse
I've been experimenting with that and so far I have not been very successful... apart from not working as i hoped (it reboots after the second init attempt), it also repeats a few parts of the boot process as crtlaltdel is executed too late during the init and thus it will allow you to enter recovery twice for example :silly:
It might be needed to re-hijack the chargemon process as this is executed precisely at the right time for this idea to work... but doing so will break compatibility with all available recoveries... and throws in some caveats for the recovery users... just the thing i was trying to fix for all and any of the Z/ZL lovers
Stuff to ponder on...
*ponders on* Maybe I can use the ctrlaltdel script to 'fix' anything that breaks and then trigger a reboot to make sure the user gets to boot in to a good working android...
chargemon would be my new rickiller script, it checks for the flagfile it creates itself, if it's not found it will do the RIC fix, then create's the flagfile and restarts init. With the second init it will find the flagfile and will execute the re-hijacked chargemon hijack script to offer recovery. If not chosen to enter recovery it will just continue boot.
Once ctrlaltdel gets started it checks if the md5sum of the chargemon script is what it's supposed to be. If not, it will create a backup of that chargemon file for execution by the re-hijacked chargemon script that it copies from a backup file somewhere (probably simply in /system/bin) corrects permissions and then triggers a reboot...
PRECAUTION: This post is on the file attached, it has no meaning regarding the OP: that fix works just fine.
Well, I'm putting my scripting online that i wrote on the above idea for those in the know, I'm not sure why it does not work but
THIS DOES NOT WORK
For anyone who wants to help out, you are welcome to take a look... you can even try it (put the 2 files inside /system/bin) but note the warning above...
To recover from the tantrum it throws, be sure to have an unlocked bootloader and DooMKernel installed. You will need TWRP to get you out of trouble, which is easy: mount system, use advanced -> filemanager and look inside /system/bin. chmod chargemon and ctrlaltdel to 644. Reboot and you're out of trouble.
Who has any idea why this does not work?
well, it sadly doesn't help me.. I'm on Odexed Stock ROM .307
if I try to rename / delete / add an apk into /system/app/ my phone still reboots..
FSN said:
well, it sadly doesn't help me.. I'm on Odexed Stock ROM .307
if I try to rename / delete / add an apk into /system/app/ my phone still reboots..
Click to expand...
Click to collapse
Can you check if there is a file called killedric in /tmp?
Sent from my C6603 using xda app-developers app
[NUT] said:
Can you check if there is a file called killedric in /tmp?
Sent from my C6603 using xda app-developers app
Click to expand...
Click to collapse
I don't have this file. Locked BL, flashed w/ TWRP 2.4.0.0
FSN said:
I don't have this file. Locked BL, flashed w/ TWRP 2.4.0.0
Click to expand...
Click to collapse
Right, then check things in succession, stop and report which you stopped at:
1. Check if /system/bin/killric.sh exists.
2. Open /system/bin/ctrlaltdel to see if it looks like the one on the OP.
3. Open a terminal app and see if killric.sh is running by typing the command 'ps | grep killric.sh'
If you have to say no to 1 and 2, reflash the zip. Then try again, if it still fails send me the logs from /cache/recovery
Sent from my C6603 using xda app-developers app
[NUT] said:
Right, then check things in succession, stop and report which you stopped at:
1. Check if /system/bin/killric.sh exists.
2. Open /system/bin/ctrlaltdel to see if it looks like the one on the OP.
3. Open a terminal app and see if killric.sh is running by typing the command 'ps | grep killric.sh'
If you have to say no to 1 and 2, reflash the zip. Then try again, if it still fails send me the logs from /cache/recovery
Sent from my C6603 using xda app-developers app
Click to expand...
Click to collapse
1. Yes
2. Yes
3. If it returns 1 it runs, right?
Could it have something to do with the exFAT patch (for 64GB sd cards)?

Working with su.d

Hi @Chainfire,
So, a while ago, I posted in the Liveboot thread inquiring as to how I'd go about incorporating liveboot into a ROM so that it could just run on first boot.
Your instructions were to chmod 0770 both the files and folders in su.d, and it should work:
If /system/su.d/0000liveboot.script exists (chmod 0644, not 0700 like other files in /system/su.d/ !), this script will be run instead of logcat and dmesg, and its output will be shown in white (stdout) and red (stderr).
Click to expand...
Click to collapse
However, I tried this, and never got it to work, and essentially moved on to other stuff for a while.
Today, I tried to revisit it, and while I was at it, replace my current init.d stuff with su.d.
So, I created the folder in /system which gets copied with t he rest of the ROM on install. I'm setting folder and file permissions to 0700, owner and group to root, SE context to ubject_r:system_file:s0, which, is exactly the same as what I'm seeing on 0000liveboot when I look at it's info.
This leaves two questions.
One, the above quote you say to set it to 0644, but liveboot itself sets it to 0700 when it installs it.
Two, what is the trick to getting other scripts to work? In your "How to SU" guide, you mention this:
From versions 2.22 onwards, after the policies have been patched and the daemon is ready to go, all executables in the /system/su.d/ directory are executed (chmod 0700 both the directoy and the scripts), followed by setprop supolicy.loaded 1. This is akin to /system/(etc/)init.d/, though execution of those scripts is both kernel-dependent and they may run before the SELinux are patches and/or su is available.
Click to expand...
Click to collapse
Setprop supolicy.loaded. Where am I supposed to do that? You say execution of those scripts is kernel-dependent - you're referring to init.d, yes? So, again, what am I missing?
This is 5.0.1 GPE for M8VZW. I have selinux set to permissive via boot image in init.rc, and verify that "getenforce" returns "permissive" from shell.
Any help you could lend would be greatly appreciated - which is also why I'm posting this as a thread...because su.d sounds like an awesome idea, and I bet more devs would like to start using this method over init.d.
Thank!
digitalhigh said:
One, the above quote you say to set it to 0644, but liveboot itself sets it to 0700 when it installs it.
Click to expand...
Click to collapse
liveboot sets the script that gets run by SuperSU to 0700. The script which I said to be set 0644 is a different script, and is not executed by SuperSU, but by liveboot.
Setprop supolicy.loaded. Where am I supposed to do that?
Click to expand...
Click to collapse
You don't. SuperSU sets this. Kernel developers can hook this event to run their own code.
You say execution of those scripts is kernel-dependent - you're referring to init.d, yes?
Click to expand...
Click to collapse
Yes, not all kernels support init.d, and init.d stuff generally runs before SuperSU patches policies, so there's no guarantees about any SELinux state.
So, again, what am I missing?
Click to expand...
Click to collapse
I don't know. Make sure you are running the latest version of SuperSU (2.46 at the time of writing). Make sure /system/su.d is chmod 0700. Make sure the scripts you want to run are also chmod 0700 and #!'d to a working shell executable. Keep in mind that the scripts are called one-by-one, in a blocking way. So if a script never exits, the next script isn't run.
Deleted
Say I have SU v2.62. I have 2 files in my /system/su.d folder. The first file doesn't have an exit, neither does the second. The second file DOES get executed as it sets selinux to permissive at boot as directed. First file is 0700 (text file), second is 0755 (a .sh file).
Now, I want to take an init.d setprop script and try it via su.d.
1) Do the other files need exit commands?
2) What should the third file (setprop file) be set to, 0755? A .sh or text file?
3) Are the other two set to the correct chmod?
Thank you for any input!
EDIT: Left it as text, and 0755. No exits, and it worked?
Using su.d to disable doze
Is it possible to use su.d in order to load a script that disables Android doze mode?
I'm trying to run this script:
Code:
#!/system/bin/sh
dumpsys deviceidle disable
Script file is located in root\su\su.d
Permissions are set to 0700.
However, script is not loaded automatically during the boot, because if I run the script manually in SManager I get a response Idle mode disabled, which means su.d script wasn't loaded.
Currenlty I use SManager to execute this doze disabling script automatically on every boot, but I wonder why wouldn't the same script work using su.d?
I use another su.d script that disables LED back-lights of hardware navigation buttons and the script works just fine.
I'm using SuperSU v2.82
Thanks for your input.

[Q] How to change device name?

Hi,
I'm rooted and have recently tried changing the device name of my Nexus 6 via terminal using:
Code:
setprop net.hostname <new-hostname>
This works as expected, however the change isn't persistent and doesn't seem to survive a reboot.
Does anybody know how I can make the change stick?
even play store apps can't change it
Script it. Init.d, su.d, tasker, script manager.

[Magisk][Module][Deprecated] Unified Hosts Adblocker

This mod has since been discontinued in favor of Adaway. Read on for information on how to use Unified Hosts with Adaway
What are Unified Host Files?
Unified host files combine many reputable sources into a single hosts file (with duplicates removed). Some examples include adaway, mvps, yoyo.org, and malware domain list (see Steven Black's page here for a complete list).
Adaway Installation for Magisk:
Adaway version 4.x now works properly with magisk systemless hosts. To enable it, just install the latest version from here (the main xda thread for it hasn't been updated for it yet). Then go to Preferences -> Enable systemless mode. This automatically enables the Systemless hosts option in magisk manager so no need to bother with that. Then use the app as normal.
How to Add Unified Hosts to Adaway:
In the adaway app, go to Preferences -> Redirection IP (NOT Allow Redirects). Change the value to 0.0.0.0. Read the readme on Steven Black's GitHub linked above for why.
Then go to Hosts Sources. Then add the url of the unified hosts you want (ONLY CHOOSE 1):
Master: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
Master+FakeNews: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews/hosts
Master+Gambling: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling/hosts
Master+Porn: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/porn/hosts
Master+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/social/hosts
Master+FakeNews+Gambling: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts
Master+FakeNews+Porn: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-porn/hosts
Master+FakeNews+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-social/hosts
Master+Gambling+Porn: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-porn/hosts
Master+Gambling+Social https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-social/hosts
Master+Porn+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/porn-social/hosts
Master+Fakenews+Gambling+Porn (This is the one I use): https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts
Master+Fakenews+Gambling+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-social/hosts
Master+Fakenews+Porn+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-porn-social/hosts
Master+Gambling+Porn+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-porn-social/hosts
Master+Fakenews+Gambling+Porn+social: https://raw.githubusercontent.com/S...lternates/fakenews-gambling-porn-social/hosts
You can then uncheck the host sources already added by default to adaway since they're included in unified hosts sources already
**Note that the 'Social' filter does exactly what you think: blocks social networks. So if you use any kind of social networking, DO NOT CHOOSE THIS ANY SOURCE WITH THIS IN IT**
Using a APN that uses a proxy server or a subsidiary provider and unable to get adblocking working? See here for a fix
Original Mod Information:
Description
Blocks ads by using Steven Black's Unified Hosts
Comes with a small utility based off of LarappsOfDongle's RP modular host module that allows you to choose which kind of host file you want (adware/malware, fakenews, gambling, porn, social, or any combination)
Installation
Go to Settings in Magisk Manager and enable 'Systemless Hosts'
Flash module
Open terminal and type:
Code:
su
hosts
Then follow the prompts to install the host file of your choice.
OR
- Open terminal and type:
Code:
su -c hosts arg1 arg2 arg3
- The script will apply your arguments all at once and close. Useful for automation purposes
- For example: `su -c hosts m wr b`
- Script will apply the master filter, then your regex whitelist, then your blacklist
Updating Hosts:
Just run the hosts file again in terminal and it'll overwrite the old one
Note: The script will now notify you to say if you need to update or not at the top of it
Disabling Host Mod:
Just toggle the enable systemless hosts option in magisk manager
Whitelist Instructions:
Create an empty file on sdcard card called "whitelist"
Either add exact lines you want remove to it -> Run hosts script and choose whitelist option
For example:
Code:
0.0.0.0 facebook.com
Will unblock facebook.com
Or add regex for lines you want removed -> Run hosts script and choose whitelist regex option
For example:
Code:
.*facebook.*
Will unblock all domains with "facebook" in them
Blacklist Instructions:
Create an empty file on sdcard card called "blacklist"
Add exact lines you want to remove it (do not include the 0.0.0.0 -> so for example: "facebook.com")
Run hosts script and choose blacklist option
For example:
Code:
google-analytics.com
Will block the google-analytics.com domain (it will add the entry "0.0.0.0 google-analytics.com" to the hosts file - note the lack of the 0's here. The script takes care of it automatically for the blacklist feature)
To Remove Whitelist:
Just run hosts script and reinstall host file of choice
Latest Magisk Version Compatibility:
15.x
Source
Can't Boot?
Try rebooting into the bootloader, then boot into system. Thanks @rignfool for the tip
Bonus!
I made a quick automate flow to update the hosts file. Just import it, add a shortcut to your home screen, and you can update it in one click
Just change the 2nd block to whatever options you want
@Didgeridoohan made a tasker profile here for any who use tasker: https://forum.xda-developers.com/showpost.php?p=73369050&postcount=451
Download
How does this differ from AdAway?
serubin323 said:
How does this differ from AdAway?
Click to expand...
Click to collapse
The unified hosts file combine many sources including AdAway, mvps, malware domains, and more. Check out steve black's page in the op for a full list.
Also, for some reason, adaway wouldn't detect the systemless hosts file for me so i had to set a custom path and symlink it
Updated module for latest magisk manager update (required changes to the readme). Doesn't change the functionality of the module at all so if you're in 1.1, there's no need to upgrade since these readme changes will only be reflected in magisk manager once this module is approved into the repo.
Damnit... Wrong thread...
OK...
Syntax...
su -c hosts ______
Please fill in the blank...
rignfool said:
Damnit... Wrong thread...
OK...
Syntax...
su -c hosts ______
Please fill in the blank...
Click to expand...
Click to collapse
Code:
su
Give root permissions
Code:
hosts
Program will prompt for input. For example, if you want malware/adware (master) + fakenews + gambling, you're input would be:
Code:
fg
The reason for not including the master (adware/malware) in the arguments is that it's already included by default in each host file. So the fakenews host file is actually master + fakenews. It's how steven set it up so I have no control over it (and who wouldn't want the malware block anyways)
Found a typo in the directions for the host file. Once again doesn't effect functionality at all but does eliminate confusion so uploaded fixed version (sorry)
Zackptg5 said:
Give root permissions
Program will prompt for input. For example, if you want malware/adware (master) + fakenews + gambling, you're input would be:
Click to expand...
Click to collapse
I'm looking to execute as a one line shell command with tasker...
So I'm using 'su -c' cuz SU detection in tasker with magisksu is broken...
Then hosts... But I want to run with an argument so I don't need to interact with the script... Just have it update the hosts file...
rignfool said:
I'm looking to execute as a one line shell command with tasker...
So I'm using 'su -c' cuz SU detection in tasker with magisksu is broken...
Then hosts... But I want to run with an argument so I don't need to interact with the script... Just have it update the hosts file...
Click to expand...
Click to collapse
I've never used tasker (use automate instead). Perhaps
su -c; hosts; sleep 1; fgps; sleep 2; q
Not sure if the sleep command works for tasker (linux thing) but if there's a way to have it wait a half a second or so before inputting the next command, and then waiting 2 seconds or so to quit after the hosts is applied (not sure on the time, just guessing).
Edit, just saw you didn't want to deal with the script. The 'hosts' command is the script. If you look my source for the hosts script, it lists each url for the file and what it does. So all of the terminal code for fgps would be:
Code:
su -c
cd /magisk/.core
wget -O hosts --no-check-certificate https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
This will replace the systemless hosts file with the one you want. Note you will at least need the wget portion of the module (system/bin) since it's not included in most roms
v1.3 update: Noticed that the disable option was broken so I removed it since it's not needed (see OP for disable instructions)
Using ze551ml, after rebooting, module disappeared. I can't find hosts command anywhere.
danzel said:
Using ze551ml, after rebooting, module disappeared. I can't find hosts command anywhere.
Click to expand...
Click to collapse
Does magisk manager say root is enabled? There's been an ongoing issue where root will disappear and so all modules will disappear as well. This isn't a module issue but a magisk issue
Automating hosts update?
Hi Zack!
Love your module, thank you!
Is there a way I can update with FG running a shell command from Tasker?
When I try
Code:
echo fg|hosts
it does download the fg file, but then it infinitely loops and never quits, until I send a CTRL-C to the terminal.
Could you please make it so hosts accepts arguments from the command line, instead of a menu?
Thank you!
Yom said:
Hi Zack!
Love your module, thank you!
Is there a way I can update with FG running a shell command from Tasker?
When I try
Code:
echo fg|hosts
it does download the fg file, but then it infinitely loops and never quits, until I send a CTRL-C to the terminal.
Could you please make it so hosts accepts arguments from the command line, instead of a menu?
Thank you!
Click to expand...
Click to collapse
The menu is part of the command line. I don't have tasker however, maybe this post will help: https://forum.xda-developers.com/showpost.php?p=71117156&postcount=9
You can circumvent running the script completely and just wget your host of choice. In that post, I have a link to the source for the hosts file with all of the urls. For fg for example, it would be: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts
Yom said:
Hi Zack!
Love your module, thank you!
Is there a way I can update with FG running a shell command from Tasker?
When I try
Code:
echo fg|hosts
it does download the fg file, but then it infinitely loops and never quits, until I send a CTRL-C to the terminal.
Could you please make it so hosts accepts arguments from the command line, instead of a menu?
Thank you!
Click to expand...
Click to collapse
As @Zackptg5 says, to automate with Tasker it's easier to just circumvent the script altogether...
I have a Tasker profile set up to fetch the hosts file directly from Steven Blacks GitHub and save it to /magisk/.core/hosts. I couldn't get wget to work properly with Taskers Run Shell, so I used the HTTP Get instead to fetch it to /sdcard and then Run Shell to move it to /magisk/.core/hosts (and to remove it from /sdcard afterwards).
Is there a possibility of whitelists?
ChronoReverse said:
Is there a possibility of whitelists?
Click to expand...
Click to collapse
In theory, you shouldn't need a white list with these hosts files. I chose them because they are gone over with a fine tooth comb so you shouldn't have any issues. However, when I get on spring break, I could attempt to add a whitelist option to the script. I was thinking the easiest way to do this would be to read a text file (would be a blank one in the module folder by default but is editable the uses to add whatever) and remove any matches from the host file. Have any better ideas to implement this? I have no experience with GUI development and that would add unnecessary overhead anyways
Does this module work currently? I disabled adaway and enabled this but it's not blocking ads that adaway blocks.
Testcase: root check by Jrummy
Adaway blocks the in app ads. This module does not
EDIT: apparently I can't read... Lol. Followed the Op and now it works great!
Neat module. It's working great! Thanks for sharing it!
Yom said:
Hi Zack!
Love your module, thank you!
Is there a way I can update with FG running a shell command from Tasker?
When I try
Code:
echo fg|hosts
it does download the fg file, but then it infinitely loops and never quits, until I send a CTRL-C to the terminal.
Could you please make it so hosts accepts arguments from the command line, instead of a menu?
Thank you!
Click to expand...
Click to collapse
I have a profile set up to do this every 12 hours. If you still need it, I updated it to use your preferred settings and exported it. All you need to do is import it in Tasker (long-press Profiles header) and turn it on.

Magisk boot script help for pixel 2 xl

Hi guys,
I'm trying to make a script to enable the android 11 notification shade blur in my pixel 2 xl,, so far I have managed to successfully enable it with ADB with this command:
adb shell
taimen:/ $ su
taimen:/ # setprop ro.surface_flinger.supports_background_blur 1
taimen:/ # stop
taimen:/ # start
It does work fine but as soon as the phone reboots it is lost
I made a magisk module and also managed to make a setprop mod with magiskhide that does indeed successfully add ro.surface_flinger.supports_background_blur 1 in build.prop, but the mod does not work unless I adb and input the command
adb shell
taimen:/ $ su
taimen:/ # stop
taimen:/ # start
I believe this is to restart system UI.
Is there any way to do this in magisk automatically at boot?
When I input in termux
su
# stop
The phone seems to try to restart the UI but it gets stuck in google logo, unlike when I do it via adb the screen goes blank and comes back alive when I input via adb
# start
I'm a complete noob in this stuff, I would really like to make a magisk script or module that let me do this, it would be useful to try first via termux to avoid a magisk boot loop in case something goes wrong with this script. The notification blur is actually the only reason I unlocked the bootloader an rooted the phone...
Thanks in advance.
You should use Magisk's resetprop tool.
All you should need in your boot script is this:
Code:
resetprop ro.surface_flinger.supports_background_blur 1
Try using service.d first, but if that doesn't work move the script to post-fs-data.d.
Or, if you're using a module, use a system.prop file.
Does "magiskhide props config 5.3.6" uses resetprop?
I did try that in service.d and post-fs-data.d
As I said, the property does seem to be changed with the setprop, since after a restart of the phone all I need to do is
Adb shell
Su
Stop
Start
And I get the blurred notification shade...
Yes, MagiskHide Props Config uses resetprop (but there you generally don't need to change to late_start service or post-fs-data, the default should be fine most of the time).
With resetprop you shouldn't need to run stop/start. That's the difference.
I did not try the delay option. I really don't know what else I could try though...
Maybe there's a delayed script I could run with the stop/start command?
Edit: sorry if I understand what you're saying, should I delete the magiskhide props config key and instead do it manually? That way I should no need the stop/start command.
I thought you had been doing it manually all along... To quote your first post: "I'm trying to make a script", "I made a magisk module and also managed to make a setprop mod".
If the stop/start commands need to be included for this to work, making your own boot script with the resetprop command and stop/start commands is the way to go.
Yeah yeah sorry, I did manage to make the module, the setprop mod I was referring to was via magiskhide...
My problem is when I try to run this stop/start script in termux
#!/system/bin/sh
su
cd
cd data/adb
stop
start
The phone goes to google logo and is stuck there, I'm afraid if I do that with magisk I could get a non booting phone...
Does this script sounds good to you?
#!/system/bin/sh
resetprop to.surface_flinger.supports_background_blur 1
stop
start
BTW I really appreciate your help!
Edit: just ran this script from termux and stuck at google logo...
Edit 2: if anyone is wondering or maybe it helps someone I ended up making this simple script in service.d
resetprop to.surface_flinger.supports_background_blur 1
Then I discovered all I needed was the terminal command
# killall surfaceflinger
And Systemui does successfully restart with the blurred background, so I created a home screen shorcut with this terminal command and all I need to do is hit the shorcut shortly after booting and it works, it's not automatic but it gets the job done...
Thanks @Didgeridoohan for your help... XDA rocks!
Hello!
I don't know if you're still looking for this but decided to share anyway.
Attached to this post is a Magisk module that enables Background Blur that survives reboots....
It's weird that a simple Magisk module with a system.prop doesn't work but ok... had to create this version which uses a service.sh script to do the job.
You'll need Magisk, obviously.
Enjoy!
Cheers!
Thank you for making this. The double restart is kinda annoying tho
Typhus_ said:
Hello!
I don't know if you're still looking for this but decided to share anyway.
Attached to this post is a Magisk module that enables Background Blur that survives reboots....
It's weird that a simple Magisk module with a system.prop doesn't work but ok... had to create this version which uses a service.sh script to do the job.
You'll need Magisk, obviously.
Enjoy!
Cheers!
Click to expand...
Click to collapse
Is this module device specific or will it work on other devices running Android 11?
rodken said:
Is this module device specific or will it work on other devices running Android 11?
Click to expand...
Click to collapse
It should work on any device running Android 11.
Typhus_ said:
It should work on any device running Android 11.
Click to expand...
Click to collapse
Perfect - functions as expected on OnePlus 8 OOS 11.
How about android 13?

Categories

Resources