From 6ad162aaad70d1c5f36e5d8d161918c1b77dcd15 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Fri, 31 Aug 2012 13:35:46 +0400 Subject: [PATCH] e4rat optimization scripts added. --- sbin/e4rat_finalize.sh | 12 ++++++++++++ sbin/e4rat_switch.sh | 40 ++++++++++++++++++++++++++++++++++++++++ sbin/gentoo-upgrade.sh | 7 +++++++ 3 files changed, 59 insertions(+) create mode 100755 sbin/e4rat_finalize.sh create mode 100755 sbin/e4rat_switch.sh diff --git a/sbin/e4rat_finalize.sh b/sbin/e4rat_finalize.sh new file mode 100755 index 0000000..30b64e2 --- /dev/null +++ b/sbin/e4rat_finalize.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +let timeout=0`grep --color=NO '^[ \t]*timeout' /etc/e4rat.conf | head -n1 | sed 's~[^0-9]\+\([0-9]\+\).*~\1~'` + +sleep $timeout + +e4rat-collect -k +pkill e4rat-collect + +e4rat-realloc /var/lib/e4rat/startup.log + +e4rat_switch.sh preload diff --git a/sbin/e4rat_switch.sh b/sbin/e4rat_switch.sh new file mode 100755 index 0000000..d608731 --- /dev/null +++ b/sbin/e4rat_switch.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +if [[ `which e4rat-realloc 2>/dev/null` && `grep 'init=/sbin/e4rat-' /boot/grub/grub.conf` ]]; then + echo "e4rat package and e4rat init record in grub.conf found ;-)" +else + echo "Either e4rat package or e4rat record in grub.conf not found, exiting..." + exit 0 +fi + +case $1 in + collect) + echo "Setting up e4rat for collecting data" + echo "remounting /boot -> rw" + mount -o remount,rw /boot && \ + sed -i "s~init=/sbin/e4rat-[a-z]*~init=/sbin/e4rat-collect~g" \ + /boot/grub/grub.conf && \ + echo "remounting /boot -> ro" && \ + mount -o remount,ro /boot && \ + echo -e "#/bin/bash\n\n/usr/sbin/e4rat-finalize.sh && rm -f /etc/local.d/e4rat-finalize.start\n" \ + > /etc/local.d/e4rat-finalize.start && \ + chmod 755 /etc/local.d/e4rat-finalize.start + [ 0 -ne $? ] && echo "e4rat_switch.sh $1 failed" && exit -1 + ;; + preload) + echo "Setting up e4rat for preload system files" + echo "remounting /boot -> rw" + mount -o remount,rw /boot && \ + sed -i "s~init=/sbin/e4rat-[a-z]*~init=/sbin/e4rat-preload~g" \ + /boot/grub/grub.conf && \ + echo "remounting /boot -> ro" && \ + mount -o remount,ro /boot + [ 0 -ne $? ] && echo "e4rat_switch.sh $1 failed" && exit -1 + ;; + *) + echo "Usage: e4rat_switch.sh {collect|preload}" + exit -1 + ;; +esac + +exit 0 diff --git a/sbin/gentoo-upgrade.sh b/sbin/gentoo-upgrade.sh index 27a6ca9..ed5c828 100755 --- a/sbin/gentoo-upgrade.sh +++ b/sbin/gentoo-upgrade.sh @@ -444,4 +444,11 @@ if [ 20 -eq $STAGE ]; then let STAGE++ fi +# Stage 21: Enabling e4rat data collection +if [ 21 -eq $STAGE ]; then + echo "======= STAGE $STAGE: Enabling e4rat data collection =======" + e4rat_switch.sh collect + [ 0 -ne $? ] && echo "Stage $STAGE: Enabling e4rat data collection failed ;-( =======" && exit $STAGE + + let STAGE++ exit 0