Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
a handy autoupdate script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
LucaMartinetti
n00b
n00b


Joined: 23 Jan 2003
Posts: 44
Location: Rome [IT]

PostPosted: Tue Apr 15, 2003 2:00 pm    Post subject: a handy autoupdate script Reply with quote

comments questions and suggestions are welcomed :D
Code:
#!/bin/sh
#
# Update script for Gentoo written
# by Stian B. Barmen (stian@barmen.nu)
# edited by Luca Martinetti (lucamartinetti@phatsoft.net)

# Portage's color scheme is not perferred in log files and mails.
export NOCOLOR="true"

log=/var/log/update.log
emerge_log=/var/log/update_emerge.log
custom_tree=/root//
lock=/tmp/update.lock
nice=10

#run one instance only
if [ ! -e $lock ]; then
   
   #Create lock file
   touch $lock
   
   echo >> "$log"
   echo "`date` == Updating `hostname` =="  >> "$log" 2>&1
   echo "`date` == Syncing portage =="  >> "$log" 2>&1
   nice -n $nice emerge sync &> /dev/null
   
   # add custom ebuild
   echo "`date` == Adding custom ebuilds to portage tree =="  >> "$log" 2>&1
   cp -r $custom_tree/* /usr/portage
   
   echo "`date` == Calculating updates =="   >> "$log" 2>&1
   update=`nice -n $nice emerge -up --deep world |grep ebuild`
   
   # If we have updates move to install, if not move to check
   # config files.
   if [ "$update" == '' ] ; then
      echo "`date` == No new updates available =="   >> "$log" 2>&1
   else
      echo  >> "$log" 2>&1
      echo "$update"  >> "$log" 2>&1
      echo  >> "$log" 2>&1
      echo "`date` == Updating =="  >> "$log" 2>&1
      # update the planet!
      nice -n $nice emerge -u --deep world &> "$emerge_log"
      # check for uninstalled updates
      update=`nice -n $nice emerge -up --deep world |grep ebuild`
         if [ "$update" == '' ]
         then
            echo "`date` == All updates installed sucessfully =="   >> "$log" 2>&1
         else
         echo "`date` == Updates still not Installed =="  >> "$log" 2>&1
         echo $update  >> "$log" 2>&1
         echo  >> "$log" 2>&1
         
         #echo to console -------------------------------
          echo "`date` == Updates still not Installed =="
         echo $update 2>&1
         #-----------------------------------------------
         fi
   fi

   # Any config files for etc-update to update?
   config_files=`nice -n $nice find /etc -iname '._cfg*'`

   if [ "$config_files" == '' ]
   then
   echo "`date` == All config files updated =="  >> "$log" 2>&1
   else
   echo "`date` == Config files needs updating: =="  >> "$log" 2>&1
   echo $config_files  >> "$log" 2>&1
   
   #echo to console ------------------------------------------------
   echo "`date` == Config files needs updating: =="
   echo $config_files 2>&1
   #----------------------------------------------------------------
   
   echo "`date` == Use etc-update to update the config now! =="  >> "$log" 2>&1
   fi
   
   #Starting custom scripts
   nice -n $nice /root/scripts/update_mldonkey.sh  >> "$log" 2>&1
      
   # Remove lock file
   rm $lock
   
   echo "`date` == Gentoo update complete  =="  >> "$log" 2>&1
   
else
   echo "`date` == Already  running.. Delete" $lock "to force =="  >> "$log" 2>&1
fi

_________________
http://www.phatsoft.net
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9527
Location: beyond the rim

PostPosted: Tue Apr 15, 2003 3:33 pm    Post subject: Re: a handy autoupdate script Reply with quote

LucaMartinetti wrote:

Code:
# add custom ebuild
   echo "`date` == Adding custom ebuilds to portage tree =="  >> "$log" 2>&1
   cp -r $custom_tree/* /usr/portage


Why not use PORTDIR_OVERLAY ? Just a suggestion ...
Back to top
View user's profile Send private message
LucaMartinetti
n00b
n00b


Joined: 23 Jan 2003
Posts: 44
Location: Rome [IT]

PostPosted: Wed Apr 16, 2003 12:32 pm    Post subject: Re: a handy autoupdate script Reply with quote

Genone wrote:
Why not use PORTDIR_OVERLAY ? Just a suggestion ...


I use to modify standard ebuilds (mainly for cvs live-update) and I think this i a simplier way..
_________________
http://www.phatsoft.net
Back to top
View user's profile Send private message
snkmoorthy
Guru
Guru


Joined: 19 Nov 2002
Posts: 376

PostPosted: Thu Apr 17, 2003 12:04 am    Post subject: Reply with quote

hello LucaMartinetti,

Can you confirm the absolute useful of this script. I was thinking in terms of

1. Add commands to check for security updates, then run the script immediately only for the security updates.

2. Add commands for normal updates, for instance, run it as a cron job every weekend

If this can be extended somewhat with more features, this is a good candidate for an ebuild.
Back to top
View user's profile Send private message
LucaMartinetti
n00b
n00b


Joined: 23 Jan 2003
Posts: 44
Location: Rome [IT]

PostPosted: Thu Apr 17, 2003 10:09 am    Post subject: Reply with quote

Thank you for your comments.. but I didn't understand something :?
snkmoorthy wrote:
1. Add commands to check for security updates, then run the script immediately only for the security updates.

Which kind of commands should I add?

snkmoorthy wrote:
2. Add commands for normal updates, for instance, run it as a cron job every weekend.


I'm already using this via cron (my is linked in /etc/cron.daily/ and the output is mailed to me only when needed)
_________________
http://www.phatsoft.net
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum