View previous topic :: View next topic |
Author |
Message |
LucaMartinetti n00b
Joined: 23 Jan 2003 Posts: 44 Location: Rome [IT]
|
Posted: Tue Apr 15, 2003 2:00 pm Post subject: a handy autoupdate script |
|
|
comments questions and suggestions are welcomed
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 |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9527 Location: beyond the rim
|
Posted: Tue Apr 15, 2003 3:33 pm Post subject: Re: a handy autoupdate script |
|
|
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 |
|
|
LucaMartinetti n00b
Joined: 23 Jan 2003 Posts: 44 Location: Rome [IT]
|
Posted: Wed Apr 16, 2003 12:32 pm Post subject: Re: a handy autoupdate script |
|
|
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 |
|
|
snkmoorthy Guru
Joined: 19 Nov 2002 Posts: 376
|
Posted: Thu Apr 17, 2003 12:04 am Post subject: |
|
|
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 |
|
|
LucaMartinetti n00b
Joined: 23 Jan 2003 Posts: 44 Location: Rome [IT]
|
Posted: Thu Apr 17, 2003 10:09 am Post subject: |
|
|
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 |
|
|
|