Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

5.7.09

Run updates from crontab

Simple safe-upgrade script to be run from root's crontab -

Reasoning - I was tired of the way the updater was in Ubuntu recently, that whole pop-under thing is annoying and counter productive. So I wrote a script that safe-update's the system and doesn't need a sudo user to install the updates.

Now, I would not advise using this on a server or mission critical desktop. Who knows what could happen even with only safe-update called...

Setup is near the bottom, read this first.

What update.sh does:

$now is the current date in unix time
$check_date is the current date minus one week
(actually 6 days 23 hours 59 minutes and 45 seconds)

Fist step is:
It checks to see if this script has been run before via a if file exists in bash

if yes then:
It checks to see if current date minus one week is greater than or equal to the last update. So if this was last run over a week ago it will start.
If not it was last updated withing a week it will exit. This _should_ not happen, but is a built in 'failsafe'.

If the file does not exist:
It creates the .update_log and goes on its merry way updating.

What is doens't do:
This script does NOT reboot the machine when done, this was done on purpose for the user(s). This way when they are done for the day they and shutdown the computer will be up to date the next time it is turned on.

WARNING:
Firefox will act crazy if not restarted after updating! This may be covered in the next revision.

Setup:
1. Copy between the CUTs to /root/update.sh via vim/vi/nano/gedit etc. (Yes you need to be root)
2. chmod +x /root/update.sh
3. su root (if you sudo'd in)
4. #crontab -e
5. Setup the crontab the way you like it
5a. Here's mine 30 16 * * 2 /root/update.sh
6. :wq <-- to save the crontab

You may also want crontab to shutdown or reboot the machine after, but that is up to you.


//----------------CUT--------------------------//
#!/bin/bash
# update.sh - DTM
# Get root's paths (as root 'grep bin /root/*')
# this will give the correct shell also
PATH=/usr/local/sbin:"${PATH}"
PATH=/usr/sbin:"${PATH}"
PATH=/sbin:"${PATH}"

# Check last update time
#-----------------------
# Check if file exists get information on last modify time or just create one

# Define vars using Unix time - makes it easier
now=`date +%s`
check_date=$(($now-604785))

# See if file exists
if [ -f /root/.update_log ];
then
last_update=`cat /root/.update_log`
if [ $check_date -ge $last_update ];
then
echo $now > /root/.update_log && aptitude update && aptitude -y safe-upgrade
else
exit
fi # //END COMPARE LOGS
else
echo $now > /root/.update_log && aptitude update && aptitude -y safe-upgrade
fi # //END MAIN IF
//-------------------------CUT--------------//

3.5.08

Have I found it?

Well, I think I have found the Linux flavor for my R61 Thinkpad.

I have tried:
Version of Linux / Reason(s) for not keeping on my notebook

Debian based-
1. Ubuntu 7.10 and 8.04 - the Ubuntu guys/community has done a great job of making Linux a more user friendly distro than most. Out of the box most everything works without a hitch this is great! But, I need more battery life than 2 hours which was the maximum I was able to obtain with Ubuntu tweaked with Powertop and all un-needed services swithced off.

2. Debian Etch - The tried and true base for most things *nix. But, I didn't have the time or the energy to manually configure everything that I needed to configure. For example the screen resolution, Wifi card and Suspend to Ram.

3. ParsiX - This little up and comer from Iran is a very nice "niche" linux. Only issue with this distribution is the use of Xorg 7.2 and the "bug" with the Lenovo screens. Whatever I tried to fix it with just would not give me the use of my entire screen.

Redhat based -
4. Centos 5.1 - It truly is wonderful that Redhat, even though they don't want to delve into the desktop arena are allowing the source to be put out for free "as is" this allows many people to use Centos as a highly reliable server for years to come. With many having great luck on older hardware and desktops. But for a newer notebook this is just flat out not the distro, I am not knocking it at all it is awesome and I still use it for server purposes but not for my R61. The Suspend to Ram, Suspend to Disk, Wifi are not able to be used without recompiling a newer kernel from scratch 2.6.18 just cant cut it these days.

5. Fedora - This is great if you are looking for cutting edge low life cycle Linux fun, but if you are looking for support longer than 13 months you are in the wrong place. There is a great wiki entry in regards to this, and that in and of itself is one of the few reasons I have to say nay to Fedora.

Novell/Suse -
6. OpenSuse 10.3 - This is/was my favorite distro as I have used Suse on and off since Suse7 and loved it. But the ports that seems to be made for the Suse SLED 10.1 that is shipped with R61's never seemed to make it into the 10.3 tree in time for me to be able to deal with. I really hated giving this one up but the lack of battery life and the screen resolution "bug" shared with Parsix made me switch.

Mandriva(Mandrake) -
7. Wow! I was always gun shy of a distro that asked you to pay for Linux. But after trying to free version I may deviate from that path. Everything works, less the Opek Finger print scanner but that will come in time. Add the availability or "Laptop" kernels for power savings and I am SOLD!

Granted I have not tried Slackware or Gentoo, maybe one day.

More to follow later.....