Jump to content


Photo

Adding an init script ..


  • Please log in to reply
7 replies to this topic

#1 OpenTel

  • Senior Member
  • 63 posts

0
Neutral

Posted 29 August 2022 - 11:11

I was unsuccessful adding a script to run-level 3.

 

My main script was created in /etc/init.d/

 

A link was created

ln -sf /etc/init.d/S90myscript /etc/rc3.d/

 

But it's not being executed permissions are all fine.

 

I'm familiar with Linux but there seems to be no 'chkconfig' command on OpenPLI?

 

So how do I do this?

 

On another note where is the best place to have a custom script run after boot?

 

Many thanks



Re: Adding an init script .. #2 scriptmelvin †

  • PLi® Contributor
  • 720 posts

+46
Good

Posted 29 August 2022 - 12:17

You can install cronie from the feed, then use @reboot (that busybox-cron doesn't support) in your crontab.


Sorry to inform you this member, my brother, passed away.

Re: Adding an init script .. #3 WanWizard

  • PLi® Core member
  • 68,309 posts

+1,719
Excellent

Posted 29 August 2022 - 12:44

Creating the symlink in the correct runlevel should be enough.

 

If it is not executed, there is something wrong with the script. It should be a correct init script, you can't just dump any bash script in there.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: Adding an init script .. #4 s3n0

  • Senior Member
  • 640 posts

+62
Good

Posted 29 August 2022 - 13:53

A link was created

ln -sf /etc/init.d/S90myscript /etc/rc3.d/

 

 

Hi.

 

You did it wrong.

 

The text at the beginning of "S90" does not belong where you inserted it! This is added to the name of the symlink in the "rc3.d" folder (on the right side of the command). The physical script file belongs to the left side and the name of the symbolic link (with this "Sxx" text) that will be created by this "link-command" belongs to the right side.

 

So the correct way is:

ln -sf /etc/init.d/myscript /etc/rc3.d/S90myscript

 

Why didn't you check it ? Is the symbolic script created and is it correct ? For example: ls -al /etc/rc3.d Check if your symbolic link is present (if you use SSH connection, you will see it as light-blue color) and if it points to the correct physical file in the filesystem (if you use SSH connection, it is light-green color).

 

Here is the info, as example from my "/etc/init.d/softcam" shell-script, on my github (https://github.com/s.../master/softcam):

#   A) You can use the automated system tool:
#      For add (install) the startup sym-links to all default run-levels:
#         update-rc.d softcam defaults 90
#      For remove (uninstall) startup sym-links from all run-levels use the following command:
#         update-rc.d -f softcam remove
#
#   B) If the automated system tool does not work or is not installed, use the manual creation of a symbolic link:
#      For add (install) the startup sym-links to run-level No.3 (Enigma2 default run-level):
#         ln -sf /etc/init.d/softcam /etc/rc3.d/S90softcam
#      For remove (uninstall) the symbolic link you can simply delete this link:
#         rm -f /etc/rc3.d/S90softcam               # or the same way with "unlink" command:   unlink /etc/rc3.d/S90softcam

Edited by s3n0, 29 August 2022 - 13:58.


Re: Adding an init script .. #5 Dimitrij

  • PLi® Core member
  • 9,967 posts

+335
Excellent

Posted 29 August 2022 - 14:17

 ln -sf /etc/init.d/myscript /etc/rc3.d/S90myscript

 


GigaBlue UHD Quad 4K /Lunix3-4K/Solo 4K


Re: Adding an init script .. #6 OpenTel

  • Senior Member
  • 63 posts

0
Neutral

Posted 29 August 2022 - 18:13

 

A link was created

ln -sf /etc/init.d/S90myscript /etc/rc3.d/

 

 

Hi.

 

You did it wrong.

 

The text at the beginning of "S90" does not belong where you inserted it! This is added to the name of the symlink in the "rc3.d" folder (on the right side of the command). The physical script file belongs to the left side and the name of the symbolic link (with this "Sxx" text) that will be created by this "link-command" belongs to the right side.

 

So the correct way is:

ln -sf /etc/init.d/myscript /etc/rc3.d/S90myscript

Why didn't you check it ? Is the symbolic script created and is it correct ? For example: ls -al /etc/rc3.d Check if your symbolic link is present (if you use SSH connection, you will see it as light-blue color) and if it points to the correct physical file in the filesystem (if you use SSH connection, it is light-green color).

 

Here is the info, as example from my "/etc/init.d/softcam" shell-script, on my github (https://github.com/s.../master/softcam):

#   A) You can use the automated system tool:
#      For add (install) the startup sym-links to all default run-levels:
#         update-rc.d softcam defaults 90
#      For remove (uninstall) startup sym-links from all run-levels use the following command:
#         update-rc.d -f softcam remove
#
#   B) If the automated system tool does not work or is not installed, use the manual creation of a symbolic link:
#      For add (install) the startup sym-links to run-level No.3 (Enigma2 default run-level):
#         ln -sf /etc/init.d/softcam /etc/rc3.d/S90softcam
#      For remove (uninstall) the symbolic link you can simply delete this link:
#         rm -f /etc/rc3.d/S90softcam               # or the same way with "unlink" command:   unlink /etc/rc3.d/S90softcam

 

 

Apologies, I indeed did it as you wrote ... I've made a mistake while copying and pasting into my post.

 

Script in /etc/init.d

-rwxr-xr-x    1 root     root           518 Aug 28 23:21 mymounts

 

 

/etc/rc3.d

lrwxrwxrwx    1 root     root            20 Aug 29 18:02 S90_mymounts -> /etc/init.d/mymounts

 

The script executes when called from the a shell session

./mymounts start

 

The scripts basically mounts a couple of cifs mounts.

It is not a shell script but an init script.

 

Networking should be up @ S90 ..


Edited by OpenTel, 29 August 2022 - 18:15.


Re: Adding an init script .. #7 Pike_Bishop

  • Senior Member
  • 1,116 posts

+72
Good

Posted 29 August 2022 - 18:50

Hi,

 

include echoes and logging in your script so you can see what is wrong or if it works at all.

 

i use also a init Script to mount my synology nas , it looks as;

#!/bin/sh

PATH_FOR_SCRIPT=/usr/script
SCRIPT_TO_START=synology_ds213_mount.sh

. /etc/default/rcS


sh $PATH_FOR_SCRIPT/$SCRIPT_TO_START &


: exit 0

but i have linked it in the startlevel and it starts another script which is mounting my nas.

cd /etc/rcS.d
ln -s ../init.d/start_synology_ds213_mount_script.sh S99start_synology_ds213_mount_script.sh

regards

Pike


Edited by Pike_Bishop, 29 August 2022 - 18:59.

Receiver: VU Ultimo 4K, Octagon SF8008 4K, Gigablue Quad 4K

Image: OpenPLI-8.3


Re: Adding an init script .. #8 s3n0

  • Senior Member
  • 640 posts

+62
Good

Posted 2 September 2022 - 14:28

Yes. "Init.d" script is not a standard script, but a script that requires input argument processing. In the case of Enigma2 distributions in lightweight Linux systems, at least the following arguments (parameters) are used:

start | stop | restart

 

The "start" argument is sent to the "init.d" script when a specific service run through init.d is starting (for example, when booting a Linux system).

The "stop" argument is invoked when the Linux system reboots / shuts down. Therefore, these basic arguments (parameters) must be captured there.

 

In some cases, the return value (error code) from the "init.d" script also plays an important role ! Be careful, don't confuse it with the "status" arguments for the init.d script. If "status" argument is requested through some "init.d" script, then the return values represent the "status code" of the service, and they are different codes than in the case of "exit code".

 

Many additional arguments for "init.d" scripts, in the case of Enigma2 set top boxes, are not needed or are not implemented (it varies depending on which Linux system is used and whether it is a light version or a full version of the Linux system).

 

You can find more information on the internet... for example, here:

https://refspecs.lin...niscrptact.html

https://www.novell.c...ml/ch13s04.html

 

With some script-examples:

https://bash.cyberci...ide//etc/init.d

https://unix.stackex...d-start-at-boot


Edited by s3n0, 2 September 2022 - 14:36.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users