Merge lp:~shiyee/update-notifier/fsck-at-reboot into lp:update-notifier/ubuntu

Proposed by Mads Chr. Olesen
Status: Merged
Approved by: Michael Vogt
Approved revision: 589
Merged at revision: 597
Proposed branch: lp:~shiyee/update-notifier/fsck-at-reboot
Merge into: lp:update-notifier/ubuntu
Diff against target: 95 lines (+63/-1)
4 files modified
data/Makefile.am (+1/-1)
data/update-motd-fsck-at-reboot (+58/-0)
debian/98-fsck-at-reboot (+3/-0)
debian/update-notifier-common.install (+1/-0)
To merge this branch: bzr merge lp:~shiyee/update-notifier/fsck-at-reboot
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Ubuntu Core Development Team Pending
Review via email: mp+31879@code.launchpad.net

Description of the change

display info on pending fsck at reboot in MOTD

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, the branch looks good. I'm happy to merge it, but please sign the canonical contributors agreement first (if you haven't done that already). Its quick and painless, for details, check:
http://www.canonical.com/contributors

Revision history for this message
Mads Chr. Olesen (shiyee) wrote :

Contributor agreement accepted, per email.

Revision history for this message
Michael Vogt (mvo) wrote :

On Wed, Nov 10, 2010 at 12:58:57PM -0000, Mads Chr. Olesen wrote:
> Contributor agreement accepted, per email.

Thanks a lot! I merged the branch now and will upload soon (this week)
into natty.

Cheers,
 Michael

Revision history for this message
Michael Vogt (mvo) wrote :

I did a small modification to the script that makes it (IMO) easier to read, see
http://bazaar.launchpad.net/~ubuntu-core-dev/update-notifier/ubuntu/revision/598

This preserves the multiline nature of the output in the "echo" and that makes the parsing easier with grep/cut

Revision history for this message
Michael Vogt (mvo) wrote :

Feedback welcome on this of course (e.g. if there is something that I overlooked).

Revision history for this message
Mads Chr. Olesen (shiyee) wrote :

It seems to be broken if more than one ext partition is mounted:
$ sudo bash -x update-motd-fsck-at-reboot --force
...
+ ext_partitions='/dev/sda2
/dev/sda5'
+ OLD_IFS='
'
+ IFS=' '
+ for part in '$ext_partitions'
++ dumpe2fs -h '/dev/sda2
/dev/sda5'
+ dumpe2fs_out='Couldn'\''t find valid filesystem superblock.'

Moving the IFS magic inside the loop seems to fix it.

Revision history for this message
Michael Vogt (mvo) wrote :

On Thu, Nov 11, 2010 at 10:23:44AM -0000, Mads Chr. Olesen wrote:
> It seems to be broken if more than one ext partition is mounted:
> $ sudo bash -x update-motd-fsck-at-reboot --force
> ...
> + ext_partitions='/dev/sda2
> /dev/sda5'
> + OLD_IFS='
> '
> + IFS=' '
> + for part in '$ext_partitions'
> ++ dumpe2fs -h '/dev/sda2
> /dev/sda5'
> + dumpe2fs_out='Couldn'\''t find valid filesystem superblock.'
>
> Moving the IFS magic inside the loop seems to fix it.

Thanks! I commited another small change that removes the IFS entirely,
I think it works fine, but I would appreciate if you could double
check, I only have a single parition setup, this is why I didn't
detect this error.

Thanks,
 Michael

Revision history for this message
Mads Chr. Olesen (shiyee) wrote :

Works fine for me now.
Thanks :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/Makefile.am'
2--- data/Makefile.am 2010-06-01 13:28:36 +0000
3+++ data/Makefile.am 2010-08-05 19:41:48 +0000
4@@ -10,7 +10,7 @@
5 @INTLTOOL_SCHEMAS_RULE@
6
7 helperdir = $(libdir)/update-notifier
8-helper_SCRIPTS = apt_check.py apt-cdrom-check cddistupgrader update-motd-reboot-required update-motd-updates-available update-motd-cpu-checker
9+helper_SCRIPTS = apt_check.py apt-cdrom-check cddistupgrader update-motd-reboot-required update-motd-updates-available update-motd-cpu-checker update-motd-fsck-at-reboot
10
11 notifydir = $(datadir)/update-notifier
12 notify_SCRIPTS = notify-reboot-required
13
14=== added file 'data/update-motd-fsck-at-reboot'
15--- data/update-motd-fsck-at-reboot 1970-01-01 00:00:00 +0000
16+++ data/update-motd-fsck-at-reboot 2010-08-05 19:41:48 +0000
17@@ -0,0 +1,58 @@
18+#!/bin/sh -e
19+#Author: Mads Chr. Olesen <mads@mchro.dk>
20+
21+# poor mans force
22+if [ "$1" = "--force" ]; then
23+ NEED_UPDATE_CHECK=yes
24+fi
25+
26+
27+
28+# check time when we did the last check
29+stamp="/var/lib/update-notifier/fsck-at-reboot"
30+if [ -e "$stamp" ]; then
31+ stampt=$(stat -c %Y $stamp)
32+else
33+ stampt=0
34+fi
35+
36+now=$(date +%s)
37+if [ $(($stampt + 3600)) -lt $now ]; then
38+ #echo $stampt $now need update
39+ NEED_UPDATE_CHECK=yes
40+fi
41+
42+# output something for update-motd
43+if [ -n "$NEED_UPDATE_CHECK" ]; then
44+ echo -n "" > $stamp
45+
46+ ext_partitions=$(mount | egrep 'ext(2|3|4)' | cut -f 1 -d \ )
47+ for part in $ext_partitions; do
48+ dumpe2fs_out=$(dumpe2fs -h $part 2>/dev/null)
49+ counts=$(echo "$dumpe2fs_out" | grep -i "mount count" | sed -e 's/.* \(.*\)$/\1/')
50+ mount_count=$(echo $counts | cut -d \ -f 1)
51+ max_mount_count=$(echo $counts | cut -d \ -f 2)
52+
53+ next_check_date=$(echo "$dumpe2fs_out" | grep "Next check" | sed -e 's/.* \(.*\)$/\1/')
54+ next_check_tstamp=$(date -d "$next_check_date" +%s)
55+
56+ #echo $next_check_date $next_check_tstamp
57+ #echo $part $mount_count / $max_mount_count
58+
59+ if [ "$mount_count" -ge "$max_mount_count" -o \
60+ "$next_check_tstamp" -lt "$now" ]; then
61+ check_occur=yes
62+ echo "*** $part will be checked for errors at next reboot ***" >> $stamp
63+ fi
64+ done
65+ if [ -n "$check_occur" ]; then
66+ echo "" >> $stamp
67+ fi
68+fi
69+
70+# output what we have (either cached or newly generated)
71+cat $stamp
72+
73+
74+
75+
76
77=== added file 'debian/98-fsck-at-reboot'
78--- debian/98-fsck-at-reboot 1970-01-01 00:00:00 +0000
79+++ debian/98-fsck-at-reboot 2010-08-05 19:41:48 +0000
80@@ -0,0 +1,3 @@
81+#!/bin/sh
82+
83+exec /usr/lib/update-notifier/update-motd-fsck-at-reboot
84
85=== modified file 'debian/update-notifier-common.install'
86--- debian/update-notifier-common.install 2010-06-01 13:28:36 +0000
87+++ debian/update-notifier-common.install 2010-08-05 19:41:48 +0000
88@@ -5,6 +5,7 @@
89 debian/20-cpu-checker etc/update-motd.d
90 debian/90-updates-available etc/update-motd.d
91 debian/98-reboot-required etc/update-motd.d
92+debian/98-fsck-at-reboot etc/update-motd.d
93 usr/share/update-notifier/notify-reboot-required
94 usr/lib/update-notifier/
95 usr/share/locale

Subscribers

People subscribed via source and target branches

to all changes: