Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
system update script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  

what do you think about automated updates?
already doing it
17%
 17%  [ 10 ]
i am only getting informed about new updates automated
26%
 26%  [ 15 ]
never thought about it
56%
 56%  [ 32 ]
Total Votes : 57

Author Message
fwerner
n00b
n00b


Joined: 27 Mar 2003
Posts: 46
Location: Germany / Freiburg

PostPosted: Sat May 22, 2004 7:29 pm    Post subject: system update script Reply with quote

i wrote a small bash-script which i use for daily updates via cron.

here it is:

Code:

#!/bin/bash


source /sbin/functions.sh

if [ "${EUID}" -ne 0 ]
then
        eerror "$0: must be root."
        exit 1
fi

echo SysUpdate V 1.0
echo Updating a Gentoo System
echo

function hasError() {
        logger -t SysUpdate "FAILED"
        exit
}


ebegin cleaning logs
        logger -t SysUpdate "cleaning logs"

        echo "Updated Packages from: " > /var/log/sysupdate.daily
        date >> /var/log/sysupdate.daily
        date > /var/log/sysupdate.detail
eend $? || hasError

ebegin syncing portage tree
        logger -t SysUpdate "syncing portage tree"
        emerge sync >> /var/log/sysupdate.detail 2>/var/log/sysupdate.detail &> /var/log/sysupdate.detail
eend $? || hasError

ebegin updating system
        logger -t SysUpdate "updating system"
        emerge world -uDpv |grep ebuild >> /var/log/sysupdate.daily
        emerge world -uDv >> /var/log/sysupdate.detail 2> /var/log/sysupdate.detail &> /var/log/sysupdate.detail
        cat /var/log/sysupdate.daily >> /var/log/sysupdate
eend $? || hasError

ebegin cleaning outdated dependencies
        logger -t SysUpdate "cleaning outdated dependencies"
        emerge depclean -v  >> /var/log/sysupdate.detail 2> /var/log/sysupdate.detail &> /var/log/sysupdate.detail
eend $? || hasError

ebegin prelinking
        logger -t SysUpdate "prelinking"
        nice -n 5 /usr/sbin/prelink -afmRv  >> /var/log/sysupdate.detail 2> /var/log/sysupdate.detail &> /var/log/sysupdate.detail
eend $? || hasError

ebegin list updated packages
        cat /var/log/sysupdate.daily
eend $? || hasError


suggestions are welcome!

its the first bash-script i write...so please don't hurt me :-)

at work i am a win-only programmer and at home a linux only user....a little bit funny :-)

f.

btw: it's a x86 system with prelinking enabled.
without prelinking you have to kick out the prelining block....

the script generates three log-files:

/var/log/sysupdate.daily
contains all updated packages from this run

/var/log/sysupdate.detail
contains the hole output of this run

/var/log/sysupdate
contains a update list from all runs

you can use this second script (if you have aterm installed) to start the script as a user in a xsession (it will open three aterms showing the first two log files and the actual update process)

attention: please have a look at the paths!

:

Code:

#!/bin/bash

aterm -title "Updated Packages" -bg black -fg grey +ls -transparent -tinting darkblue -e tail -f /var/log/sysupdate.daily &
aterm -title "Update Process" -bg black -fg grey +ls -transparent -tinting darkblue -e tail -f /var/log/sysupdate.detail &

aterm -title "System Update in Progress" -bg black -fg white +ls -transparent -tinting darkred -e su -c /root/scripts/sysupdate



Last edited by fwerner on Sat May 22, 2004 8:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
Keffin
Apprentice
Apprentice


Joined: 14 Feb 2004
Posts: 202
Location: England

PostPosted: Sat May 22, 2004 8:14 pm    Post subject: Reply with quote

Well I said I'm updating automatically, I just made a simple script that syncs and updates automagically, then goes through depclean/revdep-rebuild asking if I want to continue at each stage, then cleans out the directories that portage dumps stuff in. I still run it manually though, usually once every day or 2 when I get bored.

I made a script to compile a new kernel too, which does everything automatically except the config. I can never remember all the steps myself ;).
_________________
Always cut the deck if it ups your odds.
Back to top
View user's profile Send private message
JemandAnders
n00b
n00b


Joined: 05 Nov 2003
Posts: 2

PostPosted: Sat May 22, 2004 8:19 pm    Post subject: Reply with quote

why don't you use genkernel? its a nice script and it is merging your old config in your new kernel automatical.

using it since i switched to 2.6

f.
Back to top
View user's profile Send private message
Keffin
Apprentice
Apprentice


Joined: 14 Feb 2004
Posts: 202
Location: England

PostPosted: Sat May 22, 2004 9:13 pm    Post subject: Reply with quote

Well, my reasons were that I was just learning how to write bash scripts so I needed a couple of things to do, I am also using Vector Linux so it comes in handy for that, and I wasn't fully aware of genkernels capabilities.

I guess I should read up on genkernel when I get a chance, I wouldn't even consider putting my script in portage if I were in charge, so genkernel must be much better. :lol:
_________________
Always cut the deck if it ups your odds.
Back to top
View user's profile Send private message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214

PostPosted: Sat May 22, 2004 9:30 pm    Post subject: Reply with quote

While it's a nice idea and all, it is my opinion that sync'ing once a day is abuse of the sync mirrors. Officially, I believe you are OK with doing this (the limit for "appropriate use" is once/day), but is it truly needed?

IMO, only in rare cases is it acceptable to be sync'ing once per day. If you would, please chop this down to once every other day, or perhaps 3x per week.
Back to top
View user's profile Send private message
spb
Retired Dev
Retired Dev


Joined: 02 Jan 2004
Posts: 2135
Location: Cambridge, UK

PostPosted: Sat May 22, 2004 9:34 pm    Post subject: Reply with quote

Missing poll option: Thought about it, but decided it was a stupid idea. ;)

That's overstating it a bit, perhaps, but blindly doing updates and depcleans in a cron job has the potential to do some serious harm. I once ended up with a non-bootable system throught not running etc-update after an upgrade (udev got updated, but its config didn't). And you can't automerge config changes either, because you'll nuke fstab at the next baselayout upgrade.
Back to top
View user's profile Send private message
fwerner
n00b
n00b


Joined: 27 Mar 2003
Posts: 46
Location: Germany / Freiburg

PostPosted: Sat May 22, 2004 9:35 pm    Post subject: Reply with quote

carambola5 wrote:
While it's a nice idea and all, it is my opinion that sync'ing once a day is abuse of the sync mirrors. Officially, I believe you are OK with doing this (the limit for "appropriate use" is once/day), but is it truly needed?

IMO, only in rare cases is it acceptable to be sync'ing once per day. If you would, please chop this down to once every other day, or perhaps 3x per week.


hm i thought rsync only transmits the changes? so where is the difference between once a week and once pe day?

i do it once per day just because i dont want long compile times.

once in a week is another possibility....i am thinking about....how much traffic is sent by rsync when no update is there? so i have a value.....

f.
Back to top
View user's profile Send private message
fwerner
n00b
n00b


Joined: 27 Mar 2003
Posts: 46
Location: Germany / Freiburg

PostPosted: Sat May 22, 2004 11:24 pm    Post subject: Reply with quote

thebell wrote:
Missing poll option: Thought about it, but decided it was a stupid idea. ;)

That's overstating it a bit, perhaps, but blindly doing updates and depcleans in a cron job has the potential to do some serious harm. I once ended up with a non-bootable system throught not running etc-update after an upgrade (udev got updated, but its config didn't). And you can't automerge config changes either, because you'll nuke fstab at the next baselayout upgrade.


thats the reason for the secon option... because i thought everybody who thought of it will at least build a notifcation script....

i have a stable system (with xorg) and all goes well....

but its not a production system!

about the config files:

cron is mailing the output to me so i see which packages has been updated. and then i have to manually check the conf.

but you're right. you have to do this by hand and its not a good idea to forget it.

