Sample Header Ad - 728x90

How to run .sh script (iptables commands) on start up

3 votes
2 answers
1639 views
I am using LineageOS 18.1 When I was on LOS 16, I used to edit the file /system/etc/init.d/00banner and put my iptables commands there, e.g.:
#!/system/bin/sh
sh -c 'iptables -A OUTPUT -m owner --uid-owner 10195 -d 203.205.255.78/23 -j REJECT'
All iptables commands I put in there used to run on phone start up. But in LOS 18.1, the /system/etc/init.d/ directory was deprecated. **1.** I created and filled the custom script with the *iptables* commands above:
touch /system/etc/custominit.sh
chmod 0755 /system/etc/custominit.sh
**2.** Then I edited /system/etc/init/hw/init.rc and I added to the end:
chmod 0755 /system/etc/custominit
exec /system/etc/custominit
**3.** I also tried adding:
service custominit /system/bin/custominit.sh
    disabled
    oneshot
But none of this worked. What is it that I doing wrong? I have root access but I do not want to install any additional apps on my phone for this, as it was possible to do on LOS 16.
Asked by user363569
Nov 21, 2021, 10:49 AM
Last activity: Nov 22, 2021, 05:16 AM