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

    How to make a script persistent across configuration restore?

    Development
    4
    8
    1.0k
    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.
    • ssbarneaS
      ssbarnea
      last edited by

      Based on the documentation from https://docs.netgate.com/pfsense/en/latest/development/executing-commands-at-boot-time.html it seems that if you deploy a schell script it will be lost on upgrade and not restored from a configuration backup.

      At the same time the persistent recommended method named shellcmd seems to allow only a very short command to be run. If I have a shell script of several lines it would be impossible to paste it there.

      Is there a way to avoid this and make shell scripts to be included in the backup?

      GertjanG 1 Reply Last reply Reply Quote 0
      • jimpJ
        jimp Rebel Alliance Developer Netgate
        last edited by

        You can't include an entire script there, or in the config.xml backup from the base system.

        If you could turn it into a shell one-liner, maybe, but that is still a bit tricky to get right.

        That said, there is a Backup add-on package that might help get closer to what you are after.

        Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

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

          @ssbarnea said in How to make a script persistent across configuration restore?:

          Based on the documentation from https://docs.netgate.com/pfsense/en/latest/development/executing-commands-at-boot-time.html it seems that if you deploy a schell script it will be lost on upgrade and not restored from a configuration backup.

          On the other hand :
          I added some files and even non-pfSense, but FreeBSD packages like Munin several years (5 ?!) ago.
          These files are still there - my first pfSense install was from before 2.0
          Upgrading didn't removed nothing.

          So, if you add a file - keep a log of it. You could even use the pfSense "Notes" package where you can explain to yourself, for later usage, what you put where and why. You can even put the scripts into the Notes package - its content will be present in the config.xml that you keep aside for backup reasons.

          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 1
          • GrimsonG
            Grimson Banned @jimp
            last edited by Grimson

            @jimp said in How to make a script persistent across configuration restore?:

            You can't include an entire script there, or in the config.xml backup from the base system.

            Not even with the Filer package?

            Edit:
            I just tested it and files created with the Filer package are stored in the config.xml backup.

            jimpJ 1 Reply Last reply Reply Quote 0
            • jimpJ
              jimp Rebel Alliance Developer Netgate @Grimson
              last edited by

              @grimson said in How to make a script persistent across configuration restore?:

              @jimp said in How to make a script persistent across configuration restore?:

              You can't include an entire script there, or in the config.xml backup from the base system.

              Not even with the Filer package?

              Edit:
              I just tested it and files created with the Filer package are stored in the config.xml backup.

              Yes, you can do it with packages, but I said "from the base system".

              Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

              1 Reply Last reply Reply Quote 1
              • ssbarneaS
                ssbarnea
                last edited by ssbarnea

                For the moment I am using Ansible to deploy the configuration which mainly solves the problem of redeploying it.

                I am curious about the nature of of the scripts from /usr/local/etc/rc.d/ -- do they all need to finish during boot time or is ok if my script does something in an endless loop?

                I kinda need to assure that this runs forever and more important to avoid running two copies in parallel. I do not want to create a full blown service for that.

                jimpJ 1 Reply Last reply Reply Quote 0
                • jimpJ
                  jimp Rebel Alliance Developer Netgate @ssbarnea
                  last edited by

                  @ssbarnea said in How to make a script persistent across configuration restore?:

                  I am curious about the nature of of the scripts from /usr/local/etc/rc.d/ -- do they all need to finish during boot time or is ok if my script does something in an endless loop?

                  You'd need to make the script run the background somehow, such as with &, nohup, screen, or similar.

                  Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                  Need help fast? Netgate Global Support!

                  Do not Chat/PM for help!

                  1 Reply Last reply Reply Quote 0
                  • ssbarneaS
                    ssbarnea
                    last edited by

                    Thanks, I nailed it and endup with a script that does what I want, without the risk of running multiple instances in parallel.

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