#!/bin/sh warn() { echo "$@" >&2 } die() { echo "$@" >&2 exit 1; } [ -f /etc/init.d/chrony ] && /etc/init.d/chrony stop &>/dev/null eth=0 (ifconfig eth0 | grep -q RUNNING) && eth=1 if [ "$eth" = "1" ] ; then ifconfig eth0 down || die "Couldn't disable eth0" fi oldconsole=`fgconsole` /etc/init.d/hwclock.sh stop &>/dev/null hdparm -q -W 0 /dev/hda || die "Couldn't disable write cache" chvt 1 || die "Couldn't switch VTs" echo 4 > /proc/acpi/sleep chvt $oldconsole hdparm -q -W 1 /dev/hda || warn "Couldn't reenable write cache" /etc/init.d/hwclock.sh start &>/dev/null if [ "$eth" = "1" ] ; then ifconfig eth0 up || warn "Couldn't reenable eth0" fi [ -f /etc/init.d/chrony ] && /etc/init.d/chrony start &>/dev/null