<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Nice to hear about oneshot systemd service type, thanks!</p>
    <p>So this should executed only once, before the start of rtpengine
      service. Does it require to put something in rtpengine.service
      file (like after run after service)? Or systemd figures it out by
      itself?</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 17.01.20 15:30, Sergey Safarov
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAHtxdDf=_CLCh66JpjH-pUUz0MQoovC4OR6ESzVECN0Wqvip7w@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div><font color="#0000ff">Systemd seems to have the
            "ExecStartPre" option, is it what people use<br>
            to ensure the rtpengine kernel module is loaded and iptables
            rule exists?</font><br>
        </div>
        <div><br>
        </div>
        yes, that is option<br>
        But this command will be executed for Every daemon start.<br>
        <br>
        <font color="#0000ff">Any systemd-specific wayt to run a script
          only once after system boot? I<br>
          have seen workarounds on the net for creating like a rc.local
          service,<br>
          but they didn't look to be systemd-native</font>
        <div><br>
          <div>I can recommend create dedicated systemd unit file
            "prepare-rtpengine.service"<br>
            Like this<br>
            <br>
          </div>
        </div>
        <div><font color="#0000ff">[Unit]<br>
            Description=prepare rpengine<br>
            <br>
            [Service]<br>
            Type=oneshot<br>
            RemainAfterExit=yes<br>
            ExecStartPre=/usr/sbin/modprobe xt_RTPENGINE<br>
            ExecStart=/usr/sbin/iptables -I INPUT -p udp -j RTPENGINE
            --id 0<br>
            ExecStartPost=ip6tables -I INPUT -p udp -j RTPENGINE --id 0<br>
            StandardOutput=syslog<br>
            StandardError=syslog<br>
            <br>
            [Install]<br>
            RequiredBy=rtpengine.service<br>
            WantedBy=basic.target</font><br>
        </div>
        <div><br>
        </div>
        <div>and then<br>
          <font color="#0000ff">systemctl
            enable prepare-rtpengine.service</font></div>
        <div><br>
          This will create dependency that will be execute one tme
          before rtpengine daemon started.</div>
        <div><br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Fri, Jan 17, 2020 at 5:03
          PM Daniel-Constantin Mierla <<a
            href="mailto:miconda@gmail.com" moz-do-not-send="true">miconda@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
          <br>
          do people here have (implemented) special ways to properly
          start<br>
          rtpengine with kernel forwarding after system reboot?<br>
          <br>
          From rtpengine readme:<br>
          <br>
          """<br>
          <br>
          A typical start-up sequence including in-kernel forwarding
          might look<br>
          like this:<br>
          <br>
          # this only needs to be one once after system (re-) boot<br>
          modprobe xt_RTPENGINE<br>
          iptables -I INPUT -p udp -j RTPENGINE --id 0<br>
          ip6tables -I INPUT -p udp -j RTPENGINE --id 0<br>
          <br>
          # ensure that the table we want to use doesn't exist - usually
          needed<br>
          after a daemon<br>
          # restart, otherwise will error<br>
          echo 'del 0' > /proc/rtpengine/control<br>
          <br>
          # start daemon<br>
          /usr/sbin/rtpengine --table=0 --interface=10.64.73.31<br>
          --interface=2001:db8::4f3:3d \<br>
          --listen-ng=<a href="http://127.0.0.1:2223" rel="noreferrer"
            target="_blank" moz-do-not-send="true">127.0.0.1:2223</a>
          --tos=184 --pidfile=/run/rtpengine.pid<br>
          --no-fallback<br>
          <br>
          """<br>
          <br>
          I was relying on shell scripts executed on boot time, but now
          that<br>
          systemd is more common, I am looking to see what are<br>
          "standard"/"recommended" ways for running additional scripts
          besides the<br>
          start/stop daemon, which makes it also easier to build
          packages not<br>
          worrying about the type of OS and how it can run scripts at
          startup.<br>
          <br>
          Systemd seems to have the "ExecStartPre" option, is it what
          people use<br>
          to ensure the rtpengine kernel module is loaded and iptables
          rule exists?<br>
          <br>
          Any systemd-specific wayt to run a script only once after
          system boot? I<br>
          have seen workarounds on the net for creating like a rc.local
          service,<br>
          but they didn't look to be systemd-native, ...<br>
          <br>
          Not strictly related, but if someone is aware or had some
          experiences<br>
          with,  I am curious if "echo 'del 0' >
          /proc/rtpengine/control" is<br>
          really needed because on a system where I forgot to have it in
          the<br>
          scripts (well, was commented), I haven't noticed any issues
          after<br>
          rtpengine restarts.<br>
          <br>
          Cheers,<br>
          Daniel<br>
          <br>
          -- <br>
          Daniel-Constantin Mierla -- <a href="http://www.asipto.com"
            rel="noreferrer" target="_blank" moz-do-not-send="true">www.asipto.com</a><br>
          <a href="http://www.twitter.com/miconda" rel="noreferrer"
            target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a>
          -- <a href="http://www.linkedin.com/in/miconda"
            rel="noreferrer" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a><br>
          Kamailio World Conference - April 27-29, 2020, in Berlin -- <a
            href="http://www.kamailioworld.com" rel="noreferrer"
            target="_blank" moz-do-not-send="true">www.kamailioworld.com</a><br>
          <br>
          <br>
          _______________________________________________<br>
          Kamailio (SER) - Users Mailing List<br>
          <a href="mailto:sr-users@lists.kamailio.org" target="_blank"
            moz-do-not-send="true">sr-users@lists.kamailio.org</a><br>
          <a
            href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
        </blockquote>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio World Conference - April 27-29, 2020, in Berlin -- <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
  </body>
</html>