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

    Where is the best place to store custom scripts for ease of maintenace?

    Scheduled Pinned Locked Moved General pfSense Questions
    10 Posts 7 Posters 4.6k 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.
    • G
      guardian Rebel Alliance
      last edited by

      I am running pfSense on a machine with an SSD (not embedded), and I want to set up a couple of small python or shell scripts that run from CRON.  Where is the best place to store these scripts for ease of backup, and so they survive upgrades and other automated maintenace tasks?

      If you find my post useful, please give it a thumbs up!
      pfSense 2.7.2-RELEASE

      1 Reply Last reply Reply Quote 1
      • C
        cmb
        last edited by

        Where ever you want is fine. Upgrades won't change files that don't exist in the base system.

        1 Reply Last reply Reply Quote 0
        • N
          NOYB
          last edited by

          May be good idea to avoid /tmp and /var.  Depending on type of install and ram disk settings they could evaporate when system is rebooted.

          I put stuff like that in /vvar.

          1 Reply Last reply Reply Quote 0
          • G
            guardian Rebel Alliance
            last edited by

            @NOYB:

            May be good idea to avoid /tmp and /var.  Depending on type of install and ram disk settings they could evaporate when system is rebooted.

            I put stuff like that in /vvar.

            What about backup?  If I understand correctly, backup only backs up config.

            Would be nice to be able to roll everything into the backup, but maybe that's not possible.
            Having custom files in the middle of the existing system sounds like a maintenance/backup nightmare.

            Would I be better off to create a user (custom) and put everything in /home/custom ? 
            At least everything is in one spot.

            If you find my post useful, please give it a thumbs up!
            pfSense 2.7.2-RELEASE

            1 Reply Last reply Reply Quote 0
            • S
              Stewart
              last edited by

              I just create a folder on / like /custom.  Then any scripts that are called in cron are easily recognizable since the work custom is right in the command line.

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

                Personally, I keep custom files under /root/ so they're easy to keep track of. Really though, as cmb said, it doesn't matter so long as you know where they are. You can use the "Backup" package to backup arbitrary files and directories.

                If you want to follow hier(7) for your scripts, then common programs and utilities go in /usr/local/bin/ and administrator and system daemons/utilities would go in /usr/local/sbin/

                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
                • K
                  kpa
                  last edited by

                  If I had to choose I would use /root instead /usr/local, the latter is reserved for ports and packages that are under pkg control.

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

                    @kpa:

                    If I had to choose I would use /root instead /usr/local, the latter is reserved for ports and packages that are under pkg control.

                    Files from packages may reside there but it isn't solely for them. In FreeBSD it's for anything, as the name implies, local. As in non-base-system. It's free to be used in that way. See the link in my previous reply.

                    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
                    • S
                      Soyokaze
                      last edited by

                      Or you can go all the way with additional partition mounted anywhere you like. Only thing to remember - not to select "Quick install" on full reinstall.

                      Need full pfSense in a cloud? PM for details!

                      1 Reply Last reply Reply Quote 0
                      • G
                        guardian Rebel Alliance
                        last edited by

                        Thanks everyone for the input everyone… You've helped me think this over... and given:

                        • I want/need ease of maintenance-simple backup/restore.

                        • Custom scripts with least privilege possible-under an user with minimal rights.

                        • It's only a couple of scripts and a few kb of disk space. (A partition is not warranted.)

                        • /root is not completely under user control… file backup plugin uses it.

                        I'm thinking that it would be hard to do better than:

                        • creating a user: custom (with minimal rights).

                        • Stick everything in /home/custom

                        • Write a quick script to tar.gz /home/custom and scp to my FreeNAS box for backup
                          (or maybe use the file backup plugin, but given that it doesn't do time versions
                          automatically or allow granular restore or multiple backup profiles.)

                        A normal configuration restore will recreate everything except the actual scripts in /home/custom

                        If I'm missing something or anyone has any other suggestions, be glad to hear them.

                        If you find my post useful, please give it a thumbs up!
                        pfSense 2.7.2-RELEASE

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