You are Here:
NEW High Spec Repository is LIVE



GUI Updates script

Author (Read 24983 times)

0 Members and 1 Guest are viewing this topic.

Re: GUI Updates script
« Reply #53 on: February 21, 2015, 12:54:03 AM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 8573
    Posts
  • Reputation: 795
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 6.0 64bit

  • CPU: Intel Core i9-10850K CPU @ 3.60GHz

  • MEMORY: 32Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
Latest iteration:

- Added line 91
- Reverted to original log and first dialogue processes

Code: [Select]
#!/bin/bash
#-----------------------------------------------------------------------------------------
# Name: Linux Lite Updates
# Description: A GUI tool to easily install Updates in Linux Lite.
# Authors: Misko_2083, Jerry Bezencon
# Date: February 21st, 2015
# Website: https://www.linuxliteos.com
#-----------------------------------------------------------------------------------------

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]
then
   sudo killall -9 synaptic
else
   echo""
fi

if [ -z "$(pgrep gdebi-gtk)" ]
then
   echo ""
else
   killall -9 gdebi-gtk
fi

# Updates log variable
UPDATES=$(mktemp /tmp/updateslist.XXXXXX)

# Linux Lite default dialog icon
ic="/usr/share/icons/zenity-llcc.png"

# Get list of available updated packages then populate them to /tmp/updateslist
zenity --question --title="Linux Lite Updates" --window-icon="/usr/share/icons/zenity-llcc.png" --text="We will now fetch the Updates list.\n\nClick Yes to continue or No to abort."
   if [ "$?" -eq "0" ];then

APTUPDATE=$( stdbuf -oL /bin/bash \-c '(sudo apt-get update \-y )' 2>&1 |
stdbuf -oL sed -n -e 's/^\(.\{128\}\).*/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |     #sed 's/^\(.\{128\}\).*/\1/'  Display only the first 128 characters
zenity --progress --title="Updating package information..." --pulsate \
--width=600 --auto-close )

unset APTUPDATE

# Creates a list in /tmp/updateslist
LISTNAMES=$(apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "Name: $1 INSTALLED: $2 AVAILABLE: $3\n"}' | awk '{print NR,":\t"$0}' | tee $UPDATES)

# Check if any updates are available, if there are none, script pops up dialog box saying 'No Updates Available', removes /tmp/updateslist.XXXXXX
if [  -z "$(cat $UPDATES)"  ]; then
    zenity --info --window-icon="/usr/share/icons/zenity-llcc.png" --title="Linux Lite Updates" \
      --text="No Updates Available"
   rm $UPDATES
   exit 0
fi

# Insert text into  /tmp/updateslist.XXXXXX
sed -i -e '1 i\List of available Updates' -e '1 i\Click Update to continue or Cancel to stop the update process\n'  $UPDATES

# Erase existing available info
sudo dpkg --clear-avail

  else
       exit 0
  fi

# Call the zenity dialog to show update list
zenity --text-info --ok-label="Update" --cancel-label="Cancel" --title="Linux Lite Updates" --width=780 --height=300 --filename="$UPDATES"
      if [ "$?" -eq "0" ];then
       
      # Continue script if no halt
        INSTALL_ICON="/usr/share/icons/zenity-llcc.png"
        APPNAME="Linux Lite Updates"
       
                 # Remove tmp file
                 rm $UPDATES

    RUNUPDATES=$( stdbuf -oL /bin/bash \-c '(sudo DEBIAN_FRONTEND=noninteractive apt-get  -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade \-y )' 2>&1 | tee /var/log/llupdates.log |
       stdbuf -oL sed -n -e 's/^\(.\{128\}\).*/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |           
       zenity --progress --title="Updating..." --pulsate \
       --width=600 --auto-close )

                                if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                       
                                        zenity --error \
                                        --title="Error" --text="$APPNAME have failed."
                                        exit 0
                                fi

      # Halt updates script if user selects Cancel
       else
         rm $UPDATES
        unset UPDATES
        unset RUNUPDATES
   zenity --info --title="Updates Cancelled" --window-icon="${INSTALL_ICON}" --text="Updates Cancelled."
         exit 0
    fi

unset UPDATES
unset RUNUPDATES

PROCEED=$(zenity --question --title="$APPNAME" --window-icon=/usr/share/icons/zenity-llcc.png --text="Updates have finished installing.\n\nWould you like to view the $APPNAME log?"; echo $?)
if [ ${PROCEED} -eq 1 ]; then
   zenity --info --title="$APPNAME" --window-icon="${INSTALL_ICON}" --text="$APPNAME Complete."
   exit;
else
   zenity --text-info --ok-label="Quit" --cancel-label="Cancel" --title="Updates Log" --width=700 --height=300 --filename="/var/log/llupdates.log"
fi

exit 0
« Last Edit: February 21, 2015, 01:07:52 AM by Jerry »
 

Re: GUI Updates script
« Reply #52 on: February 20, 2015, 11:28:35 PM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 8573
    Posts
  • Reputation: 795
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 6.0 64bit

  • CPU: Intel Core i9-10850K CPU @ 3.60GHz

  • MEMORY: 32Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
A bit of a misunderstanding here :) I'll break it down:

Choose to update or not > this refers to the original first dialogue, line 32:

Code: [Select]
zenity --question --title="Linux Lite Updates" --window-icon="/usr/share/icons/zenity-llcc.png" --text="We will now fetch the Updates list.\n\nClick Yes to continue or No to abort."
This is kept because someone may have clicked on the wrong item in the Menu, or decided against updating.

