postinst maintainer script stops systemd unit file from starting automatically on install

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












I'm creating a small Debian package to install systemd unit files, specifically *.service files.



My package looks like:



myservice
|
|--debian
|- comapat
|- preinst
|- postinst
|- rules
|- myservice.service


When I install my package, the systemd services are automatically disabled and they do not start up.



Right after install, systemctl status myservice shows



root@ubuntu-xenial:~# systemctl status myservice
● myservice.service - My Service - echos output and says when it started
Loaded: loaded (/lib/systemd/system/myservice.service; disabled; vendor preset: enabled)
Active: inactive (dead)


However, when I install my package without a postinst script, the systemd services are automatically enabled and they do start up after install.



root@ubuntu-xenial:~# systemctl status myservice
● myservice.service - MyService - echos output and says when it started
Loaded: loaded (/lib/systemd/system/myservice.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-02-09 15:06:36 UTC; 10s ago
Main PID: 5024 (sh)
Tasks: 2
Memory: 172.0K
CPU: 1ms
CGroup: /system.slice/myservice.service
├─5024 /bin/sh -c echo 'myservice.service started' && echo $(date +%s) && sleep infinity
└─5026 sleep infinity


I'm confused because my postinst is "small and dumb":



#!/bin/sh -e
# POSTINST script for intera
set -e

echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"


Why does the presence of a postinst overwrite the "automatic enabling and starting" of a systemd service?


What part of debhelper deals with this and what am I missing?


Or what should I add to my postinst maintainer script to get my services up and running on install?




NOTES: My environment is a small vagrant box with a virtualbox provider. I am using the ubuntu-xenial64 Vagrant box. Not sure if this environment affects this.







share|improve this question
























    up vote
    1
    down vote

    favorite
    1












    I'm creating a small Debian package to install systemd unit files, specifically *.service files.



    My package looks like:



    myservice
    |
    |--debian
    |- comapat
    |- preinst
    |- postinst
    |- rules
    |- myservice.service


    When I install my package, the systemd services are automatically disabled and they do not start up.



    Right after install, systemctl status myservice shows



    root@ubuntu-xenial:~# systemctl status myservice
    ● myservice.service - My Service - echos output and says when it started
    Loaded: loaded (/lib/systemd/system/myservice.service; disabled; vendor preset: enabled)
    Active: inactive (dead)


    However, when I install my package without a postinst script, the systemd services are automatically enabled and they do start up after install.



    root@ubuntu-xenial:~# systemctl status myservice
    ● myservice.service - MyService - echos output and says when it started
    Loaded: loaded (/lib/systemd/system/myservice.service; enabled; vendor preset: enabled)
    Active: active (running) since Fri 2018-02-09 15:06:36 UTC; 10s ago
    Main PID: 5024 (sh)
    Tasks: 2
    Memory: 172.0K
    CPU: 1ms
    CGroup: /system.slice/myservice.service
    ├─5024 /bin/sh -c echo 'myservice.service started' && echo $(date +%s) && sleep infinity
    └─5026 sleep infinity


    I'm confused because my postinst is "small and dumb":



    #!/bin/sh -e
    # POSTINST script for intera
    set -e

    echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"


    Why does the presence of a postinst overwrite the "automatic enabling and starting" of a systemd service?


    What part of debhelper deals with this and what am I missing?


    Or what should I add to my postinst maintainer script to get my services up and running on install?




    NOTES: My environment is a small vagrant box with a virtualbox provider. I am using the ubuntu-xenial64 Vagrant box. Not sure if this environment affects this.







    share|improve this question






















      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      I'm creating a small Debian package to install systemd unit files, specifically *.service files.



      My package looks like:



      myservice
      |
      |--debian
      |- comapat
      |- preinst
      |- postinst
      |- rules
      |- myservice.service


      When I install my package, the systemd services are automatically disabled and they do not start up.



      Right after install, systemctl status myservice shows



      root@ubuntu-xenial:~# systemctl status myservice
      ● myservice.service - My Service - echos output and says when it started
      Loaded: loaded (/lib/systemd/system/myservice.service; disabled; vendor preset: enabled)
      Active: inactive (dead)


      However, when I install my package without a postinst script, the systemd services are automatically enabled and they do start up after install.



      root@ubuntu-xenial:~# systemctl status myservice
      ● myservice.service - MyService - echos output and says when it started
      Loaded: loaded (/lib/systemd/system/myservice.service; enabled; vendor preset: enabled)
      Active: active (running) since Fri 2018-02-09 15:06:36 UTC; 10s ago
      Main PID: 5024 (sh)
      Tasks: 2
      Memory: 172.0K
      CPU: 1ms
      CGroup: /system.slice/myservice.service
      ├─5024 /bin/sh -c echo 'myservice.service started' && echo $(date +%s) && sleep infinity
      └─5026 sleep infinity


      I'm confused because my postinst is "small and dumb":



      #!/bin/sh -e
      # POSTINST script for intera
      set -e

      echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"


      Why does the presence of a postinst overwrite the "automatic enabling and starting" of a systemd service?


      What part of debhelper deals with this and what am I missing?


      Or what should I add to my postinst maintainer script to get my services up and running on install?




      NOTES: My environment is a small vagrant box with a virtualbox provider. I am using the ubuntu-xenial64 Vagrant box. Not sure if this environment affects this.







      share|improve this question












      I'm creating a small Debian package to install systemd unit files, specifically *.service files.



      My package looks like:



      myservice
      |
      |--debian
      |- comapat
      |- preinst
      |- postinst
      |- rules
      |- myservice.service


      When I install my package, the systemd services are automatically disabled and they do not start up.



      Right after install, systemctl status myservice shows



      root@ubuntu-xenial:~# systemctl status myservice
      ● myservice.service - My Service - echos output and says when it started
      Loaded: loaded (/lib/systemd/system/myservice.service; disabled; vendor preset: enabled)
      Active: inactive (dead)


      However, when I install my package without a postinst script, the systemd services are automatically enabled and they do start up after install.



      root@ubuntu-xenial:~# systemctl status myservice
      ● myservice.service - MyService - echos output and says when it started
      Loaded: loaded (/lib/systemd/system/myservice.service; enabled; vendor preset: enabled)
      Active: active (running) since Fri 2018-02-09 15:06:36 UTC; 10s ago
      Main PID: 5024 (sh)
      Tasks: 2
      Memory: 172.0K
      CPU: 1ms
      CGroup: /system.slice/myservice.service
      ├─5024 /bin/sh -c echo 'myservice.service started' && echo $(date +%s) && sleep infinity
      └─5026 sleep infinity


      I'm confused because my postinst is "small and dumb":



      #!/bin/sh -e
      # POSTINST script for intera
      set -e

      echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"


      Why does the presence of a postinst overwrite the "automatic enabling and starting" of a systemd service?


      What part of debhelper deals with this and what am I missing?


      Or what should I add to my postinst maintainer script to get my services up and running on install?




      NOTES: My environment is a small vagrant box with a virtualbox provider. I am using the ubuntu-xenial64 Vagrant box. Not sure if this environment affects this.









      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 9 at 15:41









      Wimateeka

      1299




      1299




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          You need to add the debhelper placeholder to your postinst:



          #DEBHELPER#


          So your postinst should look like



          #!/bin/sh
          # POSTINST script for intera
          set -e

          echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"

          #DEBHELPER#

          exit 0


          If you don’t include that, debhelper won’t add its auto-generated postinst snippets to your maintainer script. When you don’t have a postinst at all, it just generates the entire script; but if you have your own version, it only changes the placeholder.






          share|improve this answer




















          • Thanks! This solved my issue. It looks like I was "gotten" by the devil in the details of debhelper.
            – Wimateeka
            Feb 9 at 16:09










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f423069%2fpostinst-maintainer-script-stops-systemd-unit-file-from-starting-automatically-o%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote



          accepted










          You need to add the debhelper placeholder to your postinst:



          #DEBHELPER#


          So your postinst should look like



          #!/bin/sh
          # POSTINST script for intera
          set -e

          echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"

          #DEBHELPER#

          exit 0


          If you don’t include that, debhelper won’t add its auto-generated postinst snippets to your maintainer script. When you don’t have a postinst at all, it just generates the entire script; but if you have your own version, it only changes the placeholder.






          share|improve this answer




















          • Thanks! This solved my issue. It looks like I was "gotten" by the devil in the details of debhelper.
            – Wimateeka
            Feb 9 at 16:09














          up vote
          4
          down vote



          accepted










          You need to add the debhelper placeholder to your postinst:



          #DEBHELPER#


          So your postinst should look like



          #!/bin/sh
          # POSTINST script for intera
          set -e

          echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"

          #DEBHELPER#

          exit 0


          If you don’t include that, debhelper won’t add its auto-generated postinst snippets to your maintainer script. When you don’t have a postinst at all, it just generates the entire script; but if you have your own version, it only changes the placeholder.






          share|improve this answer




















          • Thanks! This solved my issue. It looks like I was "gotten" by the devil in the details of debhelper.
            – Wimateeka
            Feb 9 at 16:09












          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          You need to add the debhelper placeholder to your postinst:



          #DEBHELPER#


          So your postinst should look like



          #!/bin/sh
          # POSTINST script for intera
          set -e

          echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"

          #DEBHELPER#

          exit 0


          If you don’t include that, debhelper won’t add its auto-generated postinst snippets to your maintainer script. When you don’t have a postinst at all, it just generates the entire script; but if you have your own version, it only changes the placeholder.






          share|improve this answer












          You need to add the debhelper placeholder to your postinst:



          #DEBHELPER#


          So your postinst should look like



          #!/bin/sh
          # POSTINST script for intera
          set -e

          echo "33[36m HI I'M A POSTINST SCRIPT `date +"%s"` 33[39m"

          #DEBHELPER#

          exit 0


          If you don’t include that, debhelper won’t add its auto-generated postinst snippets to your maintainer script. When you don’t have a postinst at all, it just generates the entire script; but if you have your own version, it only changes the placeholder.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 9 at 15:59









          Stephen Kitt

          142k22308369




          142k22308369











          • Thanks! This solved my issue. It looks like I was "gotten" by the devil in the details of debhelper.
            – Wimateeka
            Feb 9 at 16:09
















          • Thanks! This solved my issue. It looks like I was "gotten" by the devil in the details of debhelper.
            – Wimateeka
            Feb 9 at 16:09















          Thanks! This solved my issue. It looks like I was "gotten" by the devil in the details of debhelper.
          – Wimateeka
          Feb 9 at 16:09




          Thanks! This solved my issue. It looks like I was "gotten" by the devil in the details of debhelper.
          – Wimateeka
          Feb 9 at 16:09












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f423069%2fpostinst-maintainer-script-stops-systemd-unit-file-from-starting-automatically-o%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)