10 Replies Latest reply on Jun 22, 2015 1:31 PM by AreM

    systemd and preset

    mcabral

      Hi there,

       

      I would like to create new services and enable them by default when I deploy my customized version of Yocto.

       

      As described here (https://wiki.archlinux.org/index.php/systemd, creating services is fairly straightforward.

       

      I have tested this and it works fine - as long as I manually issue

       

      systemctl myservice enable

       

      where myservice is my newly created service.

       

      However, how can I make this option "enabled" by default on a custom Yocto distribution ? I see that systemd supports "presets" (systemd.preset).

       

      But does Yocto supports this ? How do I customize this on the Edison Image ?

       

      Any hints or pointers are greatly appreciated!

       

      Thanks in advance,

        • 1. Re: systemd and preset
          CMata_Intel

          Hi mcabral;

           

          Take a look of this thread where David_J_Hunt explains how to start or stop services using systemd in order to get a script started at boot. Let me know if it helps you.

           

          Regards;

          CMata

          • 2. Re: systemd and preset
            mcabral

            Thanks for the reference but something is still not clear:

             

            I am not sure how can I make my own scripts to be enabled by default when I create my own custom service units.

             

            The Intel documentation/instructions show how to create a custom image (Intel® Edison BSP User Guide), including creating a new, custom service.

             

            But is this custom service enabled by default ? (out of a brand new flash)

             

            Thanks again,

            • 3. Re: systemd and preset
              mcabral

              I have found a systemd service sample (watchdog_sample) - as described in Section 3.5 of Intel® Edison BSP User Guide.

               

              I will try to customize it and bitbake a new image to test it. I will post back here to document the results.

               

              Thanks again,

              • 4. Re: systemd and preset
                mcabral

                Hi,

                 

                I have tried editing and customizing the watchdog_sample service but somehow it does not get added to my custom build.

                 

                Issuing "bitbake edison-image" works fine and "./flashall.sh" also works (I verify that my Edison is indeed running my custom build by calling "uname -a").

                 

                So this confirms that I am running my custom build. However, my watchdog-sample edited service does not get added to the build.

                 

                I would simply like to add my own compiled binaries with a simple .service file that would run these files at the startup.

                 

                Is there anywhere else on the configuration files that I should be editing also (apart from the watchdog-sample files) ?

                 

                Thanks in advance for any pointers,

                • 5. Re: systemd and preset
                  deium

                  I am not sure if your question has the systemctl myservice enable reversed as a typo.

                  systemctl start myservice - would be used to make myservice.service start

                  systemctl enable myservice - would be used to make myservice.service start and load on bootup

                  systemctl disable myservice - would be used to make myservice.service stop and not reload on bootup

                  systemctl stop myservice - would be used to make myservice.service stop

                   

                  sometime small typos/ transpositions cause undesired results. 

                  You can also systemctl to check service status to see if there were errors and what they were.

                   

                  I am also told that adding your cmds to a .profile file in the users directory would load on login

                  Hope this might have been helpful

                  • 6. Re: systemd and preset
                    mcabral

                    Thanks -

                     

                    However, I don't think I am making myself clear on what it is that I am trying to accomplish.

                     

                    I know how to start/stop/enable services;

                     

                    What I am having problems with is to with baking a new / custom Edison image (using bitbake and so forth).

                     

                    My custom services are not being included in my custom Edison distribution.

                     

                    Sorry about not expressing myself clearly.

                     

                    Thanks again,

                    • 7. Re: systemd and preset
                      mhahn

                      I'd suggest to compare with bb recipes which come with services like e.g. device-software/meta-edison-middleware/recipes-devtools/iotkit-agent/iotkit-agent_0.1.7.bb

                      • 8. Re: systemd and preset
                        mcabral

                        Thanks mhahn,

                         

                        What I did so far was to copy/paste the watchdog-sample and edit into my own service (trying to edit it appropriately to my custom service).

                         

                        It is very simple - I don´t need to setup compilation in the .bb file - just install some pre-compiled binaries I have.

                         

                        This .bb custom service file does gets verified during the bitbake process - but my custom service is not included in the image when I flash it into my Edison.

                         

                        So this begs the question: do I need to inform the bitbake process to include this new custom service (perhaps in some configuration file, just like when adding custom packages as explained in this file Intel® Edison BSP User Guide

                         

                        Anyway I will try with the recipe you suggested instead of using the watchdog-sample.

                         

                        Thanks again,

                        1 of 1 people found this helpful
                        • 9. Re: systemd and preset
                          mhahn

                          just take any recipe which installs service files. What I picked was just an example

                          • 10. Re: systemd and preset
                            AreM

                            Hi deium,

                             

                            You said that "adding your cmds to a .profile file in the users directory would load on login"

                             

                            Is this analogous to typing "systemctl start <myfile>" after logging in? If so, can you clarify how to add cmds to a .profile file?


                            Thank you