updates will run > self explanatory.

have the option at the end to view the log which should reside in /var/log - the default dialogue at the end of the file:

Code: [Select]
PROCEED=$(zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="Updates have finished installing.\n\nWould you like to view the $APPNAME Updates log?"; echo $?)
if [ ${PROCEED} -eq 1 ]; then
   zenity --info --title="$APPNAME Updates" --window-icon="${INSTALL_ICON}" --text="$APPNAME Updates Complete."
   exit;
else
   zenity --text-info --ok-label="Quit" --cancel-label="Cancel" --title="Updates Log" --width=700 --height=300 --filename="/var/log/llupdates.log"
fi

So we want to retain the original first dialogue and original logging method :) If there is a bug, then the intuitive place to look is /var/log.
« Last Edit: February 20, 2015, 11:53:01 PM by Jerry »
 

Re: GUI Updates script
« Reply #51 on: February 20, 2015, 05:33:08 AM »
 

anon222

  • Muted
  • Gold Level Poster
  • *
  • 688
    Posts
  • Reputation: 192
  • Linux Lite Member

  • CPU: Dual core Pentium E5700 3GHz

  • MEMORY: 3Gb

  • VIDEO CARD: GeForce GT 430
OK how about now? First dialog is removed.
Code: [Select]
#!/bin/bash
#-----------------------------------------------------------------------------------------
# Name: Linux Lite Updates
# Description: A GUI tool to easily install Updates in Linux Lite.
# Authors: Misko_2083, Jerry Bezencon
# Date: 2015
# Website: https://www.linuxliteos.com
#-----------------------------------------------------------------------------------------

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]
then
   sudo killall -9 synaptic
else
   echo""
fi

if [ -z "$(pgrep gdebi-gtk)" ]
then
   echo ""
else
   killall -9 gdebi-gtk
fi

UPDATES=$(mktemp /tmp/updateslist.XXXXXX)
# Linux Lite default dialog icon
ic="/usr/share/icons/zenity-llcc.png"

APTUPDATE=$( stdbuf -oL /bin/bash \-c '(sudo apt-get update \-y )' 2>&1 |
stdbuf -oL sed -n -e 's/^\(.\{64\}\).*/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |     #sed 's/^\(.\{64\}\).*/\1/'  Display only the first 64 characters
zenity --progress --title="Updating package information..." --pulsate \
--width=600 --auto-close )

unset APTUPDATE

# Creates a list in /tmp/updateslist
LISTNAMES=$(apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "Name: $1 INSTALLED: $2 AVAILABLE: $3\n"}' | awk '{print NR,":\t"$0}' | tee $UPDATES)

# Check if any updates are available, if there are none, script pops up dialog box saying 'No Updates Available', removes /tmp/updateslist.XXXXXX
if [  -z "$(cat $UPDATES)"  ]; then
    zenity --info --window-icon="/usr/share/icons/zenity-llcc.png" --title="Linux Lite Updates" \
      --text="No Updates Available"
   rm $UPDATES
   exit 0
fi

# Insert text into  /tmp/updateslist.XXXXXX
sed -i -e '1 i\List of available Updates' -e '1 i\Click Update to continue or Cancel to stop the update process\n'  $UPDATES

# Erase existing available info
sudo dpkg --clear-avail


# Call the zenity dialog to show update list
zenity --text-info --ok-label="Update" --cancel-label="Cancel" --title="Linux Lite Updates" --width=780 --height=300 --filename="$UPDATES"
      if [ "$?" -eq "0" ];then
       

      # Continue script if no halt
        INSTALL_ICON="/usr/share/icons/zenity-llcc.png"
        APPNAME="Linux Lite Updates"
       
                 #remove tmp file
                 rm $UPDATES

    RUNUPDATES=$( stdbuf -oL /bin/bash \-c '(sudo DEBIAN_FRONTEND=noninteractive apt-get  -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade \-y )' 2>&1 | tee /var/log/llupdates.log |
       stdbuf -oL sed -n -e 's/^\(.\{64\}\).*/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |           
       zenity --progress --title="Updating..." --pulsate \
       --width=600 --auto-close )

                                if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                       
                                        zenity --error \
                                        --title="Error" --text="$APPNAME Updates have failed."
                                        exit 0
                                fi

      # Halt updates script if user selects Cancel
       else
         rm $UPDATES
        unset UPDATES
        unset RUNUPDATES
         exit 0
    fi

unset UPDATES
unset RUNUPDATES

PROCEED=$(zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="Updates have finished installing.\n\nWould you like to view the $APPNAME Updates log?"; echo $?)
if [ ${PROCEED} -eq 1 ]; then
   zenity --info --title="$APPNAME Updates" --window-icon="${INSTALL_ICON}" --text="$APPNAME Updates Complete."
   exit;
