aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-05-29 21:06:59 +0100
committerRoy Marples <roy@marples.name>2009-05-29 21:06:59 +0100
commitfa9e482a31719d5fd647a183f1f844e596db6acf (patch)
tree59e823c8dfc468aba010a4a56ca9bc1c0f302d52
parent60134ddec5fe19bc14bf0fa10d963e5f1812d586 (diff)
If not running on AC power don't run fsck to preserve battery life.
-rw-r--r--init.d/fsck.in23
1 files changed, 23 insertions, 0 deletions
diff --git a/init.d/fsck.in b/init.d/fsck.in
index 85715f01..af2b8fbe 100644
--- a/init.d/fsck.in
+++ b/init.d/fsck.in
@@ -30,6 +30,26 @@ _forcefsck()
[ -e /forcefsck ] || get_bootparam forcefsck
}
+_on_ac_power()
+{
+ if [ -f /proc/acpi/ac_adapter/AC/state ]; then
+ cat /proc/acpi/ac_adapter/AC/state | while read line; do
+ case "$line" in
+ "state:"*"on-line") return 128;;
+ esac
+ done
+ elif [ -f /proc/pmu/info ]; then
+ cat /proc/pmu/info | while read line; do
+ case "$line" in
+ "AC Power"*": 1") return 128;;
+ esac
+ done
+ else
+ return 0
+ fi
+ [ $? = 128 ]
+}
+
start()
{
local fsck_opts= p= check_extra=
@@ -41,6 +61,9 @@ start()
if _forcefsck; then
fsck_opts="$fsck_opts -f"
check_extra="(check forced)"
+ elif ! _on_ac_power; then
+ ewarn "Skipping fsck due to not being on AC power"
+ return 0
fi
if [ -n "$fsck_passno" ]; then