# How to run shell script after boot

**URL:** https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278
**Category:** Uncategorized
**Created:** [June 3, 2021, 6:52am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278 "2021-06-03T06:52:20Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 3, 2021, 6:52am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/1 "2021-06-03T06:52:20Z")

</div>

Customer would like to run shell script after WP76 module boot.

Customer put as following code in the /etc/init.d/legatostart.sh. Then, WP76 module can run shell script automatically. But customer saw that WP76 module sometimes delete their application after modifying legatstart.sh file.

# Please advise how to run shell script after module boot.

umount /legato 2\>/dev/null  
mount -o bind $LEGATO\_MNT /legato  
test -x $LEGATO\_START && $LEGATO\_START

sh /home/root/test1.sh & // customer shell  
;;

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 3, 2021, 7:24am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/2 "2021-06-03T07:24:46Z")

</div>

Does it solve if you add a sleep(5) in beginning of /home/root/test1.sh ?

Another method is to run an unsandboxed helloworld application and call your /home/root/test1.sh by system() API.

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 3, 2021, 9:34am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/3 "2021-06-03T09:34:05Z")

</div>

After modification for “sleep 5”, customer is working 3 times. But WP76xx module delete application at 4 th boot-up everytime.

Please let us know how to call shell script from API? If possible, please prepare sample adef and c code.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 3, 2021, 10:26am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/4 "2021-06-03T10:26:56Z")

</div>

It is probably because you did not type “update -g” after installing the new app.

For sample legato app, you can see

> **[Invoking shell scripts from Legato app](https://forum.legato.io/t/invoking-shell-scripts-from-legato-app/5575/4)**
>
> I don’t see problem on WP76 FW R13. You can use my hello6.tar.gz. hello6.tar.gz (314.7 KB) root@swi-mdm9x28-wp:~# chmod 777 /tmp/test.sh root@swi-mdm9x28-wp:~# /tmp/test.sh root@swi-mdm9x28-wp:~# ls /tmp/123.txt /tmp/123.txt ...

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 4, 2021, 8:56am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/5 "2021-06-04T08:56:02Z")

</div>

Customer type “update -g” after installing the new application.

Their application is working 5 times from 3 times. But WP76xx module delete these application at 6th boot-up everytime.

Customer will check sample app later, if you have any comment, please advise it.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 4, 2021, 9:12am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/6 "2021-06-04T09:12:48Z")

</div>

seems your application is making system unstable, and there is rollback mechanism if there is too much reset

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 7, 2021, 12:28am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/7 "2021-06-07T00:28:28Z")

</div>

Customer application will use only WP76xx module w/o external Host CPU.  
If WP76xx module cannot connect USB interface, WP76xx module went to sleep mode and did not work their application.  
So, I received attached wakeup\_app from SWI. But customer said that WP76xx module sometimes remove this wakeup\_app.  
Please check this application is making system unstable. If this application is making system unstable, please let us know how to run their application w/o Host USB interface connection.  
[wakeup\_app.rar](https://mangoh.discourse.group/uploads/short-url/4uATXQ5rKtkvAGGXwwRNVeDQlYN.rar) (199.2 KB)

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 7, 2021, 12:51am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/8 "2021-06-07T00:51:08Z")

</div>

Can you attach the uart console to show this problem?

Btw, are you trying on mangoh board?

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 7, 2021, 2:37am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/9 "2021-06-07T02:37:56Z")

</div>

Please see attached console log.  
Teraterm.log: Run customer application and wakeup\_app  
Teraterm2.log: Run only wakeup\_app  
Procedure