else
   zenity --text-info --ok-label="Save Updates Log" --cancel-label="Close" --title="Updates Log" --width=700 --height=300 --filename="/var/log/llupdates.log"
     if [ $? -ne 0 ]; then
            exit;
        else

         #Generate the save list and on the first occurance of "FALSE" change it to "TRUE"
         LL_LIST_D=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1}' /etc/passwd |sed '0,/FALSE/s/FALSE/TRUE/'`)
         
     #Add optional save location
         LL_LIST_H=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1"/Desktop"}' /etc/passwd`)
         
         save_location=$(zenity --title="System Report Save Location" --list --radiolist --text="Select save location:" --column="Select" --column="Save file location:" --width=325  --height=300 "${LL_LIST_D[@]}" "${LL_LIST_H[@]}")
                if [ $? -ne 0 ]; then
            unset LL_LIST_D
            unset   LL_LIST_H
            unset save_location
            exit 0
               else       
                      #Extract username
                      LL_USER=$(echo "$save_location" | cut -d'/' -f3)
                 
                      # Add filename to the save path
                      SAVE_PATH=$(echo $save_location| sed 's,.*,&\/var/log/llupdates.log,g')
                       
            #Checks if the file exists. If it does asks for confirmation.
            if [  ! -z "$(echo $SAVE_PATH)" ]; then
                if zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="file ${SAVE_PATH} allready exists.\nWould you like to overwite the file?"; then
                             
                                   cp /var/log/llupdates.log $save_location
                      chown $LL_USER  $SAVE_PATH    # Change the ownership to LL_USER
                   
                else
                    unset save_location
                    unset LL_LIST_D
                    unset   LL_LIST_H
                    unset SAVE_PATH
                    unset LL_USER
                    exit 1
                fi
            else                                 
                cp /var/log/llupdates.log $save_location
                chown $LL_USER  $SAVE_PATH    # Change the ownership to LL_USER
                   
            fi
                         
                       
            fi
    fi
fi

unset LL_LIST_D
unset   LL_LIST_H
unset SAVE_PATH
unset LL_USER
unset save_location

exit 0
 

Re: GUI Updates script
« Reply #50 on: February 20, 2015, 05:09:12 AM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 8573
    Posts
  • Reputation: 795
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 6.0 64bit

  • CPU: Intel Core i9-10850K CPU @ 3.60GHz

  • MEMORY: 32Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
I certainly appreciate the work thats gone into the log file changes, but I think there is now too much user interaction.
Ideally, they will:

Choose to update or not > updates will run > have the option at the end to view the log which should reside in /var/log.
 

Re: GUI Updates script
« Reply #49 on: February 20, 2015, 04:37:37 AM »
 

anon222

  • Muted
  • Gold Level Poster
  • *
  • 688
    Posts
  • Reputation: 192
  • Linux Lite Member

  • CPU: Dual core Pentium E5700 3GHz

  • MEMORY: 3Gb

  • VIDEO CARD: GeForce GT 430
Yes, but we could show only the first 64 characters of the strings. It doesn't need to be 64 you can tweak that at your end.
Code: [Select]
#!/bin/bash
#-----------------------------------------------------------------------------------------
# Name: Linux Lite Updates
# Description: A GUI tool to easily install Updates in Linux Lite.
# Authors: Misko_2083, Jerry Bezencon
# Date: 2015
# Website: https://www.linuxliteos.com
#-----------------------------------------------------------------------------------------

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]
then
   sudo killall -9 synaptic
else
   echo""
fi

if [ -z "$(pgrep gdebi-gtk)" ]
then
   echo ""
else
   killall -9 gdebi-gtk
fi

UPDATES=$(mktemp /tmp/updateslist.XXXXXX)
# Linux Lite default dialog icon
ic="/usr/share/icons/zenity-llcc.png"

# Get list of available updated packages then populate them to /tmp/updateslist
zenity --question --title="Linux Lite Updates" --window-icon="/usr/share/icons/zenity-llcc.png" --text="We will now fetch the Updates list.\n\nClick Yes to continue or No to abort."
   if [ "$?" -eq "0" ];then

APTUPDATE=$( stdbuf -oL /bin/bash \-c '(sudo apt-get update \-y )' 2>&1 |
stdbuf -oL sed -n -e 's/^\(.\{64\}\).*/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |     #sed 's/^\(.\{64\}\).*/\1/'  Display only the first 64 characters
zenity --progress --title="Updating package information..." --pulsate \
--width=600 --auto-close )

unset APTUPDATE

# Creates a list in /tmp/updateslist
LISTNAMES=$(apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "Name: $1 INSTALLED: $2 AVAILABLE: $3\n"}' | awk '{print NR,":\t"$0}' | tee $UPDATES)

# Check if any updates are available, if there are none, script pops up dialog box saying 'No Updates Available', removes /tmp/updateslist.XXXXXX
if [  -z "$(cat $UPDATES)"  ]; then
    zenity --info --window-icon="/usr/share/icons/zenity-llcc.png" --title="Linux Lite Updates" \
      --text="No Updates Available"
   rm $UPDATES
   exit 0
fi

# Insert text into  /tmp/updateslist.XXXXXX
sed -i -e '1 i\List of available Updates' -e '1 i\Click Update to continue or Cancel to stop the update process\n'  $UPDATES

# Erase existing available info
sudo dpkg --clear-avail

  else
       exit 0
  fi

# Call the zenity dialog to show update list
zenity --text-info --ok-label="Update" --cancel-label="Cancel" --title="Linux Lite Updates" --width=780 --height=300 --filename="$UPDATES"
      if [ "$?" -eq "0" ];then
       

      # Continue script if no halt
        INSTALL_ICON="/usr/share/icons/zenity-llcc.png"
        APPNAME="Linux Lite Updates"
       
                 #remove tmp file
                 rm $UPDATES

    RUNUPDATES=$( stdbuf -oL /bin/bash \-c '(sudo DEBIAN_FRONTEND=noninteractive apt-get  -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade \-y )' 2>&1 | tee /var/log/llupdates.log |
       stdbuf -oL sed -n -e 's/^\(.\{64\}\).*/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |           
       zenity --progress --title="Updating..." --pulsate \
       --width=600 --auto-close )

                                if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                       
                                        zenity --error \
                                        --title="Error" --text="$APPNAME Updates have failed."
                                        exit 0
                                fi

      # Halt updates script if user selects Cancel
       else
         rm $UPDATES
        unset UPDATES
        unset RUNUPDATES
         exit 0
    fi

unset UPDATES
unset RUNUPDATES

PROCEED=$(zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="Updates have finished installing.\n\nWould you like to view the $APPNAME Updates log?"; echo $?)
if [ ${PROCEED} -eq 1 ]; then
   zenity --info --title="$APPNAME Updates" --window-icon="${INSTALL_ICON}" --text="$APPNAME Updates Complete."
   exit;
else
   zenity --text-info --ok-label="Save Updates Log" --cancel-label="Close" --title="Updates Log" --width=700 --height=300 --filename="/var/log/llupdates.log"
     if [ $? -ne 0 ]; then
            exit;
        else

         #Generate the save list and on the first occurance of "FALSE" change it to "TRUE"
         LL_LIST_D=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1}' /etc/passwd |sed '0,/FALSE/s/FALSE/TRUE/'`)
         
     #Add optional save location
         LL_LIST_H=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1"/Desktop"}' /etc/passwd`)
         
         save_location=$(zenity --title="System Report Save Location" --list --radiolist --text="Select save location:" --column="Select" --column="Save file location:" --width=325  --height=300 "${LL_LIST_D[@]}" "${LL_LIST_H[@]}")
                if [ $? -ne 0 ]; then
            unset LL_LIST_D
            unset   LL_LIST_H
            unset save_location
            exit 0
               else       
                      #Extract username
                      LL_USER=$(echo "$save_location" | cut -d'/' -f3)
                 
                      # Add filename to the save path
                      SAVE_PATH=$(echo $save_location| sed 's,.*,&\/var/log/llupdates.log,g')
                       
            #Checks if the file exists. If it does asks for confirmation.
            if [  ! -z "$(echo $SAVE_PATH)" ]; then
                if zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="file ${SAVE_PATH} allready exists.\nWould you like to overwite the file?"; then
                             
                                   cp /var/log/llupdates.log $save_location
                      chown $LL_USER  $SAVE_PATH    # Change the ownership to LL_USER
                   
                else
                    unset save_location
                    unset LL_LIST_D
                    unset   LL_LIST_H
                    unset SAVE_PATH
                    unset LL_USER
                    exit 1
                fi
            else                                 
                cp /var/log/llupdates.log $save_location
                chown $LL_USER  $SAVE_PATH    # Change the ownership to LL_USER
                   
            fi
                         
                       
            fi
    fi
fi

unset LL_LIST_D
unset   LL_LIST_H
unset SAVE_PATH
unset LL_USER
unset save_location

exit 0
 

Re: GUI Updates script
« Reply #48 on: February 20, 2015, 04:27:29 AM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 8573
    Posts
  • Reputation: 795
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 6.0 64bit

  • CPU: Intel Core i9-10850K CPU @ 3.60GHz

  • MEMORY: 32Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
This is good :) The only thing is that the 64 character string cuts off some of the output at the beginning, example http://xxxxxx becomes tp://xxxxxx
 

Re: GUI Updates script
« Reply #47 on: February 20, 2015, 03:02:05 AM »
 

anon222

  • Muted
  • Gold Level Poster
  • *
  • 688
    Posts
  • Reputation: 192
  • Linux Lite Member

  • CPU: Dual core Pentium E5700 3GHz

  • MEMORY: 3Gb

  • VIDEO CARD: GeForce GT 430
Ah O.o , ok found it.
The list is there just used `cat /tmp/updatelist` instead of `cat $UPDATES` when checking if there are any updates.
fixed :)
Code: [Select]
#!/bin/bash
#-----------------------------------------------------------------------------------------
# Name: Linux Lite Updates
# Description: A GUI tool to easily install Updates in Linux Lite.
# Authors: Misko_2083, Jerry Bezencon
# Date: 2015
# Website: https://www.linuxliteos.com
#-----------------------------------------------------------------------------------------

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]
then
   sudo killall -9 synaptic
else
   echo""
fi

if [ -z "$(pgrep gdebi-gtk)" ]
then
   echo ""
else
   killall -9 gdebi-gtk
fi

UPDATES=$(mktemp /tmp/updateslist.XXXXXX)
# Linux Lite default dialog icon
ic="/usr/share/icons/zenity-llcc.png"

# Get list of available updated packages then populate them to /tmp/updateslist
zenity --question --title="Linux Lite Updates" --window-icon="/usr/share/icons/zenity-llcc.png" --text="We will now fetch the Updates list.\n\nClick Yes to continue or No to abort."
   if [ "$?" -eq "0" ];then

APTUPDATE=$( stdbuf -oL /bin/bash \-c '(sudo apt-get update \-y )' 2>&1 |
stdbuf -oL sed -n -e 's/^.*\(.\{64\}\)$/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |                        #' s/^.*\(.\{64\}\)$/\1/' Display only the last 64 chars, to dispay the first 64, change to 's/^\(.\{64\}\).*/\1/'
zenity --progress --title="Updating package information..." --pulsate \
--width=600 --auto-close )

