FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 09-24-2012, 01:12 PM
Leander Jedamus
 
Default unattended-upgrade in /etc/network/if-up.d

Hi!

I wrote a simple script for unattended-upgrade, which is run when an
interface (except loopback) is coming up.
It is modified from ntpdate in the same directory (/etc/network/if-up.d/).
Here it is:
----8<----8<----8<----8<----8<----8<----8<----
#!/bin/sh

# written by Leander Jedamus 24.09.2012

PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH

# gives me German messages
LANG=de_DE.utf8
export LANG

SCRIPTNAME=unattended-upgrade
PROGRAMPATH=/usr/bin
PROGRAMNAME1=apt-get
PROGRAMNAME2=unattended-upgrade
PROGRAM1=$PROGRAMPATH/$PROGRAMNAME1
PROGRAM2=$PROGRAMPATH/$PROGRAMNAME2

if [ "$METHOD" = loopback ]; then
exit 0
fi

# Check whether unattended-upgrade was removed but not purged; it's
useless to
# wait for it in that case.
if [ ! -x $PROGRAM1 ] && [ -d $PROGRAMPATH ]; then
exit 0
fi
if [ ! -x $PROGRAM2 ] && [ -d $PROGRAMPATH ]; then
exit 0
fi

(

# This is for the case that /usr will be mounted later.
if [ -r /lib/udev/hotplug.functions ]; then
. /lib/udev/hotplug.functions
wait_for_file $PROGRAM1
wait_for_file $PROGRAM2
fi

LOCKFILE=/var/lock/$SCRIPTNAME-ifup

# Avoid running more than one at a time
if [ -x /usr/bin/lockfile-create ]; then
lockfile-create $LOCKFILE
lockfile-touch $LOCKFILE &
LOCKTOUCHPID="$!"
fi

# invoke-rc.d --quiet ntp stop >/dev/null 2>&1 || true

# run update again, when return code is not 0
RETCODE=1
while [ $RETCODE != 0 ]; do
$PROGRAM1 update 2>/dev/null >/dev/null && RETCODE=0
done

$PROGRAM2

# invoke-rc.d --quiet ntp start >/dev/null 2>&1 || true

if [ -x /usr/bin/lockfile-create ] ; then
kill $LOCKTOUCHPID
lockfile-remove $LOCKFILE
fi

) &
----8<----8<----8<----8<----8<----8<----8<----

This script will run apt-get install as root until it succeeds running
and then will run unattended-upgrade.
Logfile is in /var/log/unattended-upgrades/unattended-upgrades.log

I also wrote to the author of unattended-upgrade, but he has not
answered me for a week or so.

Perhaps somebody else can use it.

Greetings
Leander Jedamus

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 09-24-2012, 01:26 PM
Leander Jedamus
 
Default unattended-upgrade in /etc/network/if-up.d

Hi!

I pasted it to http://paste.ubuntu.com/1224477/

Greetings
Leander Jedamus

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 12:16 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org