• Categories
    • Recent
    • Tags
    • Popular
    • Register
    • Login

    Auto update & upgrade your pi with MyController.

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 2 Posters 656 Views 2 Watching
    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.
    • skywatchS Offline
      skywatch
      last edited by

      If you want to automate keeping your pi up-to-date then this little script may be for you.

      Just copy and save it in a file (I called mine autoupdate.sh - but you can use whatever name you like!) and then use crontab -e to run the above named file whenever you want.

      I tested it by daily running, but now it only runs once a week in the early hours of the morning.

      #!/bin/sh
      export DEBIAN_FRONTEND=noninteractive
      export DEBIAN_PRIORITY=critical
      sudo bash /home/mycontroller/bin/stop.sh
      sleep 15
      sudo bash /home/mcagent/bin/stop.sh
      sleep 15
      sudo -E apt-get -qy update
      sudo -E apt-get -qy -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" upgrade
      sudo -E apt-get -qy autoclean
      sudo reboot
      

      Maybe some of you might even have improvements to suggest! 😉

      T 1 Reply Last reply Reply Quote 1
      • T Offline
        Tag MOD @skywatch
        last edited by

        @skywatch

        Cool!! great work!! :thumbs_up:

        Think that the sleep can be replaced with a test if the script is still running. will have a look see what i can find.

        1 Reply Last reply Reply Quote 0
        • skywatchS Offline
          skywatch
          last edited by

          Yeah, I thought about that but 'sleep' seems only to work with processes spawned within the script - or maybe I completely mis-understand it. I'm still learning a lot! 😉

          1 Reply Last reply Reply Quote 0
          • T Offline
            Tag MOD
            last edited by Tag

            Well, looking at the start and stop scripts, there is a test that looks if mycontroller is running..

            ps -ef | grep "org.mycontroller.standalone.StartApp" | grep -v grep | awk '{ print $2 }'
            

            so you could test if the line above returns the pid of mycontroller. If a number (process id) is returned, mycontroller is running, if no data returned, mycontroller is down..

            1 Reply Last reply Reply Quote 0
            • skywatchS Offline
              skywatch
              last edited by skywatch

              @Tag

              That's brilliant - Thank you!

              McAgent is similar, so could work for both.....

              I have to take Mum shopping today but will try this out in the script as soon as I can 😉

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

              0

              Online

              587

              Users

              529

              Topics

              3.4k

              Posts
              Copyright © 2015-2025 MyController.org | Contributors | Localization