SHARE
TWEET

yad-updater Version 4

a guest Feb 14th, 2020 67 in 23 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. touch ~/.loggy
  3. log="/tmp/$(date +%s)"
  4.  
  5. ### This 2 lines of code check if there's internet connectivity
  6. # adapted from https://unix.stackexchange.com/questions/190513/shell-scripting-proper-way-to-check-for-internet-connectivity
  7. if nc -zw1 google.com 443; then
  8.   echo "Internet connection detected"
  9.  
  10.  
  11. ### Check if user is Root, if not, pop up window asking for password, to run updater. If Canceled, exits.
  12. # adapted from  https://stackoverflow.com/questions/42875809/checking-sudo-in-bash-script-with-if-statements
  13. if [[ "$EUID" = 0 ]]; then
  14.     echo "already root"
  15. else
  16.     gksudo "antiX updater"
  17.     if sudo true; then
  18.         echo "You are Root or running the script in sudo mode"
  19.     else
  20.         echo "You entered the wrong password or you canceled"
  21.         exit 1
  22.     fi
  23. fi
  24.  
  25. env LANGUAGE=en sudo apt update 2> "${log}" |
  26. while read -r line; do echo "# ${line}"; echo " ${line}" > ~/.loggy ; done |
  27.     yad --progress --pulsate --center --no-buttons --auto-close --progress-text=' Waiting for a Network connection...' --width=700 --height=100 --title="antiX - Updater"
  28. string=$(cat ~/.loggy)
  29.  for reqsubstr in 'up to date';do
  30.   if [ -z "${string##*$reqsubstr*}" ] ;then
  31.       yad --center --width=250 --text-align=center --text="\n  $string  " --title='antiX - Update' --button="OK":1 ; exit 0
  32.     else      
  33.         x-terminal-emulator -T " antiX - Updater" -e /bin/bash -c "sudo apt dist-upgrade && sleep 0.1 && yad --center --width=250 --text-align=center  --text='\n Finished  ' --button='OK':1 --title='antiX - Updater'"
  34.    fi
  35.     done
  36.  
  37. ### This 2 lines of code  end the part of the script that checks for internet connectivity
  38.   else  yad --center --width=250 --text-align=center  --text='\n No Internet connection detected!  ' --title='antiX - Updater' --button='OK':1
  39.  
  40. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top