unset APTUPDATE

# Creates a list in /tmp/updateslist
LISTNAMES=$(apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "Name: $1 INSTALLED: $2 AVAILABLE: $3\n"}' | awk '{print NR,":\t"$0}' | tee $UPDATES)

# Check if any updates are available, if there are none, script pops up dialog box saying 'No Updates Available', removes /tmp/updateslist.XXXXXX
if [  -z "$(cat $UPDATES)"  ]; then
    zenity --info --window-icon="/usr/share/icons/zenity-llcc.png" --title="Linux Lite Updates" \
      --text="No Updates Available"
   rm $UPDATES
   exit 0
fi

# Insert text into  /tmp/updateslist.XXXXXX
sed -i -e '1 i\List of available Updates' -e '1 i\Click Update to continue or Cancel to stop the update process\n'  $UPDATES

# Erase existing available info
sudo dpkg --clear-avail

  else
       exit 0
  fi

# Call the zenity dialog to show update list
zenity --text-info --ok-label="Update" --cancel-label="Cancel" --title="Linux Lite Updates" --width=780 --height=300 --filename="$UPDATES"
      if [ "$?" -eq "0" ];then
       

      # Continue script if no halt
        INSTALL_ICON="/usr/share/icons/zenity-llcc.png"
        APPNAME="Linux Lite Updates"
       
                 #remove tmp file
                 rm $UPDATES

    RUNUPDATES=$( stdbuf -oL /bin/bash \-c '(sudo DEBIAN_FRONTEND=noninteractive apt-get  -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade \-y )' 2>&1 | tee /var/log/llupdates.log |
       stdbuf -oL sed -n -e 's/^.*\(.\{64\}\)$/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |                 #' s/^.*\(.\{64\}\)$/\1/' Display only the last 64 chars, to dispay the first 64, change to 's/^\(.\{64\}\).*/\1/'
       zenity --progress --title="Updating..." --pulsate \
       --width=600 --auto-close )

                                if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                       
                                        zenity --error \
                                        --title="Error" --text="$APPNAME Updates have failed."
                                        exit 0
                                fi

      # Halt updates script if user selects Cancel
       else
         rm $UPDATES
        unset UPDATES
        unset RUNUPDATES
         exit 0
    fi

unset UPDATES
unset RUNUPDATES

PROCEED=$(zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="Updates have finished installing.\n\nWould you like to view the $APPNAME Updates log?"; echo $?)
if [ ${PROCEED} -eq 1 ]; then
   zenity --info --title="$APPNAME Updates" --window-icon="${INSTALL_ICON}" --text="$APPNAME Updates Complete."
   exit;
else
   zenity --text-info --ok-label="Save Updates Log" --cancel-label="Close" --title="Updates Log" --width=700 --height=300 --filename="/var/log/llupdates.log"
     if [ $? -ne 0 ]; then
            exit;
        else

         #Generate the save list and on the first occurance of "FALSE" change it to "TRUE"
         LL_LIST_D=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1}' /etc/passwd |sed '0,/FALSE/s/FALSE/TRUE/'`)
         
     #Add optional save location
         LL_LIST_H=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1"/Desktop"}' /etc/passwd`)
         
         save_location=$(zenity --title="System Report Save Location" --list --radiolist --text="Select save location:" --column="Select" --column="Save file location:" --width=325  --height=300 "${LL_LIST_D[@]}" "${LL_LIST_H[@]}")
                if [ $? -ne 0 ]; then
            unset LL_LIST_D
            unset   LL_LIST_H
            unset save_location
            exit 0
               else       
                      #Extract username
                      LL_USER=$(echo "$save_location" | cut -d'/' -f3)
                 
                      # Add filename to the save path
                      SAVE_PATH=$(echo $save_location| sed 's,.*,&\/var/log/llupdates.log,g')
                       
            #Checks if the file exists. If it does asks for confirmation.
            if [  ! -z "$(echo $SAVE_PATH)" ]; then
                if zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="file ${SAVE_PATH} allready exists.\nWould you like to overwite the file?"; then
                             
                                   cp /var/log/llupdates.log $save_location
                      chown $LL_USER  $SAVE_PATH    # Change the ownership to LL_USER
                   
                else
                    unset save_location
                    unset LL_LIST_D
                    unset   LL_LIST_H
                    unset SAVE_PATH
                    unset LL_USER
                    exit 1
                fi
            else                                 
                cp /var/log/llupdates.log $save_location
                chown $LL_USER  $SAVE_PATH    # Change the ownership to LL_USER
                   
            fi
                         
                       
            fi
    fi
fi

unset LL_LIST_D
unset   LL_LIST_H
unset SAVE_PATH
unset LL_USER
unset save_location

exit 0
« Last Edit: February 20, 2015, 03:12:39 AM by misko_2083 »
 

Re: GUI Updates script
« Reply #46 on: February 20, 2015, 01:37:32 AM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 8573
    Posts
  • Reputation: 795
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 6.0 64bit

  • CPU: Intel Core i9-10850K CPU @ 3.60GHz

  • MEMORY: 32Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
Your code in post #43 gives 'No updates available' whilst my currently working script below does:

Code: [Select]
#!/bin/bash
#-----------------------------------------------------------------------------------------
# Name: Linux Lite Updates
# Description: A GUI tool to easily install Updates in Linux Lite.
# Authors: Misko_2083, Jerry Bezencon
# Date: Nov 20th, 2014
# Website: https://www.linuxliteos.com
#-----------------------------------------------------------------------------------------

