Cm data connect persistant after reboot

I need my data connection also need to be persistant when i connect my board to laptop

for now. I am able to automate the process till NAT rules and iptables, so only i have to use ‘cm data connect’ through ssh to get internet on my laptop

but I included below in my init script still i am not able to get internet access over ethernet from mangOH yellow to my laptop
**
cm data connect >/dev/null 2>&1 &**

could you tell me how to make above command persistant

  1. create a script startdata.sh in /home/root with the following content:

root@swi-mdm9x28-wp:~# cat startdata.sh
sleep 30
/mnt/legato/system/bin/cm data connect

  1. chmod 777 /home/root/startdata.sh
  2. you can test this script by “sh /home/root/startdata.sh”
  3. if it is ok, open /etc/init.d/startlegato.sh and add the following line:
case “$1” in
start)
echo “Legato start sequence”

    umount /legato 2>/dev/null
    mount -o bind $LEGATO_MNT /legato

    test -x $LEGATO_START && $LEGATO_START

sh /home/root/startdata.sh &
;;

my startdata.sh already have below script. could you please tell me at which location i should add your given piece of code?

#!/bin/sh

sleep 10

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -C POSTROUTING -o rmnet_data0 -j MASQUERADE 2>/dev/null ||
iptables -t nat -A POSTROUTING -o rmnet_data0 -j MASQUERADE

iptables -C FORWARD -i ecm0 -o rmnet_data0 -j ACCEPT 2>/dev/null ||
iptables -A FORWARD -i ecm0 -o rmnet_data0 -j ACCEPT

iptables -C FORWARD -i rmnet_data0 -o ecm0 -m state --state RELATED,ESTABLISHED -j ACCEPT 2>/dev/null ||
iptables -A FORWARD -i rmnet_data0 -o ecm0 -m state --state RELATED,ESTABLISHED -j ACCEPT

exit 0

maybe you can add it at the beginning of the script:

i.e.

sleep 30
/mnt/legato/system/bin/cm data connect

sleep 10

I followed your instructions, but below command is is halted in execution.

There is also one thing which i want to highlight that when I do cm data connect then manually every time i have to type Ctrl + C to come out of execution and then data is conneted.

root@swi-mdm9x28-wp:~# chmod 777 /home/root/startdata.sh

so I am not sure if ‘cm data connect‘ itself is the problem or not because rest of the script is behaving correctly.

I did not try reboot yet as it is giving me problems in chmod itself. please guide

i don’t see problem to run this script



sleep 30
/mnt/legato/system/bin/cm data connect

It worked with me but a little modification which is mentioned below

sleep 30
/mnt/legato/system/bin/cm data connect &

Thank you jyijyi !!