1. Add wakeup\_app and customer application
2. send “update –g” command
3. Power OFF → ON at 5 times  
Please see last line. It is described as “’wakeup\_app’ is not installed”.  
Note: Yes, customer is checking this issue using mangOH green board.  
[teraterm.log](https://mangoh.discourse.group/uploads/short-url/b94GLuTRfc3SUGBFGx4sbIvUw72.log) (108.1 KB)  
[teraterm2.log](https://mangoh.discourse.group/uploads/short-url/nhzbT5yBVEoJvmYFMbo6JXMcOmd.log) (101.9 KB)

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 7, 2021, 3:01am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/10 "2021-06-07T03:01:42Z")

</div>

Why does the module keep resetting?  
If it reboots too much, it will regard as unstable environment and rollback to previous image.

```auto

Open I2C Bus at, '/dev/i2c/4'
Try open I2C Bus at, '/dev/i2c-4'
Open I2C Bus at, '/dev/i2c/4'
Try open I2C Bus at, '/dev/i2c-4'
	Register Addr 0x11: 0x1b...

Format: Log Type - Time(microsec) - Message - Optional Info
Log Type: B - Since Boot(Power On Reset), D - Delta, S - Statistic
S - QC_IMAGE_VERSION_STRING=BOOT.BF.3.1.2-00094

```

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 8, 2021, 7:07am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/11 "2021-06-08T07:07:20Z")

</div>

Thanks. To check it, customer added the following power off code.  
system("/sbin/poweroff -f");

But Customer think that WP76xx module do not go to power off sequence.  
When customer send “/sbin/poweroff –f” command in linux console, WP76xx module go to power off sequence.  
Is there any limitation to perform “system("/sbin/poweroff -f");” command in application?

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 8, 2021, 7:34am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/12 "2021-06-08T07:34:43Z")

</div>

how about send AT!POWERDOWN to /dev/ttyAT channel

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 8, 2021, 8:44am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/13 "2021-06-08T08:44:13Z")

</div>

To send AT command, I tried to open /dev/ttyAT channel but I cannot open it from application.  
Of course, I succeeded to send AT command from consol window for WP76xx module using microcosm application.

Please advise how to send AT command in application.

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 8, 2021, 9:32am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/14 "2021-06-08T09:32:53Z")

</div>

you can see this document on how to send AT command in unsandboxed legato application:

[Sending AT command in Legato application.docx](https://mangoh.discourse.group/uploads/short-url/eeW5rtumfl90F32V8TMBOXcoVFp.docx) (215.2 KB)

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 11, 2021, 4:53am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/15 "2021-06-11T04:53:14Z")

</div>

Thanks.

Customer did not see application deleting issue after adding power down sequence.

But there is possibility that end user will cut power supply in their system without power down sequence. If module delete their application, it is impact for their system.

After deleting their application, SWI default application is still keeping in WP76 module. Can customer set their application as default application?

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 11, 2021, 5:09am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/16 "2021-06-11T05:09:08Z")

</div>

you can see here on modifying the wifi.sdef to add your application as default application in legato.cwe:

> **[Flash size wp7607](https://forum.legato.io/t/flash-size-wp7607/3805/34)**
>
> hi @jyijyi, Thanks for your help earlier. I was able to build and file using make wp76xx command. Also I was to add myCustom.adef file and build separately with command: mkapp -t wp76xx apps/sample/myApp/myCustom.adef Now, I am trying to add...

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 14, 2021, 1:48am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/17 "2021-06-14T01:48:17Z")

</div>

This meaning is that customer need to build “Build your custom Device Image” in [https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-13,-d-,1-components/](https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-release-13,-d-,1-components/)?

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 14, 2021, 2:02am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/18 "2021-06-14T02:02:21Z")

</div>

Yes, you are correct

---

<div class="post-metadata">

### Author: ![takashishiina](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@takashishiina](https://mangoh.discourse.group/u/takashishiina)
#### Post date: [June 24, 2021, 2:18am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/19 "2021-06-24T02:18:26Z")

</div>

Customer tried to build their application based on “Build your custom Device Image”. But Customer do not understand which timing / how to implement their application.  
If possible, please let us know how to implement “Hello World” as default application?

---

<div class="post-metadata">

### Author: ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)
#### Post date: [June 24, 2021, 2:41am UTC](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278/20 "2021-06-24T02:41:15Z")

</div>

Can they build the legato.cwe?  
Have they modified wifi.sdef?

[Next page](https://mangoh.discourse.group/t/how-to-run-shell-script-after-boot/9278.md?page=2)
