ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Ubiquiti ERL script wanted to compare md5 values

    Scheduled Pinned Locked Moved IT Discussion
    edgemaxscriptingubiquitimd5checksumbash
    34 Posts 2 Posters 9.5k 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.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Add this to clean it up...

      md5sum -c /config/md5test.md5 2>/dev/null || echo "Fail"
      
      1 Reply Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch
        last edited by

        looking at what i need to do to send an email. The documentation for ERL sucks as it is mostly community created and the package stuff changed with firmware 1.6.0

        scottalanmillerS 1 Reply Last reply Reply Quote 0
        • scottalanmillerS
          scottalanmiller
          last edited by

          Also try it with good md5 sums to make sure it does nothing when they are successfully matched. Just to be sure.

          JaredBuschJ 1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller @JaredBusch
            last edited by

            @JaredBusch said:

            looking at what i need to do to send an email. The documentation for ERL sucks as it is mostly community created and the package stuff changed with firmware 1.6.0

            Oh shoot, forgot that it was ERL. Might not use the same mail command at all. That's a common syntax, but certainly not the only one.

            1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch @scottalanmiller
              last edited by

              @scottalanmiller said:

              Also try it with good md5 sums to make sure it does nothing when they are successfully matched. Just to be sure.

              I did.

              jbusch@jared:~$ md5sum -c /config/md5test.md5 echo && "Successful test of MD5" || echo "Failed test of MD5"
              /root.dev/squashfs.img: OK
              /root.dev/squashfs.o: OK
              md5sum: echo: No such file or directory
              Failed test of MD5
              jbusch@jared:~$ md5sum -c /config/md5test.md5 && echo "Successful test of MD5" || echo "Failed test of MD5"
              /root.dev/squashfs.img: OK
              /root.dev/squashfs.o: OK
              Successful test of MD5
              jbusch@jared:~$
              
              1 Reply Last reply Reply Quote 0
              • scottalanmillerS
                scottalanmiller
                last edited by

                The first one "worked" because you put in three commands and the middle one had a typo so failed caused the third one to trigger. You didn't test what you think that you tested.

                1 Reply Last reply Reply Quote 0
                • JaredBuschJ
                  JaredBusch
                  last edited by

                  I did earlier then when doing further testing found it easier to use the typo instead of updating the .md5 file repeatedly. guess i could have made a second one for failure testing.. It is late and I am a bit lazy at this point.

                  scottalanmillerS 1 Reply Last reply Reply Quote 0
                  • scottalanmillerS
                    scottalanmiller @JaredBusch
                    last edited by

                    @JaredBusch said:

                    I did earlier then when doing further testing found it easier to use the typo instead of updating the .md5 file repeatedly. guess i could have made a second one for failure testing.. It is late and I am a bit lazy at this point.

                    Only problem is that you are testing the failure of the echo command not of the md5sum in doing that.

                    1 Reply Last reply Reply Quote 0
                    • JaredBuschJ
                      JaredBusch
                      last edited by

                      I was making sure a success worked like i thought because i was thinking that writing it to a system log would be good even on success.

                      1 Reply Last reply Reply Quote 0
                      • scottalanmillerS
                        scottalanmiller
                        last edited by

                        Oh no, I think you are right, that syntax should work.

                        1 Reply Last reply Reply Quote 0
                        • JaredBuschJ
                          JaredBusch
                          last edited by

                          Happy now?

                          jbusch@jared:~$ md5sum -c /config/bad.md5 && echo "Successful test of MD5" || echo "Failed test of MD5"
                          /root.dev/squashfs.img: OK
                          /root.dev/squashfs.o: FAILED
                          md5sum: WARNING: 1 of 2 computed checksums did NOT match
                          Failed test of MD5
                          jbusch@jared:~$ md5sum -c /config/good.md5 && echo "Successful test of MD5" || echo "Failed test of MD5"
                          /root.dev/squashfs.img: OK
                          /root.dev/squashfs.o: OK
                          Successful test of MD5
                          jbusch@jared:~$
                          
                          1 Reply Last reply Reply Quote 0
                          • scottalanmillerS
                            scottalanmiller
                            last edited by

                            Yes better 🙂

                            Don't forget the 2>/dev/null so you only get the result message.

                            1 Reply Last reply Reply Quote 0
                            • JaredBuschJ
                              JaredBusch
                              last edited by JaredBusch

                              what is the 2 for? it still printed instead of sending the output to /dev/null

                              jbusch@jared:~$ md5sum -c /config/good.md5 2>/dev/null && echo "Successful test of MD5" || echo "Failed test of MD5"
                              /root.dev/squashfs.img: OK
                              /root.dev/squashfs.o: OK
                              Successful test of MD5
                              jbusch@jared:~$ md5sum -c /config/good.md5 > /dev/null && echo "Successful test of MD5" || echo "Failed test of MD5"
                              Successful test of MD5
                              
                              1 Reply Last reply Reply Quote 0
                              • scottalanmillerS
                                scottalanmiller
                                last edited by

                                Argh, I must be getting tired.

                                The 2 is good but not what we wanted. Just drop the 2 completely. Just >/dev/null

                                JaredBuschJ 1 Reply Last reply Reply Quote 0
                                • scottalanmillerS
                                  scottalanmiller
                                  last edited by

                                  That's better, no extraneous junk. Just pass or fail.

                                  1 Reply Last reply Reply Quote 0
                                  • scottalanmillerS
                                    scottalanmiller
                                    last edited by

                                    Now if you want to run that every five minutes or hourly or daily or whatever you can pop it into the crontab and it will run it for you.

                                    JaredBuschJ 1 Reply Last reply Reply Quote 0
                                    • JaredBuschJ
                                      JaredBusch @scottalanmiller
                                      last edited by

                                      @scottalanmiller said:

                                      Argh, I must be getting tired.

                                      The 2 is good but not what we wanted. Just drop the 2 completely. Just >/dev/null

                                      I did. if you look again. And I even recalled the piping output to dev.null once i seen it fail. Like, oh yeah, I learned this a time or three..

                                      1 Reply Last reply Reply Quote 0
                                      • JaredBuschJ
                                        JaredBusch @scottalanmiller
                                        last edited by

                                        @scottalanmiller said:

                                        Now if you want to run that every five minutes or hourly or daily or whatever you can pop it into the crontab and it will run it for you.

                                        Yeah, I am thinking weekly to /var/log/ or something on success and the log and email on a problem.

                                        But, now that I am this far on it, I want to look at not having to create the good.md5 on each ERL and after every upgrade (because the value will change). SO, I may need an actual bash script.

                                        But that is not for tonight.

                                        1 Reply Last reply Reply Quote 0
                                        • JaredBuschJ
                                          JaredBusch
                                          last edited by JaredBusch

                                          Posted over on the UBNT forums.. We'll see what happens. I am heading to bed i think.

                                          1 Reply Last reply Reply Quote 0
                                          • scottalanmillerS
                                            scottalanmiller
                                            last edited by

                                            Good night.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 2 / 2
                                            • First post
                                              Last post