• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

Execute a script at boot

Search This thread

stevexce

Senior Member
Dec 21, 2014
92
10
Can't execute my script on boot even with 30s delay before each command. Manual executing works perfectly. I put .sh file to /sbin/.magisk/img/.core/service.d/

Code:
#!/system/bin/sh
sleep 5
insmod /storage/emulated/0/modsAndApps/xt_HL.ko
sleep 5
/system/bin/iptables -t mangle -A POSTROUTING -j TTL --ttl-set 64
 

Didgeridoohan

Senior Moderator / Dev Committee / Dev Relations
Staff member
May 31, 2012
11,693
12,576
Gothenburg
Google Nexus 4
Nexus 6
Can't execute my script on boot even with 30s delay before each command. Manual executing works perfectly. I put .sh file to /sbin/.magisk/img/.core/service.d/

Code:
#!/system/bin/sh
sleep 5
insmod /storage/emulated/0/modsAndApps/xt_HL.ko
sleep 5
/system/bin/iptables -t mangle -A POSTROUTING -j TTL --ttl-set 64

Just to make sure: you've given the script execution permission, right?

If you have, try to look for sys.boot_completed instead of doing random sleep intervals (see the post before yours).
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    It is causing delayed notification on some apps.
    Oreo
    Credit @return_of_0ctobot

    while [ "$(getprop sys.boot_completed)" != 1 ];
    do sleep 1;
    done

    Much more universal ... And does not require trial and error to find boot completed
    1
    A couple of things:
    1. You don't need to call su in the boot script. It's being executed by Magisk, which always has superuser access...
    2. post-fs-data.d might be too early. Try moving it to service.d instead. Depending on when that's being set during boot, you might also have to add a delay as to when the command is being run.
    1
    Something like that might work, yes. Have you made sure that the command works at all on your device? If it does it's likely a matter of finding the correct delay...
    1
    It seems it is working now, thanks for the tip "delay"
    1
    It seems it is working now, thanks for the delay tip

    No worries. Been there, done that, pulled my hair out in frustration... :laugh: