WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: startup  (Read 2647 times)

Offline andyb1973

  • Newbie
  • *
  • Posts: 16
startup
« on: May 13, 2022, 01:02:04 PM »
best and fastest way to start up a sh?

i used /opt/bootlocal.sh but it seems not to fast as i thought

thx
ab

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: startup
« Reply #1 on: May 13, 2022, 05:27:59 PM »
Hi andyb1973
The question is too vague to answer due to the way it was ask and the lack of detail to what you are doing.

... fastest way to start up a sh? ...
The earliest practical place to launch a script is from  /opt/bootsync.sh.
The fastest way to execute a script is highly dependent on what the script is doing and how it is written.

If you attach a copy of your  /opt/bootlocal.sh  and the script you are launching, we can better answer your question.

Offline andyb1973

  • Newbie
  • *
  • Posts: 16
Re: startup
« Reply #2 on: May 14, 2022, 12:56:37 PM »
i try

@ the beginning (before ssh server and the trottler of cpu i think) of bootlocal, i placed my "/opt/nav.sh &" (ok, nice answer)...
ok, my sh makes:
1. launch usbmode switch with parameters (i need to tranform my gsm key): the light of the gsm key changes
2. lanch ppp to connect gsm (a loop in & to recatch the carrier if needed) ..depends where is my key
3. lanch ping to discover network (a loop without &) .. time.. depends
4. end: a loop reading gps key with readline and a curl to fixed ip to send coordinates (depends by the point 3)

it seems the script is called after a little bit.. the prompt is ready, but i see gsm change after more or less 30 seconds  (a sensation based upon the change of the blinkiing light on gsm key .. also the strout on prompt seems to lanch after time)

maybe can  i put my sh in a better place (or create a service?)? another note: i leave 40-usbmodeswitch in /etc/udev/roles.d/, maybe usb is parsing all of them taking time?

thanks

Offline Mypresus

  • Newbie
  • *
  • Posts: 24
Re: startup
« Reply #3 on: May 15, 2022, 01:54:56 AM »
Hi andyb1973

As Rich said your question is vague. If you need to start your script earlier you may want to look at /etc/init.d also look at /etc/init.d/tc-config to see what starts up from there, and maybe modify tc-config.  You mentioned PPP and Ping which would require Ethernet so may want to look after eth and usb devices (for GSM key) have started.

Probably the order to look at for places to place your script is init.d > rcs > tc-config > bootsync.sh > bootlocal.sh

Cheers

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11041
Re: startup
« Reply #4 on: May 15, 2022, 02:00:26 AM »
You can add logging to your script to see when things happen. It doesn't sound like starting it earlier would help much, rather some steps in it are taking the time.
The only barriers that can stop you are the ones you create yourself.

Offline andyb1973

  • Newbie
  • *
  • Posts: 16
Re: startup
« Reply #5 on: May 15, 2022, 03:35:57 PM »
Hi andyb1973

As Rich said your question is vague. If you need to start your script earlier you may want to look at /etc/init.d also look at /etc/init.d/tc-config to see what starts up from there, and maybe modify tc-config.  You mentioned PPP and Ping which would require Ethernet so may want to look after eth and usb devices (for GSM key) have started.

Probably the order to look at for places to place your script is init.d > rcs > tc-config > bootsync.sh > bootlocal.sh

Cheers


aorry, i'm newbie, but if i make e sh in init.d (not a service) is allowed?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: startup
« Reply #6 on: May 15, 2022, 05:37:18 PM »
Hi andyb1973
I think the place to start is the execution time of your script.
Comment out  /opt/nav.sh &  from your  bootlocal.sh  file.
Reboot your machine and run sections of  /opt/nav.sh  one at a time and see which ones are taking too long.
Once you have  /opt/nav.sh  running satisfactory from the command line, re-enable it in  bootlocal.sh.
If it's slow again, then something else is causing that.

I've attached a file with a timestamp function you can use for logging elapsed time.
Place the contents before your code in your  /opt/nav.sh  script.

Everytime you call  Timestamp , it will print the elapsed time since the last call to  Timestamp.
You can include a message to be printed next to the elapsed time like this:
Code: [Select]
Timestamp "launch usbmode switch"
# Your usbmode code
Timestamp "launch ppp to connect gsm"
# Your ppp code

Offline andyb1973

  • Newbie
  • *
  • Posts: 16
Re: startup
« Reply #7 on: May 16, 2022, 06:22:16 AM »
thx

Offline andyb1973

  • Newbie
  • *
  • Posts: 16
Re: startup
« Reply #8 on: May 18, 2022, 06:40:10 AM »
Hi andyb1973

As Rich said your question is vague. If you need to start your script earlier you may want to look at /etc/init.d also look at /etc/init.d/tc-config to see what starts up from there, and maybe modify tc-config.  You mentioned PPP and Ping which would require Ethernet so may want to look after eth and usb devices (for GSM key) have started.

Probably the order to look at for places to place your script is init.d > rcs > tc-config > bootsync.sh > bootlocal.sh

Cheers

for donkey like me, but how register a new init.d/example.sh without update-rc or systemd ?

thx

Offline Mypresus

  • Newbie
  • *
  • Posts: 24
Re: startup
« Reply #9 on: May 19, 2022, 01:04:24 AM »
Not sure but guessing you want to use a USB gateway device to connect to a GSM network?
So, guessing the order is:
1 USB is required first check if device is available.
2 If device is available get GSM key.
3 If GSM key retrieved Set PPP authentication.
4 Check if can reach the net.
If this is the case then, as the udev daemon is started in the etc/init.d/tc-config so no use setting your script in init.d so believe your question isn’t relevant to your solution. 
As Curaga suggested placing earlier then bootlocal.sh or bootsync.sh would probably not help. As mentioned, logging/timestamping is your best option, maybe create a script that checks usb device first then go from there.