• header.categories
    • header.recent
    • header.tags
    • header.popular
    • register
    • login

    Auto update & upgrade your pi with MyController.

    scheduled pinned locked moved General Discussion
    5 posts 2 posters 921 views 2 watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • skywatchS offline
      skywatch
      global: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 one-reply-to-this-post last-reply-time reply quote 1
      • T offline
        Tag MOD @skywatch
        global: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.

        one-reply-to-this-post last-reply-time reply quote 0
        • skywatchS offline
          skywatch
          global: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! 😉

          one-reply-to-this-post last-reply-time reply quote 0
          • T offline
            Tag MOD
            global: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..

            one-reply-to-this-post last-reply-time reply quote 0
            • skywatchS offline
              skywatch
              global: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 😉

              one-reply-to-this-post last-reply-time reply quote 0
              • first-post
                last-post

              0

              online

              644

              users

              532

              topics

              3.4k

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