Update notifier – low resources script to check and install updates

Forum Forums General Tips and Tricks Update notifier – low resources script to check and install updates

  • This topic has 34 replies, 6 voices, and was last updated Feb 26-2:01 pm by Lead Farmer.
Viewing 5 posts - 31 through 35 (of 35 total)
  • Author
    Posts
  • #100590
    Member
    Lead Farmer
      Helpful
      Up
      0
      ::

      Add echo something and sleep something into your script.

      In roxterm –help -e “Execute remainder of command line inside the terminal. Must be the final option.”

      $(roxterm -e sudo apt upgrade)

      So roxtrem terminal is closing when the upgrade is done. and I wanted to keep it open, I don’t know how add echo something and sleep will keep it open.

      But as I said it doesn’t mater I replaced it with:

      x-terminal-emulator -T "$title_terminal" -e /bin/bash -c "sudo apt upgrade && sleep 0.1 && yad --center --borders=5 --width=250 --text-align=center --button=gtk-ok:1 --title='Update Complete' --buttons-layout=center"

      • This reply was modified 2 months, 1 week ago by Lead Farmer.
      • This reply was modified 2 months, 1 week ago by Lead Farmer.
      • This reply was modified 2 months, 1 week ago by Lead Farmer.
      #100613
      Member
      RJP
        Helpful
        Up
        0
        ::

        Platform does not allow to write whole script, but you can add bin/bash yourself.

        while :
        do
        echo ###################
        echo My update script
        echo #################
        x-terminal-emulator -T "$title_terminal" -e /bin/bash -c "sudo apt update && sudo apt upgrade && yad --center --borders=5 --width=250 --text-align=center --button=gtk-ok:1 --title='Update Complete' --buttons-layout=center"
        sleep 10
        killall update-script
        clear
        done
        '"

        PS. replace killall update-script with the right script name.

        Edit: Your script has no update feature, so add sudo apt update && sudo apt upgrade

        • This reply was modified 2 months, 1 week ago by RJP.
        • This reply was modified 2 months, 1 week ago by RJP.
        • This reply was modified 2 months, 1 week ago by RJP.
        #100618
        Member
        Lead Farmer
          Helpful
          Up
          0
          ::

          Edit: Your script has no update feature, so add sudo apt update && sudo apt upgrade

          The script I post in #100535 is very simple and I set it to run once at 10:02 and 22:02 every day with crontab.

          First it dues a “sudo apt update” and log the number of packages that need to be upgraded, if the number is “0” then exit the script.
          If the number is more then 0, it will show a yad massage telling that a update is available and the number of packages that can be upgraded see See second image in post #99700.

          If the Install button is pressed the x-terminal-emulator will show and run “sudo apt upgrade && sleep 0.1 && yad…” it mean it will do the upgrade and show a yad massage that update in complete with ok button, when the button is pressed it will exit the script.

          • This reply was modified 2 months, 1 week ago by Lead Farmer.
          • This reply was modified 2 months, 1 week ago by Lead Farmer.
          • This reply was modified 2 months, 1 week ago by Lead Farmer.
          #100625
          Member
          RJP
            Helpful
            Up
            0
            ::

            New version from the script.

            #!/bin/bash
            yad  --text="Would you like to check and install updates?"  --title="UPDATER"
            if [ $? = 0 ];
            then
            x-terminal-emulator -T "$title_terminal" -e /bin/bash -c "sudo apt update && sudo apt upgrade && yad --center --borders=5 --width=250 --text-align=center --button=gtk-ok:1 --title='Update Complete' --buttons-layout=center"
            else exit 0
            fi
            
            • This reply was modified 2 months ago by RJP.
            #100662
            Member
            Lead Farmer
              Helpful
              Up
              0
              ::

              Another change I add to the script is not to do “sudo apt update” if the CPU is under load, I’m using uptime command TO know what is the load average in the last minute is, and if it’s less then 1 do “sudo apt update”, and if there are packages that need upgraded do “sudo apt upgrade.

              The reason I add it is because the “sudo apt update” take about 10 seconds at 50% CPU load on my PC, and it might effect other processes that I run like watching a YouTube video.

              here the script

              #!/bin/bash
              #
              # Set this bash scrip with crontab to check and install updates
              #
              export DISPLAY=:0.0
              CPULOAD=$(uptime | grep -Po '(?<=load average: )[\d\.]+')
              # Set X and Y where the massage will show on your screen
              X=1366
              Y=768
              
              # Check if the CPU is not under load
              if (( $(echo "$CPULOAD < 1" | bc -l) )); then
              	UPGRADS_NUM=$(sudo apt update | grep -P -o '^\d+')
              	# If there are packages that needed to be upgraded show message
              	if [[ $UPGRADS_NUM -gt 0 ]]; then
              		yad \
              		--borders=20 \
              		--timeout=600 \
              		--title="Update Available" \
              		--text="You can update $UPGRADS_NUM packages" \
              		--geometry=200x120+$X+$Y \
              		--button="Install":2 \
              		--button="Cancel":1 \
              		--buttons-layout=center
              		SELECT=$?
              		# Exit or upgrade depend by the button press 
              		[[ $SELECT -eq 1 ]] && exit 0
              		if [[ $SELECT -eq 2 ]]; then
              			x-terminal-emulator -T "$title_terminal" -e /bin/bash -c \
              			"sudo apt upgrade && sleep 1 && desktop-menu --write-out-global && sleep 0.1 && \
              			yad  \
              			--center \
              			--borders=5 \
              			--width=250 \
              			--text-align=center \
              			--button=gtk-ok:1 \
              			--title='Update Complete' \
              			--buttons-layout=center"
              		fi
              	fi
              fi
              exit 0

              #############
              Edit: I fixed the script, there was a problem with CPULOAD= line.

              • This reply was modified 2 months ago by Lead Farmer.
              • This reply was modified 2 months ago by Lead Farmer.
            Viewing 5 posts - 31 through 35 (of 35 total)
            • You must be logged in to reply to this topic.