# Help..... Startlegato.sh dissappeards from /etc/init.d

**URL:** <https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926>\
**Category:** Legato Application Framework\
**Created:** [August 9, 2021, 4:31pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926 "2021-08-09T16:31:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 9, 2021, 4:31pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/1 "2021-08-09T16:31:59Z")

</div>

Hi, I have my own cwe file based on 16.10.1.m3 (FX30s) that generally runs well. I have a custom startlegato.sh file that checks a for a 3rd script and runs it if present…

I have one country/network where modems seem to stop connecting (we’d sent a replacement modem which did exactly the same). Finally haven gotten a modem back to check, and digging through the files, I see that startlegato.sh has dissapeared from /etc/init.d and legato is not running.

What can cause this to happen in the field? It runs OK for a few weeks then suddenly stops uploading and since legato is no longer running I have no way of restarting it…

legato status shows the image is “good” but legato is not running…

Why would startlegato vanish… After starting legato manually, it seems to have put back startlegato.sh into the correct place, but its my custom one…

Any ideas?

_ **UPDATE** _  
The way I set up these devices, is to flash my own CWE file and then run a few scripts, one of which updates/copies in my startlegato.sh file into /etc/init.d… so I am wondering if there is a situation (like system reset of some sort), that would replace all the files and therefore overwrite that folder thereby removing my file? If that is the case, then how to I go about including startlegato.sh in the cwe images?

I should add that these devices are connected to AirVantage and various commands can be run from there… but I don’t believe the FW was replaced…

Thanks,  
Karl

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 10, 2021, 1:02am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/2 "2021-08-10T01:02:16Z")

</div>

Only this file disappears?

is your own 3rd script files still there?

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 10, 2021, 6:50am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/3 "2021-08-10T06:50:30Z")

</div>

Hi @jyijyi, thanks for the reply.

Yes it is the only file I have spotted to have dissappeared.

My script file (the 3rd script I refer to) is in the home directory is created on the fly when I want to change some config (APN details in this case) remotely.

i.e. my app received my request to change the APN (via SMS). The app puts the script into the home directly and restart the module. On start up the startlegato.sh script in the init.d directory does its usual thing, but also checks if this script is there and runs it if it is… and then deletes it…

So that “3rd” script was not there… but that does not mean it was removed? Other files in the home directly remain…

Also

> After starting legato manually, it seems to have put back startlegato.sh into the correct place, but its my custom one…

might be a misleading… as my application on start up checks startlegato.sh is in the init.d folder… but its a bit useless… as it only works if legato runs ;-/

Thanks,  
Karl

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 10, 2021, 6:59am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/4 "2021-08-10T06:59:14Z")

</div>

could there be chance that power cut during you modify startlegato.sh ?

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 10, 2021, 7:26am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/5 "2021-08-10T07:26:41Z")

</div>

Hmmm… if it had happened once… I’d say possibly… but this has happened a few times to this modem, so unlikely I think… but you are suggestion something goes wrong in replacing the file? What would the timing of that need to be? i.e. would the faliure have to happen in the few micro seconds the file is written? Or is there a time delay after it is written where the failure/restart would need to happen?

Is it possible the FW “restored” itself because of some other failure and replaced the files? Although I’d then expect startlegato.sh to just be the default one?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 10, 2021, 7:44am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/6 "2021-08-10T07:44:46Z")

</div>

if you are talking about rollback mechanism, i don’t quite think it happens.  
As when you manually start the legato, your legato application are all there.

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 10, 2021, 8:10am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/7 "2021-08-10T08:10:07Z")

</div>

Ah yes good point… any ideas what else could cause this?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 10, 2021, 8:16am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/8 "2021-08-10T08:16:28Z")

</div>

As your application will overwrite the startlegato.sh, I think this is the cause.  
Do you need to overwrite this file in each boot up?

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 10, 2021, 9:03am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/9 "2021-08-10T09:03:15Z")

</div>

No it does not… this was bad design… For interest sake, what is the write cycle limit on the flash?

I will look at changing this… but I need to first re-create the problem repeatably to know I have fixed it…

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 10, 2021, 9:13am UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/10 "2021-08-10T09:13:33Z")

</div>

I guess it is 100000

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 10, 2021, 3:02pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/11 "2021-08-10T15:02:32Z")

</div>

OK, I’ve made a little progress. I’ve managed to connect to the device in the field, via the customers PC and USB cable.

I see the following things.

1. legato is not running as above
2. the startlegato.sh file is not in /etc/init.d/ as above
3. when I try can cp the file back in, I get the following error **“input/output error linux”**. I am able to cp the file in as startlegato1.sh… but when I try to rename it I get the same error.

1. running dmesg I see the following towards the end of the log…**aufs au\_lkup\_dentry:223:chmod[844]: I/O Error, both of real entry and whiteout found, startlegato.sh, err -5**

I am not a linux expert… so not sure what this points at… any thoughts?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 10, 2021, 3:17pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/12 "2021-08-10T15:17:08Z")

</div>

Maybe you need to use swiflash to recover the module

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 12, 2021, 12:57pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/13 "2021-08-12T12:57:49Z")

</div>

Hi @jyijyi thanks for the response.

I’ve tried reflashing the mcu…xxxxxx.cwe and my legato.cwe using fwupdate. The re-flashing worked… but it has not restored the startlegato.sh file in /etc/init.d

Is there a way to say format the file system and then re-flash it from Windows (the customer does not have a linux machine).

Factory Reset (using the pushbutton) did not manage to replace the file either.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 12, 2021, 1:04pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/14 "2021-08-12T13:04:01Z")

</div>

Did you try swiflash tool to recover it?

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 12, 2021, 1:06pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/15 "2021-08-12T13:06:25Z")

</div>

Yes, but I think it needs to effectively rewrite all the linux and legato system files? i.e. re-install linux… or something. What is the most original state I can get the modem to?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 12, 2021, 1:27pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/16 "2021-08-12T13:27:43Z")

</div>

I think swiflash has a recovery mode to back to default state

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 12, 2021, 1:28pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/17 "2021-08-12T13:28:43Z")

</div>

Thanks, but I think that is for Linux client. I only have a Windows machine available?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 12, 2021, 1:41pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/18 "2021-08-12T13:41:53Z")

</div>

You can download the window version here

[http://downloads.sierrawireless.com/tools/swiflash/swiflash.zip](http://downloads.sierrawireless.com/tools/swiflash/swiflash.zip)

---

<div class="post-metadata">

**Author:** ![karlkuhn](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@karlkuhn](https://forum.legato.io/u/karlkuhn)\
**Post date:** [August 12, 2021, 2:47pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/19 "2021-08-12T14:47:32Z")

</div>

Thanks, but the -reset option does not seem to replace system files? How do I get all system files to be replaced?

Seperately I was wondering if using something like fsck would help solve the problem… but I can’t get that to work as /etc is mounted. Can’t umount it, because it is use…

Any other thoughts?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [August 12, 2021, 2:59pm UTC](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926/20 "2021-08-12T14:59:51Z")

</div>

can it recover the startlegato.sh file?

[Next page](https://forum.legato.io/t/help-startlegato-sh-dissappeards-from-etc-init-d/5926.md?page=2)