how do you like the script? im missing suggestions to make it better...i can't believe that all is right (as i already mentioned its my first one)
Back to top
View user's profile Send private message
aridhol
Guru
Guru


Joined: 20 Jan 2003
Posts: 509
Location: Stockholm, Sweden

PostPosted: Sun May 23, 2004 8:36 pm    Post subject: Reply with quote

There is no option for (No, I don't like automated updates.)
_________________
72 of Pitcairn Islands 49 inhabitants use Seti@Home
"If you buy a DVD you have a copy. If you want a backup copy you buy another one."
"Anyone who is capable of getting themselves made President should on no account be allowed to do the job."
Back to top
View user's profile Send private message
Roguelazer
Veteran
Veteran


Joined: 10 Feb 2003
Posts: 1233
Location: San Francisco, CA

PostPosted: Sun May 23, 2004 10:12 pm    Post subject: Reply with quote

I wrote my own awhile ago. Here it is for any interested parties:

Code:

#!/bin/bash

echo "Starting Roguelazer\'s System Updater..."

LOGDIR="${HOME}/.system_updates/"
LOGFILE="${HOME}/.system_updates/log"
UPDATEFILE="${HOME}/worldupdates.txt"
TEMPFILE="${HOME}/tempupdates"

if [ ${UID} == 0 ]
then true
else echo "You need to have root privileges to run this script"
exit 1
fi

if [ -d ${LOGDIR} ]
then true
else mkdir ${LOGDIR}
fi

if [  -e ${LOGFILE} ]
then true
else touch ${LOGFILE}
fi

STARTTIME=`date +%x' '%X`
echo "${STARTTIME} : Update commenced" >> ${LOGFILE}
echo "Update commenced at ${STARTTIME}"
echo "Syncing time to Atomic Clock..."
rdate -s time.nist.gov > /dev/null 2>&1
echo "Done!"
echo "Updating locate database..."
updatedb -u > /dev/null 2>&1
echo "Done!"
echo "Updating Prelink status..."
prelink -afmR > /dev/null 2>&1
echo "Done!"
echo "Updating portage tree..."
emerge sync > /dev/null 2>&1
echo "Done!"
echo "Updating esearch database..."
eupdatedb > /dev/null 2>&1
echo "Done!"
echo "Searching for updates..."
emerge -up world > ${UPDATEFILE}
cat ${UPDATEFILE} | grep ebuild > ${TEMPFILE}
cp ${TEMPFILE} ${UPDATEFILE}
rm ${TEMPFILE}
UPDATESAVAILABLE=`wc -l ${UPDATEFILE} | cut -c-2`
echo "${UPDATESAVAILABLE} updates were available" >> ${LOGFILE}
echo "${UPDATESAVAILABLE} updates available..."
ENDTIME=`date +%x' '%X`
echo "Update finished at ${ENDTIME}"
echo "${ENDTIME} : Update finished" >> ${LOGFILE}
echo "Starting upgrade procedure, please wait..."
emerge -uav world

_________________
Registered Linux User #263260
Back to top
View user's profile Send private message
fwerner
n00b
n00b


Joined: 27 Mar 2003
Posts: 46
Location: Germany / Freiburg

PostPosted: Mon May 24, 2004 6:16 am    Post subject: Reply with quote

i would place the prelink command at the end.

why prelinking when some packages will be replaced? they will work but they won't be prelinked. if you place it at the end you know that everything is prelinked everytime.

updatedb: hm i wouldnt do that in my update script because i think it has nothing to do with a system update. this process should run daily in a cron job (same for the atomic clock).

f.
Back to top
View user's profile Send private message
Roguelazer
Veteran
Veteran


Joined: 10 Feb 2003
Posts: 1233
Location: San Francisco, CA

PostPosted: Mon May 24, 2004 10:36 am    Post subject: Reply with quote

I put the updatedb script in because I don't particularly need to run it on a regular basis, but since I'm updating my packages, I might as well update everything else. As for the prelink, well, I do it at the beginning because the emerge -u world often fails halfway through, terminating the script. And when it doesn't, it still takes quite a few hours. I like to have everything else done before I do the emerge -u world so that I can safely terminate the emerge -u world and not leave anything...undone.
_________________
Registered Linux User #263260
Back to top
View user's profile Send private message
fwerner
n00b
n00b


Joined: 27 Mar 2003
Posts: 46
Location: Germany / Freiburg

PostPosted: Mon May 24, 2004 1:50 pm    Post subject: Reply with quote

Roguelazer wrote:
I put the updatedb script in because I don't particularly need to run it on a regular basis, but since I'm updating my packages, I might as well update everything else. As for the prelink, well, I do it at the beginning because the emerge -u world often fails halfway through, terminating the script. And when it doesn't, it still takes quite a few hours. I like to have everything else done before I do the emerge -u world so that I can safely terminate the emerge -u world and not leave anything...undone.


with ebegin and eend you can define blocks with can run seperatly...even if the update failes you can continue

(have a look at my code - when you remove the exit line in the hasError function it will continue with the next block.
Back to top
View user's profile Send private message
Roguelazer
Veteran
Veteran


Joined: 10 Feb 2003
Posts: 1233
Location: San Francisco, CA

PostPosted: Mon May 24, 2004 7:29 pm    Post subject: Reply with quote

*shrug*

Mine works for me, yours works for you. The power of choice, right?
_________________
Registered Linux User #263260
Back to top
View user's profile Send private message
NeighborhoodGullwings
Apprentice
Apprentice


Joined: 05 Dec 2003
Posts: 159

PostPosted: Tue May 25, 2004 8:22 am    Post subject: Reply with quote

I agree with the poster above that said automatic updates is an abuse of the rsync mirrors. It is.

It also provides an enormous opportunity to break your system. The times when you should update a package are to fix bugs/holes, to add new functionality, or to benefit from performance improvements. Blindlessly upgrading every package that's available is both unnecessary and ignorant. It introduces a risk in that the upgraded package is actually worse (less functionality, more bugs) than the previous version (whether the authors knew about it or not), and is especially silly when the upgraded package doesn't add any new improvements that you would use.

I didn't vote, because there wasn't an option for "I thought about it and decided it was dumb."
Back to top
View user's profile Send private message
Roguelazer
Veteran
Veteran


Joined: 10 Feb 2003
Posts: 1233
Location: San Francisco, CA

PostPosted: Tue May 25, 2004 10:44 am    Post subject: Reply with quote

Automatic updates don't hurt rsync mirrors if they're run once every two days. As for blindly upgrading, well, look up the -a flag of emerge. As in emerge -uav.
_________________
Registered Linux User #263260
Back to top
View user's profile Send private message
spb
Retired Dev
Retired Dev


Joined: 02 Jan 2004
Posts: 2135
Location: Cambridge, UK

PostPosted: Tue May 25, 2004 10:46 am    Post subject: Reply with quote

Roguelazer wrote:
Automatic updates don't hurt rsync mirrors if they're run once every two days. As for blindly upgrading, well, look up the -a flag of emerge. As in emerge -uav.

If you're going to use the -a flag, then that completely defeats the point of automated updates, since you need to explicitly say 'yes' every time. You might as well do it manually every couple of days (which I do).
Back to top
View user's profile Send private message
Roguelazer
Veteran
Veteran


Joined: 10 Feb 2003
Posts: 1233
Location: San Francisco, CA

PostPosted: Tue May 25, 2004 8:02 pm    Post subject: Reply with quote

It still does everything else automagically. And if you really wanted to, you could set up a little script that does -a and then, if no response is given after 10 minutes, assumes Yes.
_________________
Registered Linux User #263260
Back to top
View user's profile Send private message
teglsbo
n00b
n00b


Joined: 18 Apr 2004
Posts: 11

PostPosted: Wed May 26, 2004 10:12 pm    Post subject: Redirection in sysupdate Reply with quote

Code:
emerge world -uDv >> /var/log/sysupdate.detail 2> var/log/sysupdate.detail &> /var/log/sysupdate.detail

The above type of redirect is wrong.
It will overwrite /var/log/sysupdate.detail instead of appending.

Instead use:
Code:
emerge world -uDv >> /var/log/sysupdate.detail 2>&1
Back to top
View user's profile Send private message
teglsbo
n00b
n00b


Joined: 18 Apr 2004
Posts: 11

PostPosted: Wed May 26, 2004 10:19 pm    Post subject: $CONFIG_PROTECT in cron jobs Reply with quote

When running a script like sysupdate from a cron job you will have to make sure that you have $CONFIG_PROTECT set correctly, which is not done by cron.

I have added these lines to the top of sysupdate:
Code:
# Make sure we have $CONFIG_PROTECT
source /etc/profile

If $CONFIG_PROTECT is not set then protected paths not listed in /etc/make.globals (e.g. "/var/bind" for bind) will not be protected.
Back to top
View user's profile Send private message
fwerner
n00b
n00b


Joined: 27 Mar 2003
Posts: 46
Location: Germany / Freiburg

PostPosted: Fri Jun 04, 2004 5:01 pm    Post subject: Re: Redirection in sysupdate Reply with quote

teglsbo wrote:
Code:
emerge world -uDv >> /var/log/sysupdate.detail 2> var/log/sysupdate.detail &> /var/log/sysupdate.detail

The above type of redirect is wrong.
It will overwrite /var/log/sysupdate.detail instead of appending.

Instead use:
Code:
emerge world -uDv >> /var/log/sysupdate.detail 2>&1


Thank you :-)
I will add it tomorrow..and place a link with a modified version (it also uses revdep-rebuild and contains the CONFIG_PROTECT warning

f.
Back to top
View user's profile Send private message
placeholder
Advocate
Advocate


Joined: 07 Feb 2004
Posts: 2500

PostPosted: Fri Jun 04, 2004 5:22 pm    Post subject: Reply with quote

I never really thought of anything like it, because I like to see what packages are going to get updated in order to keep stuff I want off of my HDD since GTK+ seems to "need" gnome-hicolor and gnome-icon-theme as a dependency now. :roll:
Back to top
View user's profile Send private message
icefox13
Tux's lil' helper
Tux's lil' helper


Joined: 19 Apr 2004
Posts: 78
Location: Munich, Germany

PostPosted: Fri Jun 04, 2004 5:55 pm    Post subject: Reply with quote

I have only created a small cronjob which syncs the portage every day and creates a list of programs which "emerge -uD world" would build. Finally, because I update nearly every package to keep the system consistent, it fetches the packages with "emerge -fuD world".

I know the maximum is once a day... I will lower this to once a week
Back to top
View user's profile Send private message
fwerner
n00b
n00b


Joined: 27 Mar 2003
Posts: 46
Location: Germany / Freiburg

PostPosted: Fri Jun 04, 2004 5:58 pm    Post subject: Reply with quote

Pwnz3r wrote:
I never really thought of anything like it, because I like to see what packages are going to get updated in order to keep stuff I want off of my HDD since GTK+ seems to "need" gnome-hicolor and gnome-icon-theme as a dependency now. :roll:


the script brakes when the update fails and your cron mails you the output.
so you see the failure...and can look into /var/log/sysupdate.daily, fixing it by adding it to /etc/portage/package.keywords and wait until next week....

until now it never happend to me...lucky guy i guess :-)
Back to top
View user's profile Send private message
untiefe
Apprentice
Apprentice


Joined: 12 Jan 2004
Posts: 230
Location: the nonexisting Bielefeld, Germany

PostPosted: Sat Jul 02, 2005 10:46 am    Post subject: Reply with quote

I've started quite some time ago to write glcu, that doesn't automatically updates your system, but precompiles the packages, that need an update and notifies you via eMail. Because I like to have some control over my gentoo box and because you can't do the etc-update automatically, this is the only working update option for me.

Bye, Michael
_________________
"I'm an angel bored like hell
And you're a devil meaning well"

:: Cardigans - You're The Storm ::

glcu - gentoo linux cron update (full featured semi-automatic updates via cron)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat 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