• Categories
  • Recent
  • Tags
  • Popular
  • Register
  • Login
  • Categories
  • Recent
  • Tags
  • Popular
  • Register
  • Login

Launch ./start.sh on startup , or like a service ?

Scheduled Pinned Locked Moved Getting Started
startuplauchautostart
10 Posts 2 Posters 6.7k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    Stephan35
    last edited by 23 Feb 2017, 17:47

    Hello, i would like to know how to lauch MyContoller on startup , like a service or another way.
    Thanks ,
    Best regards.

    T 1 Reply Last reply 24 Feb 2017, 07:28 Reply Quote 0
    • T Offline
      Tag MOD @Stephan35
      last edited by 24 Feb 2017, 07:28

      @Stephan35

      which OS are you using?, if it is linux, you can add the startup script to the startup scripts env in /etc.

      I will have a look and keep you posted..

      S 1 Reply Last reply 24 Feb 2017, 08:53 Reply Quote 0
      • S Offline
        Stephan35 @Tag
        last edited by Stephan35 24 Feb 2017, 08:53

        @Tag

        Sorry, on linux.
        Should i use something like this

        sudo cp start.sh /etc/init.d
        sudo chmod +x /etc/init.d/start.sh
        sudo update-rc.d start.sh defaults

        To start

        sudo /etc/init.d/start.sh start

        To stop

        sudo /etc/init.d/start.sh stop

        Maybe rename start.sh to mycontroller.sh ?

        Is there no probleme with user and path to find mycontroller ?

        Thanks .

        1 Reply Last reply Reply Quote 0
        • T Offline
          Tag MOD
          last edited by Tag 24 Feb 2017, 17:47

          @Stephan35

          Here is how i got all working.

          1. Start your favorite editor (nano or vi) and make a file called mycontroller in /etc/init.d
          sudo vi /etc/init.d/mycontroller
          
          1. copy the following text into the file (Make sure to get the path to mycontroller right!! in my case i used /home/user/mycontroller)
          #! /bin/sh
          # /etc/init.d/mycontroller
          
          ### BEGIN INIT INFO
          # Provides:          mycontroller
          # Required-Start:    $remote_fs $syslog
          # Required-Stop:     $remote_fs $syslog
          # Default-Start:     2 3 4 5
          # Default-Stop:      0 1 6
          # Short-Description: Start daemon at boot time
          # Description:       Enable service provided by daemon.
          ### END INIT INFO
          
          # The following part always gets executed.
          # echo " Mycontroller rocks!!"
          
          # The following part carries out specific functions depending on arguments.
          case "$1" in
            start)
              echo "Starting Mycontroller"
                  /home/user/mycontroller/bin/start.sh
              ;;
            stop)
              echo "Stopping Mycontroller"
                  /home/user/mycontroller/bin/stop.sh
              ;;
            *)
              echo "Usage: /etc/init.d/mycontroller {start|stop}"
              exit 1
              ;;
          esac
          
          exit 0
          
          1. Make the file executable:
          sudo chmod 755 /etc/init.d/mycontroller
          
          1. Now add the script to the initd environment:
          sudo update-rc.d mycontroller defaults
          
          1. Test the script with the commands below:
          sudo /etc/init.d/mycontroller start
          

          and after mycontroller has started successfully:

          sudo /etc/init.d/mycontroller stop
          

          If troubleshooting is required/ search for mycontroller in /var/log/syslog this is the file where all output massages will appear.

          That should do the trick, depending on your version of linux, (in mycase armbian) it might be that a different startup mechanism is used.

          Tested all on an OrangPI Zero running armbian (Jesse) and RaspberryPI running Ubuntu Mate 15.10 both mycontroller applications are "up" after a reboot.

          S 1 Reply Last reply 24 Feb 2017, 18:05 Reply Quote 2
          • S Offline
            Stephan35 @Tag
            last edited by 24 Feb 2017, 18:05

            @Tag Wonderfull !

            Just had this error :

            insserv: warning: script 'mycontroller' missing LSB tags and overrides

            I had to add this at the beginning :

            ### BEGIN INIT INFO
            # Provides:          MyController domotique
            # Required-Start:    $remote_fs $syslog
            # Required-Stop:     $remote_fs $syslog
            # Default-Start:     2 3 4 5
            # Default-Stop:      0 1 6
            # Short-Description: Start daemon at boot time
            # Description:       Enable service provided by daemon.
            ### END INIT INFO
            
            1 Reply Last reply Reply Quote 0
            • T Offline
              Tag MOD
              last edited by 24 Feb 2017, 18:07

              @Stephan35

              Yes i saw that one to, it can be safely ignored, but will add it to the install steps.
              Thanks for reminding!

              S 1 Reply Last reply 25 Feb 2017, 10:38 Reply Quote 0
              • S Offline
                Stephan35 @Tag
                last edited by Stephan35 25 Feb 2017, 10:38

                @Tag
                Finally does not start at boot , missing something or, INIT is not correctly set.
                chkconfig -l display this :

                mountnfs.sh               0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on 
                mycontroller              0:off  1:off  2:on   3:on   4:on   5:on   6:off
                network-manager           0:off  1:off  2:on   3:on   4:on   5:on   6:off
                
                

                have a look later .
                Best regards

                T 1 Reply Last reply 26 Feb 2017, 09:08 Reply Quote 0
                • T Offline
                  Tag MOD @Stephan35
                  last edited by Tag 26 Feb 2017, 09:08

                  @Stephan35

                  What is your current runlevel? , check with the command

                  runlevel
                  

                  Mycontroller is only started in runlevel 2-5 so if you enter runlevel 0,1 or 6 mycontroller is stopped. (make the changes in the top of the script..)

                  Another issue might be that the cript itself in incorrect.... make sure that the startup script starts with

                  #!/bin/sh
                  

                  This is really important.

                  So the complete file should look like this:

                  #! /bin/sh
                  # /etc/init.d/mycontroller
                  
                  ### BEGIN INIT INFO
                  # Provides:          mycontroller
                  # Required-Start:    $remote_fs $syslog
                  # Required-Stop:     $remote_fs $syslog
                  # Default-Start:     2 3 4 5
                  # Default-Stop:      0 1 6
                  # Short-Description: Start daemon at boot time
                  # Description:       Enable service provided by daemon.
                  ### END INIT INFO
                  
                  
                  # The following part always gets executed.
                  #echo "This part always gets executed"
                  
                  # The following part carries out specific functions depending on arguments.
                  case "$1" in
                    start)
                      echo "Starting Mycontroller"
                          /home/user/mycontroller/bin/start.sh
                      ;;
                    stop)
                      echo "Stopping Mycontroller"
                          /home/user/mycontroller/bin/stop.sh
                      ;;
                    *)
                      echo "Usage: /etc/init.d/mycontroller {start|stop}"
                      exit 1
                      ;;
                  esac
                  
                  exit 0
                  

                  If you execute the following command,

                  grep -i mycontroller /var/log/syslog
                  

                  what is the output?
                  (if no output, look into an older file like i.e syslog.1)

                  In my case the output is:

                  root@orangepizero:~# grep -i mycontroller /var/log/syslog.1
                  Feb 25 11:27:40 localhost mycontroller[474]: Starting Mycontroller
                  Feb 25 11:27:40 localhost mycontroller[474]: /usr/bin/java
                  Feb 25 11:27:43 localhost mycontroller[474]: java version: 1.8.0_121
                  Feb 25 11:27:43 localhost mycontroller[474]: Start issued for Mycontroller
                  
                  1 Reply Last reply Reply Quote 1
                  • S Offline
                    Stephan35
                    last edited by 27 Feb 2017, 20:54

                    @Tag said:

                    Another issue might be that the cript itself in incorrect.... make sure that the startup script starts with

                    #!/bin/sh
                    This is really important.

                    Yes , it was that !

                    Got also Orange Pi Zero 😉

                    T 1 Reply Last reply 27 Feb 2017, 21:37 Reply Quote 0
                    • T Offline
                      Tag MOD @Stephan35
                      last edited by 27 Feb 2017, 21:37

                      @Stephan35

                      Great!! good luck!, orangepizero is really great, and is powerfull enough to run mycontroller 😄

                      1 Reply Last reply Reply Quote 0
                      2 out of 10
                      • First post
                        2/10
                        Last post

                      1

                      Online

                      636

                      Users

                      532

                      Topics

                      3.4k

                      Posts
                      Copyright © 2015-2025 MyController.org | Contributors | Localization