Gentoo-Upgrade/sbin/e4rat_switch.sh

47 lines
1.6 KiB
Bash
Raw Normal View History

2012-08-31 13:35:46 +04:00
#!/bin/bash
2012-12-01 01:48:28 +04:00
GRUB_CFG_FLIST=""
[ -f /boot/grub/grub.conf ] && GRUB_CFG_FLIST="$GRUB_CFG_FLIST /boot/grub/grub.conf"
[ -f /boot/grub2/grub.cfg ] && GRUB_CFG_FLIST="$GRUB_CFG_FLIST /boot/grub2/grub.cfg"
[ "" == "$GRUB_CFG_FLIST" ] && echo 'No Grub config files found! ;-(' && exit -1
if [[ `which e4rat-realloc 2>/dev/null` && `grep 'init=/sbin/e4rat-' $GRUB_CFG_FLIST` ]]; then
2012-08-31 13:35:46 +04:00
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" \
2012-12-01 01:48:28 +04:00
$GRUB_CFG_FLIST && \
2012-08-31 13:35:46 +04:00
echo "remounting /boot -> ro" && \
2013-04-01 17:47:47 +04:00
mount -o remount,ro -force /boot && \
2012-08-31 14:12:07 +04:00
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
2012-08-31 13:35:46 +04:00
[ 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" \
2012-12-01 01:48:28 +04:00
$GRUB_CFG_FLIST && \
2012-08-31 13:35:46 +04:00
echo "remounting /boot -> ro" && \
2013-04-01 17:47:47 +04:00
mount -o remount,ro -force /boot
2012-08-31 13:35:46 +04:00
[ 0 -ne $? ] && echo "e4rat_switch.sh $1 failed" && exit -1
;;
*)
echo "Usage: e4rat_switch.sh {collect|preload}"
exit -1
;;
esac
exit 0