# Ensure multi-language support
export LANG=C

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]
then
   sudo killall -9 synaptic
else
   echo""
fi

if [ -z "$(pgrep gdebi-gtk)" ]
then
   echo ""
else
   killall -9 gdebi-gtk
fi

# Linux Lite default dialog icon
ic="/usr/share/icons/zenity-llcc.png"

# Get list of available updated packages then populate them to /tmp/updateslist
zenity --question --title="Linux Lite Updates" --window-icon="/usr/share/icons/zenity-llcc.png" --text="We will now fetch the Updates list.\n\nClick Yes to continue or No to abort."
   if [ "$?" -eq "0" ];then

x=$( stdbuf -oL /bin/bash \-c '(sudo apt-get update \-y )' 2>&1 |
stdbuf -oL sed -n -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p'|
zenity --progress --title="Updating package information..." --pulsate \
--width=600 --auto-close )

# Creates a list in /tmp/updateslist
LISTNAMES=$(apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "Name: $1 INSTALLED: $2 AVAILABLE: $3\n"}' | awk '{print NR,":\t"$0}' | tee /tmp/updateslist)

# Check if any updates are available, if there are none, script pops up dialog box saying 'No Updates Available', removes /tmp/updateslist
if [  -z "$(cat /tmp/updateslist)"  ]; then
    zenity --info --window-icon="/usr/share/icons/zenity-llcc.png" --title="Linux Lite Updates" \
      --text="No Updates Available"
   rm /tmp/updateslist
   exit 0
fi

# Insert text into  /tmp/updateslist
sed -i -e '1 i\List of available Updates' -e '1 i\Click Update to continue or Cancel to stop the update process\n'  /tmp/updateslist

# Erase existing available info
sudo dpkg --clear-avail

  else
       exit 0
  fi

# Call the zenity dialog to show update list
zenity --text-info --ok-label="Update" --cancel-label="Cancel" --title="Linux Lite Updates" --width=780 --height=300 --filename="/tmp/updateslist"
      if [ "$?" -eq "0" ];then
       

      # Continue script if no halt
        INSTALL_ICON="/usr/share/icons/zenity-llcc.png"
        APPNAME="Linux Lite"
       
                 #remove tmp file
                 rm /tmp/updateslist

       x=$( stdbuf -oL /bin/bash \-c '(sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade \-y )' 2>&1 | tee /var/log/llupdates.log |
       stdbuf -oL sed -n -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p'|
       zenity --progress --title="Updating..." --pulsate \
       --width=600 --auto-close )

                                if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                       
                                        zenity --error \
                                        --title="Error" --text="$APPNAME Updates have failed."
                                        exit 0
                                fi

   # Halt updates script if user selects Cancel
    else
         rm /tmp/updateslist
             exit 0
   fi

PROCEED=$(zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="Updates have finished installing.\n\nWould you like to view the $APPNAME Updates log?"; echo $?)
if [ ${PROCEED} -eq 1 ]; then
   zenity --info --title="$APPNAME Updates" --window-icon="${INSTALL_ICON}" --text="$APPNAME Updates Complete."
   exit;
else
   zenity --text-info --ok-label="Quit" --cancel-label="Cancel" --title="Updates Log" --width=700 --height=300 --filename="/var/log/llupdates.log"
fi

exit 0
 

Re: GUI Updates script
« Reply #45 on: February 19, 2015, 10:44:00 PM »
 

anon222

  • Muted
  • Gold Level Poster
  • *
  • 688
    Posts
  • Reputation: 192
  • Linux Lite Member

  • CPU: Dual core Pentium E5700 3GHz

  • MEMORY: 3Gb

  • VIDEO CARD: GeForce GT 430
@Jerry:
If the next script handles *.conf files in a way it doesn't install the package maintainer's versions on a fresh install, the previous script will probably work in the same way.
Code: [Select]
#!/bin/bash
# Authors: Misko2083, Jerry Bezencon

bold=`tput bold`
normal=`tput sgr0`

echo "${bold}**********************"
echo "Linux Lite 2.0 Updates"
echo "**********************${normal}"
echo ""
echo "Linux Lite will now search for updates for your computer."
echo "Once installed, your computer will be up to date."
echo "Simply follow the onscreen instructions."
echo ""
echo "Please enter your password to continue..."
if [ "$(pidof synaptic)" ]
then
    sudo killall -9 synaptic
else
    echo""
fi
if [ -z "$(pgrep gdebi-gtk)" ]
then
    echo ""
else
    killall -9 gdebi-gtk
fi
sudo apt-get update && sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
echo ""
echo "Updates complete."
echo "This window will now close."
sleep 5
#exit
 

Re: GUI Updates script
« Reply #44 on: February 19, 2015, 10:17:01 PM »
 

anon222

  • Muted
  • Gold Level Poster
  • *
  • 688
    Posts
  • Reputation: 192
  • Linux Lite Member

  • CPU: Dual core Pentium E5700 3GHz

  • MEMORY: 3Gb

  • VIDEO CARD: GeForce GT 430
Update
Changes
Display only the last 64 chars when the output is parsed to the progress dialogs (this way the progress bar width will not increase)
Variables are now unset before exit
Package list is now preset to a variable (safer)
Ownership of the report now changes to the user
added apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
Code: [Select]
#!/bin/bash
#-----------------------------------------------------------------------------------------
# Name: Linux Lite Updates
# Description: A GUI tool to easily install Updates in Linux Lite.
# Authors: Misko_2083, Jerry Bezencon
# Date: 2015
# Website: https://www.linuxliteos.com
#-----------------------------------------------------------------------------------------

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]
then
   sudo killall -9 synaptic
else
   echo""
fi

if [ -z "$(pgrep gdebi-gtk)" ]
then
   echo ""
else
   killall -9 gdebi-gtk
fi

UPDATES=$(mktemp /tmp/updateslist.XXXXXX)
# Linux Lite default dialog icon
ic="/usr/share/icons/zenity-llcc.png"

# Get list of available updated packages then populate them to /tmp/updateslist
zenity --question --title="Linux Lite Updates" --window-icon="/usr/share/icons/zenity-llcc.png" --text="We will now fetch the Updates list.\n\nClick Yes to continue or No to abort."
   if [ "$?" -eq "0" ];then

APTUPDATE=$( stdbuf -oL /bin/bash \-c '(sudo apt-get update \-y )' 2>&1 |
stdbuf -oL sed -n -e 's/^.*\(.\{64\}\)$/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |                        #' s/^.*\(.\{64\}\)$/\1/' Display only the last 64 chars
zenity --progress --title="Updating package information..." --pulsate \
--width=600 --auto-close )

unset APTUPDATE

# Creates a list in /tmp/updateslist
LISTNAMES=$(apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "Name: $1 INSTALLED: $2 AVAILABLE: $3\n"}' | awk '{print NR,":\t"$0}' | tee $UPDATES)

# Check if any updates are available, if there are none, script pops up dialog box saying 'No Updates Available', removes /tmp/updateslist
if [  -z "$(cat /tmp/updateslist)"  ]; then
    zenity --info --window-icon="/usr/share/icons/zenity-llcc.png" --title="Linux Lite Updates" \
      --text="No Updates Available"
   rm $UPDATES
   exit 0
fi

# Insert text into  /tmp/updateslist
sed -i -e '1 i\List of available Updates' -e '1 i\Click Update to continue or Cancel to stop the update process\n'  $UPDATES

# Erase existing available info
sudo dpkg --clear-avail

  else
       exit 0
  fi

# Call the zenity dialog to show update list
zenity --text-info --ok-label="Update" --cancel-label="Cancel" --title="Linux Lite Updates" --width=780 --height=300 --filename="$UPDATES"
      if [ "$?" -eq "0" ];then
       

      # Continue script if no halt
        INSTALL_ICON="/usr/share/icons/zenity-llcc.png"
        APPNAME="Linux Lite Updates"
       
                 #remove tmp file
                 rm $UPDATES

    RUNUPDATES=$( stdbuf -oL /bin/bash \-c '(sudo DEBIAN_FRONTEND=noninteractive apt-get  -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade \-y )' 2>&1 | tee /var/log/llupdates.log |
       stdbuf -oL sed -n -e 's/^.*\(.\{64\}\)$/\1/' -e '/\[*$/ s/^/# /p' -e '/\*$/ s/^/# /p' |                     #' s/^.*\(.\{64\}\)$/\1/' Display only the last 64 chars
       zenity --progress --title="Updating..." --pulsate \
       --width=600 --auto-close )

                                if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                       
                                        zenity --error \
                                        --title="Error" --text="$APPNAME Updates have failed."
                                        exit 0
                                fi

      # Halt updates script if user selects Cancel
       else
         rm $UPDATES
        unset UPDATES
        unset RUNUPDATES
         exit 0
    fi

unset UPDATES
unset RUNUPDATES

PROCEED=$(zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="Updates have finished installing.\n\nWould you like to view the $APPNAME Updates log?"; echo $?)
if [ ${PROCEED} -eq 1 ]; then
   zenity --info --title="$APPNAME Updates" --window-icon="${INSTALL_ICON}" --text="$APPNAME Updates Complete."
   exit;
else
   zenity --text-info --ok-label="Save Updates Log" --cancel-label="Close" --title="Updates Log" --width=700 --height=300 --filename="/var/log/llupdates.log"
     if [ $? -ne 0 ]; then
            exit;
        else

         #Generate the save list and on the first occurance of "FALSE" change it to "TRUE"
         LL_LIST_D=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1}' /etc/passwd |sed '0,/FALSE/s/FALSE/TRUE/'`)
         
     #Add optional save location
         LL_LIST_H=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1"/Desktop"}' /etc/passwd`)
         
         save_location=$(zenity --title="System Report Save Location" --list --radiolist --text="Select save location:" --column="Select" --column="Save file location:" --width=325  --height=300 "${LL_LIST_D[@]}" "${LL_LIST_H[@]}")
                if [ $? -ne 0 ]; then
            unset LL_LIST_D
            unset   LL_LIST_H
            unset save_location
            exit 0
               else       
                      #Extract username
                      LL_USER=$(echo "$save_location" | cut -d'/' -f3)
                 
                      # Add filename to the save path
                      SAVE_PATH=$(echo $save_location| sed 's,.*,&\/var/log/llupdates.log,g')
                       
            #Checks if the file exists. If it does asks for confirmation.
            if [  ! -z "$(echo $SAVE_PATH)" ]; then
                if zenity --question --title="$APPNAME Updates" --window-icon=/usr/share/icons/zenity-llcc.png --text="file ${SAVE_PATH} allready exists.\nWould you like to overwite the file?"; then
                             
                                   cp /var/log/llupdates.log $save_location
                      chown $LL_USER  $SAVE_PATH    # Change the ownership to LL_USER
                   
                else
                    unset save_location
                    unset LL_LIST_D
                    unset   LL_LIST_H
                    unset SAVE_PATH
                    unset LL_USER
                    exit 1
                fi
            else                                 
                cp /var/log/llupdates.log $save_location
                chown $LL_USER  $SAVE_PATH    # Change the ownership to LL_USER
                   
            fi
                         
                       
            fi
    fi
