User Tools

Site Tools


update

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
update [2023/05/09 21:04] – created steveupdate [2025/02/04 16:06] (current) steve
Line 3: Line 3:
 <code bash Update> <code bash Update>
 #!/bin/bash #!/bin/bash
-+/usr/local/bin/Update 
-# This allows updating software by a single common command on all my machines +# This allows updating software by a single common command on all my machines. 
 + 
 Logs=~/.Logs/$(date +"%Y/%m/%d") Logs=~/.Logs/$(date +"%Y/%m/%d")
 mkdir -p ${Logs} mkdir -p ${Logs}
-LogFile=${Logs}/$(hostname)-$(date +"%T.txt"+LogFile=${Logs}/$(hostname -s)-$(date +"%T.txt"
 + 
 ############################################################################# #############################################################################
 ### SRJ 2015-03-27   This script allows a user to update the local        ### ### SRJ 2015-03-27   This script allows a user to update the local        ###
 ### machine without further credentials, it requires that a file be       ### ### machine without further credentials, it requires that a file be       ###
-### created in /etc/sudoers.d/update with the lines below;                ### +### created in /etc/sudoers.d/Update with the lines below;                ### 
-###   ## Installation and management of software                          ### +###                                                                       ### 
-###   Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date,                ### +### ## Installation and management of software                            ### 
-###   /usr/bin/yum, /usr/bin/rkhunter, /usr/bin/needs-restarting          ### +### Cmnd_Alias SOFTWARE_UPDATE = /bin/rpm, /usr/bin/up2date,           ### 
-###   %wheel ALL = NOPASSWD: SOFTWARE                                     ### +###  /usr/bin/dnf, /usr/bin/rkhunter, /usr/bin/needs-restarting, \        ### 
-###      -or this, as appropriate-                                        ### +###  /usr/bin/etckeeper, /usr/bin/tig                                     ### 
-###   Cmnd_Alias SOFTWARE_UPDATE = /usr/local/bin/apt, /usr/bin/apt-get   ### +### %wheel ALL = NOPASSWD: SOFTWARE_UPDATE                                ### 
-###   %sudo ALL = NOPASSWD: SOFTWARE_UPDATE                               ### +###                                                                       ### 
-### This allows all users in the 'wheel' group to update the server     ###+###     #  -or this, as appropriate-                                      ### 
 +###                                                                       ### 
 +### Cmnd_Alias SOFTWARE_UPDATE = /usr/local/bin/apt, /usr/bin/apt-get, \  ### 
 +###     /usr/bin/tig                                                      ### 
 +### %sudo ALL = NOPASSWD: SOFTWARE_UPDATE                                 ### 
 +###                                                                       ### 
 +### This allows all users in the 'wheel' or 'sudo' group to run updates ###
 ############################################################################# #############################################################################
 + 
 source /etc/os-release source /etc/os-release
 + 
 case ${PRETTY_NAME} in case ${PRETTY_NAME} in
         "NethServer 7.9.2009")         "NethServer 7.9.2009")
                 System="RH"                 System="RH"
                 ;;                 ;;
- +  
-        "Linux Mint 21")+        "Linux Mint 21.3"|"Linux Mint 22"|"Linux Mint 22.1")
                 System="Deb"                 System="Deb"
                 ;;                 ;;
 +
 + "Debian GNU/Linux 12 (bookworm)")
 + System="Deb"
 + ;;
 +
 + "Rocky Linux 8.10 (Green Obsidian)"|"Rocky Linux 9.4 (Blue Onyx)")
 + System="NewRH"
 + ;;
  
-        *)+ *)
                 System="Unknown"                 System="Unknown"
                 echo "This system is unknown, please update this script and add a check"                 echo "This system is unknown, please update this script and add a check"
-                echo "for the pattern ${PRETTY_NAME} to ease updating.+                echo "for the pattern;" 
-                echo ""+                echo "${PRETTY_NAME}" 
 +                echo "Then update https://wiki.cyli.org/doku.php?id=update"
                 exit 127                 exit 127
                 ;;                 ;;
         esac         esac
 + 
 if [[ ${System} == "Deb" ]]; then if [[ ${System} == "Deb" ]]; then
-        sudo apt update | tee -a ${LogFile} +    echo "Updating ${PRETTY_NAME}" | tee -a ${LogFile}     
-        sudo apt upgrade -y | tee -a ${LogFile} +        sudo apt-get update | tee -a ${LogFile} 
-        sudo apt autoremove -y | tee -a ${LogFile}+        sudo apt-get upgrade -y | tee -a ${LogFile} 
 +        sudo apt-get autoremove -y | tee -a ${LogFile}
         if [ -f /var/run/reboot-required ] ; then         if [ -f /var/run/reboot-required ] ; then
                 echo 'This system needs to be rebooted!' | tee -a ${LogFile}                 echo 'This system needs to be rebooted!' | tee -a ${LogFile}
                 else echo "This system doesn't need rebooting." | tee -a ${LogFile}                 else echo "This system doesn't need rebooting." | tee -a ${LogFile}
                 fi                 fi
 + 
    elif [[ ${System} == "RH" ]]; then    elif [[ ${System} == "RH" ]]; then
 +    echo "Updating ${PRETTY_NAME}" | tee -a ${LogFile}    
         sudo /usr/bin/yum -y update | tee -a ${LogFile}         sudo /usr/bin/yum -y update | tee -a ${LogFile}
-        sudo /usr/bin/rkhunter --propupd | tee -a ${LogFile} +        sudo /usr/bin/yum -autoremove | tee -a ${LogFile}
-        sudo /usr/bin/yum autoremove | tee -a ${LogFile}+
         Something=''         Something=''
         Something=$(sudo /usr/bin/needs-restarting)         Something=$(sudo /usr/bin/needs-restarting)
Line 63: Line 79:
                 else echo 'No restart is required.' | tee -a ${LogFile}                 else echo 'No restart is required.' | tee -a ${LogFile}
                 fi                 fi
 +
 +   elif [[ ${System} == "NewRH" ]]; then
 +    echo "Updating ${PRETTY_NAME}" | tee -a ${LogFile}    
 +        sudo /usr/bin/dnf -y update | tee -a ${LogFile}
 +        sudo /usr/bin/dnf -y autoremove | tee -a ${LogFile}
 +        Something=''
 +        Something=$(sudo /usr/bin/needs-restarting)
 +        if [[ ! -z $Something ]]; then
 +                echo 'This machine needs to be restarted!' | tee -a ${LogFile}
 +                else echo 'No restart is required.' | tee -a ${LogFile}
 +                fi
 +
 +
 fi fi
 </code> </code>
update.1683666294.txt.gz · Last modified: by steve