Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    rc.d startup script seems to keep running all the time

    Scheduled Pinned Locked Moved General pfSense Questions
    4 Posts 4 Posters 572 Views
    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
      sparkman123
      last edited by

      I am trying to write a startup script that runs at boot time for pfsense. I have been able to create one that works correctly, however, I have noticed that, while it runs at boot time, it also runs when certain services, such as openvpn, are restarted.

      Below is the source for my bootscript in rc.d/

      # . /etc/rc.subr
      
      # name="tinhat"
      # start_cmd="${name}_start"
      # stop_cmd=":"
      
      # tinhat_start()
      # {
          # /bin/sh /root/./bootlog2.sh
          # /usr/bin/touch /root/ihavestarted
      # }
      
      # load_rc_config ${name}
      # run_rc_command "$1"
      

      I played around with the #PROVIDE and #REQUIRE directives, but those had no effect.

      Is there an additional configuration change I need to make in order for this to run only once?

      1 Reply Last reply Reply Quote 0
      • GertjanG
        Gertjan
        last edited by Gertjan

        @sparkman123 said in rc.d startup script seems to keep running all the time:

        to run only once?

        Here you go :
        Install the Shellcmd package.
        Goto Services > Shellcmd Settings and add a "shellcmd" or "earlyshellcmd".

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

        1 Reply Last reply Reply Quote 0
        • kiokomanK
          kiokoman LAYER 8
          last edited by

          did you try to use Shellcmd instead ?
          it's really neat

          shellcmd
          Will run the command specified towards the end of the boot process.
          earlyshellcmd
          Will run the command specified at the beginning of the boot process.
          afterfilterchangeshellcmd
          Will run after each filter_configure() call. See /etc/inc/filter.inc source code for "documentation".
          Note: Only one entry of this type can be configured!
          

          ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
          Please do not use chat/PM to ask for help
          we must focus on silencing this @guest character. we must make up lies and alter the copyrights !
          Don't forget to Upvote with the 👍 button for any post you find to be helpful.

          1 Reply Last reply Reply Quote 0
          • stephenw10S
            stephenw10 Netgate Administrator
            last edited by

            Yes, using shellcmd is easiest here and it then stores the command in the config file. However to run at rc.d script use /usr/local/etc/rc.d/.
            https://docs.netgate.com/pfsense/en/latest/development/executing-commands-at-boot-time.html

            Steve

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.