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

    2100 LED question

    Scheduled Pinned Locked Moved Hardware
    30 Posts 5 Posters 2.3k 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.
    • JonathanLeeJ
      JonathanLee
      last edited by JonathanLee

      Screenshot 2023-08-24 at 11.51.41 AM.png

      I got my rule id it is 43

      However running

      Screenshot 2023-08-24 at 11.52.32 AM.png

      switch -R does not work for some reason

      It would be these rules to show stats only

      Screenshot 2023-08-24 at 12.10.29 PM.png

      In linux you can just display specific information I wonder how to pluck that out in freebsd

      pfctl -vvsr

      I will figure it out I just need all the rules that are in use for GAME_IP_GROUP

      YEAHHHH use them with pfctl -vvss | grep ', rule ... and we should be good to make a script use a if clause if !null it should work and make a cron for it

      Make sure to upvote

      1 Reply Last reply Reply Quote 0
      • JonathanLeeJ
        JonathanLee
        last edited by JonathanLee

        Screenshot 2023-08-24 at 12.19.07 PM.png

        pfctl -vvss | grep ', rule 43'

        Make sure to upvote

        1 Reply Last reply Reply Quote 0
        • JonathanLeeJ
          JonathanLee
          last edited by

          I am going to use this as a string entry and check to see if it is null if not turn the led on.

          Simple enough in theory.

          Screenshot 2023-08-24 at 1.02.54 PM.png

          Make sure to upvote

          1 Reply Last reply Reply Quote 0
          • JonathanLeeJ
            JonathanLee
            last edited by JonathanLee

            Something maybe like this

            #!/bin/sh
            pfctl -vvss | grep ', rule 79' >/dev/null
            res=$?
            
            if [ $res = 0 ]; then
              sysctl -q dev.gpio.2.led.2.pwm=1
              gpioctl -f /dev/gpioc2 6 duty 1 >/dev/null
            fi
            
            
            Or...
            
            #!/bin/sh
            
            str="$(pfctl -vvss | grep ', rule 79')"
            
            if [ -z "$str" ]; then
              sysctl -q dev.gpio.2.led.2.pwm=1
              gpioctl -f /dev/gpioc2 6 duty 1 >/dev/null
            fi
            

            Ref Researching:
            https://forums.freebsd.org/threads/bin-sh-how-to-save-a-shell-command-output-into-a-string-variable.90088/

            Make sure to upvote

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

              The problem there is that the rule number an change if you add or remove rules. I was hoping you might be able to see tags on rules in the states but I don't see a way to do that. Yet...

              JonathanLeeJ 2 Replies Last reply Reply Quote 1
              • JonathanLeeJ
                JonathanLee @stephenw10
                last edited by

                @stephenw10 It works if you don't adjust the rules I have it going now.

                Make sure to upvote

                1 Reply Last reply Reply Quote 0
                • JonathanLeeJ
                  JonathanLee
                  last edited by JonathanLee

                  /root/deviceonlinenight

                  #!/bin/sh
                  pfctl -vvss | grep ', rule 79' >/dev/null
                  res=$?
                  if [ $res = 0 ]; 
                  then
                    sysctl -q dev.gpio.2.led.0.pwm=1
                    gpioctl -f /dev/gpioc2 0 duty 200 >/dev/null
                    sysctl -q dev.gpio.2.led.1.pwm=1
                    gpioctl -f /dev/gpioc2 3 duty 200 >/dev/null
                    sysctl -q dev.gpio.2.led.2.pwm=1
                    gpioctl -f /dev/gpioc2 6 duty 200 >/dev/null
                  else
                    sysctl -q dev.gpio.2.led.0.pwm=1
                    gpioctl -f /dev/gpioc2 0 duty 0 >/dev/null
                    gpioctl -f /dev/gpioc2 1 duty 0 >/dev/null
                    gpioctl -f /dev/gpioc2 2 duty 0 >/dev/null
                    sysctl -q dev.gpio.2.led.1.pwm=1
                    gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
                    gpioctl -f /dev/gpioc2 4 duty 0 >/dev/null
                    gpioctl -f /dev/gpioc2 5 duty 0 >/dev/null
                    sysctl -q dev.gpio.2.led.2.pwm=1
                    gpioctl -f /dev/gpioc2 6 duty 0 >/dev/null
                    gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
                    gpioctl -f /dev/gpioc2 8 duty 0 >/dev/null
                  fi
                  
                  

                  /root/deviceonlineday

                  #!/bin/sh
                  pfctl -vvss | grep ', rule 79' >/dev/null
                  res=$?
                  if [ $res = 0 ]; 
                  then
                    sysctl -q dev.gpio.2.led.1.pwm=1
                    gpioctl -f /dev/gpioc2 3 duty 100 >/dev/null
                    sysctl -q dev.gpio.2.led.2.pwm=1
                    gpioctl -f /dev/gpioc2 6 duty 100 >/dev/null
                  else
                    sysctl -q dev.gpio.2.led.1.pwm=1
                    gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
                    sysctl -q dev.gpio.2.led.2.pwm=1
                    gpioctl -f /dev/gpioc2 7 duty 100 >/dev/null
                  fi
                  
                  

                  Make sure to upvote

                  1 Reply Last reply Reply Quote 1
                  • JonathanLeeJ
                    JonathanLee @stephenw10
                    last edited by JonathanLee

                    @stephenw10

                    pfctl -vvss| grep '192.168.1.11' would work great too as it would be IP address based not rule based
                    also
                    pfctl -vvss| grep -e 192.168.1.18 -e 192.168.1.11

                    Make sure to upvote

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

                      Nice!

                      1 Reply Last reply Reply Quote 1
                      • JonathanLeeJ
                        JonathanLee
                        last edited by JonathanLee

                        Kind of amazing looking when testing the deviceonlinenight.sh

                        IMG_20230824_220920858.jpg

                        It looks like the CM-5

                        The 90s Connection Machine

                        Muzio_CM5.jpg

                        Make sure to upvote

                        1 Reply Last reply Reply Quote 1
                        • JonathanLeeJ
                          JonathanLee
                          last edited by JonathanLee

                          #!/bin/sh
                          pfctl -vvss | grep ', rule 79' >/dev/null
                          res=$?
                          if [ $res = 0 ]; 
                          then
                            sysctl -q dev.gpio.2.led.1.pwm=1
                            gpioctl -f /dev/gpioc2 3 duty 100 >/dev/null
                            sysctl -q dev.gpio.2.led.2.pwm=1
                            gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
                            gpioctl -f /dev/gpioc2 6 duty 100 >/dev/null
                            gpioctl -f /dev/gpioc2 8 duty 100 >/dev/null
                          else
                            sysctl -q dev.gpio.2.led.1.pwm=1
                            gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
                            sysctl -q dev.gpio.2.led.2.pwm=1
                            gpioctl -f /dev/gpioc2 6 duty 0 >/dev/null
                            gpioctl -f /dev/gpioc2 8 duty 0 >/dev/null
                            gpioctl -f /dev/gpioc2 7 duty 7 >/dev/null
                          fi
                          
                          

                          IMG_20230825_171454810.jpg

                          This will have purple and red :)

                          Make sure to upvote

                          1 Reply Last reply Reply Quote 0
                          • JonathanLeeJ
                            JonathanLee
                            last edited by

                            Another way to do this now you can run the pfctl command once and use the case command to iterate over the variable I named state

                            #!/bin/sh
                            state=$( pfctl -vvss )
                            res=1
                            resb=1
                            case "$state" in 
                              *, rule 79*)
                                res=0
                                ;;
                            esac
                            case "$state" in 
                              *192.168.1.11*)
                                resb=0
                                ;;
                            esac
                            if [ $res = 0 ] && [ $resb = 0 ]; 
                            then
                              sysctl -q dev.gpio.2.led.1.pwm=1
                              gpioctl -f /dev/gpioc2 3 duty 50 >/dev/null
                              sysctl -q dev.gpio.2.led.2.pwm=1
                              gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
                              gpioctl -f /dev/gpioc2 6 duty 50 >/dev/null
                            elif [ $res = 0 ];
                            then
                              sysctl -q dev.gpio.2.led.1.pwm=1
                              gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
                              sysctl -q dev.gpio.2.led.2.pwm=1
                              gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
                              gpioctl -f /dev/gpioc2 6 duty 50 >/dev/null
                            elif [ $resb = 0 ];
                            then
                              sysctl -q dev.gpio.2.led.2.pwm=1
                              gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
                              gpioctl -f /dev/gpioc2 6 duty 0 >/dev/null
                              sysctl -q dev.gpio.2.led.1.pwm=1
                              gpioctl -f /dev/gpioc2 3 duty 50 >/dev/null
                            else
                              sysctl -q dev.gpio.2.led.1.pwm=1
                              gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
                              sysctl -q dev.gpio.2.led.2.pwm=1
                              gpioctl -f /dev/gpioc2 6 duty 0 >/dev/null
                              gpioctl -f /dev/gpioc2 7 duty 50 >/dev/null
                              
                            fi
                            
                            

                            Make sure to upvote

                            1 Reply Last reply Reply Quote 1
                            • JonathanLeeJ
                              JonathanLee
                              last edited by

                              Here is a version with 3 conditional LED adaptions.

                              #!/bin/sh
                              check_current_states=$( pfctl -vvss | grep -e ', rule 84' -e '192.168.1.11' -e '192.168.1.15' )
                              res=1
                              resb=1
                              resc=1
                              case "$check_current_states" in 
                                *", rule 79"* ) res=0 ;;
                              esac
                              case "$check_current_states" in
                                *192.168.1.11* ) resb=0 ;;
                              esac
                              case "$check_current_states" in
                                *192.168.1.15* ) resc=0 ;;
                              esac
                              if [ $res = 0 ] && [ $resb = 0 ]; 
                              then
                                sysctl -q dev.gpio.2.led.1.pwm=1
                                gpioctl -f /dev/gpioc2 3 duty 50 >/dev/null
                                sysctl -q dev.gpio.2.led.2.pwm=1
                                gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
                                gpioctl -f /dev/gpioc2 6 duty 50 >/dev/null
                              elif [ $res = 0 ];
                              then
                                sysctl -q dev.gpio.2.led.1.pwm=1
                                gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
                                sysctl -q dev.gpio.2.led.2.pwm=1
                                gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
                                gpioctl -f /dev/gpioc2 6 duty 50 >/dev/null
                              elif [ $resb = 0 ];
                              then
                                sysctl -q dev.gpio.2.led.2.pwm=1
                                gpioctl -f /dev/gpioc2 7 duty 0 >/dev/null
                                gpioctl -f /dev/gpioc2 6 duty 0 >/dev/null
                                sysctl -q dev.gpio.2.led.1.pwm=1
                                gpioctl -f /dev/gpioc2 3 duty 50 >/dev/null
                              else
                                sysctl -q dev.gpio.2.led.1.pwm=1
                                gpioctl -f /dev/gpioc2 3 duty 0 >/dev/null
                                sysctl -q dev.gpio.2.led.2.pwm=1
                                gpioctl -f /dev/gpioc2 6 duty 0 >/dev/null
                                gpioctl -f /dev/gpioc2 7 duty 50 >/dev/null
                                
                              fi
                              if [ $resc = 0 ];
                              then
                                sysctl -q dev.gpio.2.led.0.pwm=1
                                gpioctl -f /dev/gpioc2 2 duty 50 >/dev/null
                              else
                                sysctl -q dev.gpio.2.led.0.pwm=1
                                gpioctl -f /dev/gpioc2 2 duty 0 >/dev/null
                              
                              fi
                              

                              Make sure to upvote

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