Script at boot....

There are 7 replies in this Thread which was already clicked 1,290 times. The last Post () by s3n0.

  • Good evening, I'm looking to launch a script when my octagon starts, I have my script functional and tested ... on the other hand, it's to find the launch order that I'm stuck, in etc/rc3.d or other. ...thanks for any help....

  • Go to Best Answer
    • Official Post

    Good evening, I'm looking to launch a script when my octagon starts, I have my script functional and tested ... on the other hand, it's to find the launch order that I'm stuck, in etc/rc3.d or other. ...thanks for any help....

    What dose the script do ?

    IE: Is it required at every boot ? And at what point should it run ??

  • Hello and thank you for your answer dear friend, the script must be launched just when the image is started, only once is just to change a data in the device, after that it's ok, that's why I don't turn to cron...no need to be restarted afterwards....

  • Hi.


    It's not complicated. This is a system of "init.d" control shell-scripts (start / stop / restasrt), depending on the current Linux run-level.


    I recommend you take a look at my "init.d" script, designed to run Softcams: https://github.com/s3n0/e2scripts/blob/master/softcam


    You will find all general information there at the beginning of this shell-script. You can, of course, delete the contents of the script and use your own code.


    The important parameters (arguments) used for the $1 "init.d" script are: start, stop and restart. The original "init.d system", which you can find on the internet, uses more input arguments, not just these 3 arguments (start | stop | restart). Also the output exit code from the "init.d" script has its meaning. Therefore, if no error has occurred, it is recommended to exit the init.d script with a zero error return code, i.e.: exit 0.


    In the case of Linux Enigma2 set-top boxes, the very common rules and standards do not apply to these init.d scripts ... but many of them also apply to Linux set-top boxes, where a bit truncated Linux is used.


    Once you have created your init.d script and placed it in the "/etc/init.d" folder, then a sym-link must be created to the appropriate Run-Level. Most Enigma2 set-top boxes use the main Run-Level number 3. Therefore, you need to create a sym-link from your "init.d" script as a file, just to the "/etc/rc3.d" folder. However, this sym-link in the "/etc/rc?.d" folders must have the prescribed form. This information can also be googleed on the internet :) - for example: https://man.cx/init.d - I mean the shape and meaning of numbers and letters, in a sym-link, created for a specific "init.d" script.


    Of course, your "init.d" script must have an execution attribute assigned to it. For example, using with the Linux-Shell:

    chmod a+x /etc/init.d/your_script


    And that's about it.


    You can test the auto-start of your "init.d" script, for example, by restarting the set-top box:

    reboot


    If something doesn't work for you, feel free to write and ask.


    "How-to init.d scripts" can also be Googleed ;-).


    ///// EDIT:


    One more note:


    All "init.d" scripts should also be terminated regularly ! For example, with the command exit 0, or in the event of an error, the corresponding other error code according to the "init.d" standard. Otherwise, booting may remain stuck on this init.d script if it did not complete successfully. If you need to run something "in the background", so this can also be done, with the help of appropriate tools / commands, directly in your init.d script.

  • Thanks mate, so I was good with the file in /etc/init and launch in /etc/rc3.d

    I don't use cron for this kind of tasks....

    In case of problems, I will not hesitate to ask you, but I think the explanation is clear.....

    • Best Answer

    You're welcome.


    BTW ... in the case of OpenATV Enigma2, you can also use a boot shell-script: "/usr/bin/enigma2_pre_start.sh". However, not all Enigma2 distributions use this shell-script. You also need to keep in mind that this shell-script runs every time Enigma2 starts.


    While the "init.d" scripts run through the Linux system directly - i.e. during boot of the set-top box (regardless of the Enigma2 GUI) - during the boot into Run-Level-3.


    Note 1:

    If you create a new shell-script (if does not exist) then you must to assign the execution attributes - with the command chmod a+x /path-to-file, or set the value of the file attributes to 755 using the FTP client.


    Note 2:

    Also, keep in mind that for all shell-scripts, you must always use with the Unix/Linux line ending (LF). Not the Windows (CR + LF) line ending.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!