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

    Helper Script

    Development
    2
    5
    1.7k
    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.
    • B
      BJXYZ
      last edited by

      Hello,

      Here in the forum I have read that some people have even written scripts to automate tasks. I would like to add and remove rules, but I do not know how to begin. Some people looked at the php code and other edit the config.xml. Can someone perhaps give me a script or some code to start building my own script?

      Greetings

      BJ

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

        Have you looked at the PHP shell?
        http://doc.pfsense.org/index.php/Using_the_PHP_pfSense_Shell

        Steve

        1 Reply Last reply Reply Quote 0
        • B
          BJXYZ
          last edited by

          Yes, but i want something to call from remote. I have no idea howto call this automatical via ssh. I want to use something over HTTP or a script diretcly called via ssh. For example on google I found a user who wrote this

          I don't have a pfSense box right now, but you can do something like:

          ssh r…@192.51.100.20 /my/script.php blocklist 198.51.100.20 comment
          ssh r...@192.51.100.20 rm -f /tmp/config.cache ; /etc/rc.reload_something2x

          Where /my/script.php is a script that modifies /conf/config.xml.
          Hacking that script would only take a minute.  You can modify
          /tmp/rules.debug too, but the rules would be removed on next reload.
          :)

          Anyway, you can try this sed trick if you don't want to use PHP:

          sed 's/<rules>$/<rules><entry1>insert here</entry>/g'
          /conf/config.xml > /conf/config.xml.new</entry1></rules></rules>

          So I though somebody has allready a script which modify the config.xml or some code which could help my writting my own script.

          BJ

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

            You can playback php shell recording directly from the normal shell if that helps.

            Steve

            1 Reply Last reply Reply Quote 0
            • B
              BJXYZ
              last edited by

              Okay thanks. I will try this.

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