fi

unset LL_LIST_D
unset   LL_LIST_H
unset SAVE_PATH
unset LL_USER
unset save_location

exit 0
« Last Edit: February 19, 2015, 10:24:12 PM by misko_2083 »
 

Re: GUI Updates script
« Reply #43 on: December 06, 2014, 08:03:00 AM »
 

Wirezfree

  • PayPal Supporter
  • Platinum Level Poster
  • *****
  • 1484
    Posts
  • Reputation: 405
  • Linux Lite "Advocate"

  • Linux Lite: 2.8 64bit

  • CPU: i7-4790S

  • MEMORY: 16Gb

  • VIDEO CARD: Intel HD4600 (Integrated)
Code: [Select]
The latest will be whatever is the last full posting of the code (#33) in this case.
O.K,
Will give it a try later... Dave
Upgrades WIP 2.6 to 2.8 - (6 X 2.6 to 2.8 completed on: 20/02/16 All O.K )
Linux Lite 3.0 Humming on a ASRock N3070 Mobo ~ btrfs RAID 10 Install on 4 Disks :)

Computers Early days:
ZX Spectrum(1982) , HP-150 MS-DOS(1983) , Amstrad CPC464(1984) ,  BBC Micro B+64(1985) , My First PC HP-Vectra(1987)
 

Re: GUI Updates script
« Reply #42 on: December 06, 2014, 07:28:41 AM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 8573
    Posts
  • Reputation: 795
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 6.0 64bit

  • CPU: Intel Core i9-10850K CPU @ 3.60GHz

  • MEMORY: 32Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
The latest will be whatever is the last full posting of the code (#33) in this case.
 

Re: GUI Updates script
« Reply #41 on: December 06, 2014, 07:23:35 AM »
 

Wirezfree

  • PayPal Supporter
  • Platinum Level Poster
  • *****
  • 1484
    Posts
  • Reputation: 405
  • Linux Lite "Advocate"

  • Linux Lite: 2.8 64bit

  • CPU: i7-4790S

  • MEMORY: 16Gb

  • VIDEO CARD: Intel HD4600 (Integrated)
Code: [Select]
Quote from: Wirezfree on 02 December 2014, 05:18:52
Hi Jerry, misko and sysdrum,

I have been following your threads on the GUI Updates & System Reporting Scripts with interest.
I don't know if it's possible.??
Once they are defined "stable", would it be possible to add them into the "How To's..."
How to add:
Update GUI
System Reporting

It would be great for the folks who are either sticking on LL2.0 or not quite ready to make the move.

Just a thought...

Dave

We can certainly do that :) See the first post of this thread for the Updates instructions.

Hi Jerry,

Thanks... O.K on instructions
The actual script went through a number of updates/iterations..
Is the script in 1st post also the latest.?

Thanks... Dave
Upgrades WIP 2.6 to 2.8 - (6 X 2.6 to 2.8 completed on: 20/02/16 All O.K )
Linux Lite 3.0 Humming on a ASRock N3070 Mobo ~ btrfs RAID 10 Install on 4 Disks :)

Computers Early days:
ZX Spectrum(1982) , HP-150 MS-DOS(1983) , Amstrad CPC464(1984) ,  BBC Micro B+64(1985) , My First PC HP-Vectra(1987)
 

Re: GUI Updates script
« Reply #40 on: December 06, 2014, 04:23:56 AM »
 

Jerry

  • Linux Lite Creator
  • Administrator
  • Platinum Level Poster
  • *****
  • 8573
    Posts
  • Reputation: 795
  • Linux Lite Member
    • Linux Lite OS

  • Linux Lite: 6.0 64bit

  • CPU: Intel Core i9-10850K CPU @ 3.60GHz

  • MEMORY: 32Gb

  • VIDEO CARD: nVidia GeForce GTX 1650

  • Kernel: 5.x
Hi Jerry, misko and sysdrum,

I have been following your threads on the GUI Updates & System Reporting Scripts with interest.
I don't know if it's possible.??
Once they are defined "stable", would it be possible to add them into the "How To's..."
How to add:
Update GUI
System Reporting

It would be great for the folks who are either sticking on LL2.0 or not quite ready to make the move.

Just a thought...

Dave

We can certainly do that :) See the first post of this thread for the Updates instructions.
« Last Edit: December 06, 2014, 04:26:32 AM by Jerry »
 

Re: GUI Updates script
« Reply #39 on: December 05, 2014, 09:48:48 PM »
 

altman

  • Gold Level Poster
  • *******
  • 740
    Posts
  • Reputation: 43
  • Linux Lite Member
Hey cool , Saved some space just doing L Cleaner .
HP DV7 i7 2670QM 500.1GB 8GB Ram Dual-Boot LL2.4 Beta / Extix 15.1.1 64-bit 
Dell Inspiron 1720 CrunchBang 11

Duckduckgo ( for now )
 

 

-->
X Close Ad

NEW High Spec Repository is LIVE