ionice limits

This commit is contained in:
Kolan Sh 2012-08-17 10:51:32 +04:00
parent 23ab2315d8
commit 0e8011f70a
3 changed files with 23 additions and 19 deletions

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
STAGE=0 STAGE=0
NICE_CMD=nice -n 19 ionice -c2 -n7
source /etc/make.conf source /etc/make.conf
[ -f /etc/gentoo-upgrade.conf ] && source /etc/gentoo-upgrade.conf [ -f /etc/gentoo-upgrade.conf ] && source /etc/gentoo-upgrade.conf
@ -103,14 +104,14 @@ if [ 1 -eq $STAGE ]; then
fi fi
# sync portage tree # sync portage tree
eix-sync || emerge --sync $NICE_CMD eix-sync || $NICE_CMD emerge --sync
[ 0 -ne $? ] && echo "Stage $STAGE: portage tree synchronization failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: portage tree synchronization failed ;-( =======" && exit $STAGE
# Update metadata cache # Update metadata cache
in_list "$EGENCACHE" ${TRUE_LIST[@]} && in_list "$EGENCACHE" ${TRUE_LIST[@]} &&
if [[ "git" == "$SYNC_TYPE" ]]; then if [[ "git" == "$SYNC_TYPE" ]]; then
echo "---------- Updating metadata cache for Git portage tree ----------" echo "---------- Updating metadata cache for Git portage tree ----------"
egencache --repo=gentoo --update --jobs=$((`grep "^processor" /proc/cpuinfo -c`+1)) $NICE_CMD egencache --repo=gentoo --update --jobs=$((`grep "^processor" /proc/cpuinfo -c`+1))
[ 0 -ne $? ] && echo "Stage $STAGE: Metadata update failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: Metadata update failed ;-( =======" && exit $STAGE
fi fi
@ -122,19 +123,19 @@ if [ 1 -eq $STAGE ]; then
# eix update # eix update
if [ `which eix-update 2>/dev/null` ]; then if [ `which eix-update 2>/dev/null` ]; then
eix-update $NICE_CMD eix-update
[ 0 -ne $? ] && echo "Stage $STAGE: eix-update failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: eix-update failed ;-( =======" && exit $STAGE
fi fi
# eix-remote update # eix-remote update
if [ `which eix-remote 2>/dev/null` ]; then if [ `which eix-remote 2>/dev/null` ]; then
eix-remote update $NICE_CMD eix-remote update
[ 0 -ne $? ] && echo "Stage $STAGE: eix-remote update failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: eix-remote update failed ;-( =======" && exit $STAGE
fi fi
# layman syncronization # layman syncronization
if [ `which layman 2>/dev/null` ]; then if [ `which layman 2>/dev/null` ]; then
layman -S $NICE_CMD layman -S
[ 0 -ne $? ] && echo "Stage $STAGE: layman synchronization failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: layman synchronization failed ;-( =======" && exit $STAGE
fi fi
@ -163,7 +164,7 @@ fi
if [ 3 -eq $STAGE ]; then if [ 3 -eq $STAGE ]; then
echo "======= STAGE $STAGE: disable prelink =======" echo "======= STAGE $STAGE: disable prelink ======="
if [ `which prelink 2>/dev/null` ]; then if [ `which prelink 2>/dev/null` ]; then
prelink -ua 2>/dev/null $NICE_CMD prelink -ua 2>/dev/null
[ 0 -ne $? ] && echo "Stage $STAGE: prelink disabling failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: prelink disabling failed ;-( =======" && exit $STAGE
fi fi
@ -312,7 +313,7 @@ if [ 11 -eq $STAGE ]; then
[ 0 != $? ] && echo "Stage $STAGE: cann't touch /etc/portage/need_upgrade_xorg_input_drivers ;-( =======" && exit $STAGE [ 0 != $? ] && echo "Stage $STAGE: cann't touch /etc/portage/need_upgrade_xorg_input_drivers ;-( =======" && exit $STAGE
eselect python set $new_python eselect python set $new_python
[ 0 != $? ] && echo "Stage $STAGE: cann't switch to another python version ;-( =======" && exit $STAGE [ 0 != $? ] && echo "Stage $STAGE: cann't switch to another python version ;-( =======" && exit $STAGE
python-updater $NICE_CMD python-updater
[ 0 != $? ] && echo "Stage $STAGE: python-updater failed ;-( =======" && exit $STAGE [ 0 != $? ] && echo "Stage $STAGE: python-updater failed ;-( =======" && exit $STAGE
rm /etc/portage/need_upgrade_python rm /etc/portage/need_upgrade_python
[ 0 != $? ] && echo "Stage $STAGE: cann't remove /etc/portage/need_upgrade_xorg_input_drivers ;-( =======" && exit $STAGE [ 0 != $? ] && echo "Stage $STAGE: cann't remove /etc/portage/need_upgrade_xorg_input_drivers ;-( =======" && exit $STAGE
@ -360,16 +361,16 @@ if [ 14 -eq $STAGE ]; then
emerge -c emerge -c
[ 0 -ne $? ] && echo "Stage $STAGE: emerge -c failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: emerge -c failed ;-( =======" && exit $STAGE
if [ `which localepurge 2>/dev/null` ]; then if [ `which localepurge 2>/dev/null` ]; then
localepurge &>/dev/null $NICE_CMD localepurge &>/dev/null
[ 0 -ne $? ] && echo "Stage $STAGE: localepurge failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: localepurge failed ;-( =======" && exit $STAGE
fi fi
if [ `which eclean 2>/dev/null` ]; then if [ `which eclean 2>/dev/null` ]; then
eclean packages $NICE_CMD eclean packages
[ 0 -ne $? ] && echo "Stage $STAGE: eclean packages failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: eclean packages failed ;-( =======" && exit $STAGE
in_list "$ECLEAN_DISTFILES" ${TRUE_LIST[@]} in_list "$ECLEAN_DISTFILES" ${TRUE_LIST[@]}
if [ 0 -eq $? ]; then if [ 0 -eq $? ]; then
eclean distfiles $NICE_CMD eclean distfiles
[ 0 -ne $? ] && echo "Stage $STAGE: eclean distfiles failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: eclean distfiles failed ;-( =======" && exit $STAGE
fi fi
fi fi
@ -392,7 +393,7 @@ fi
if [ 16 -eq $STAGE ]; then if [ 16 -eq $STAGE ]; then
echo "======= STAGE $STAGE: Scan for vulnearable packages =======" echo "======= STAGE $STAGE: Scan for vulnearable packages ======="
if [ `which glsa-check 2>/dev/null` ]; then if [ `which glsa-check 2>/dev/null` ]; then
glsa-check -f affected $NICE_CMD glsa-check -f affected
# [ 0 -ne $? ] && echo "Stage $STAGE: glsa-check fix failed ;-( =======" && exit $STAGE # [ 0 -ne $? ] && echo "Stage $STAGE: glsa-check fix failed ;-( =======" && exit $STAGE
fi fi
@ -405,7 +406,7 @@ fi
if [ 17 -eq $STAGE ]; then if [ 17 -eq $STAGE ]; then
echo "======= STAGE $STAGE: Prelink libraries =======" echo "======= STAGE $STAGE: Prelink libraries ======="
if [ `which prelink 2>/dev/null` ]; then if [ `which prelink 2>/dev/null` ]; then
prelink -avfmR $NICE_CMD prelink -avfmR
[ 0 -ne $? ] && echo "Stage $STAGE: prelink -avfmR failed ;-( =======" && exit $STAGE [ 0 -ne $? ] && echo "Stage $STAGE: prelink -avfmR failed ;-( =======" && exit $STAGE
fi fi

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
NICE_CMD=nice -n 19 ionice -c2 -n7
REVISION=`kernel-config list | grep \*$ | cut -d" " -f6 | cut -d- -f2-8` REVISION=`kernel-config list | grep \*$ | cut -d" " -f6 | cut -d- -f2-8`
[ "" == "$REVISION" ] && echo "No appropriate kernel revision found ;-(" && exit -1 [ "" == "$REVISION" ] && echo "No appropriate kernel revision found ;-(" && exit -1
@ -7,7 +9,7 @@ SOURCES=linux-$REVISION
[ "" == "$SOURCES" ] && echo "No appropriate kernel sources found ;-(" && exit -1 [ "" == "$SOURCES" ] && echo "No appropriate kernel sources found ;-(" && exit -1
# rm old modules # rm old modules
cd /lib/modules && rm -rf `ls | grep -v "^$REVISION$"` cd /lib/modules && $NICE_CMD rm -rf `ls | grep -v "^$REVISION$"`
# rm old kernel revisions # rm old kernel revisions
mount -o remount,rw /boot mount -o remount,rw /boot
@ -15,7 +17,7 @@ cd /boot && rm -f `ls System.map-* config-* vmlinuz-* initramfs-* 2>/dev/null |
mount -o remount,ro /boot mount -o remount,ro /boot
# rm old sources # rm old sources
cd /usr/src && rm -rf `find -maxdepth 1 -name "linux-*" -type d | grep -v "$SOURCES$"` cd /usr/src && $NICE_CMD rm -rf `find -maxdepth 1 -name "linux-*" -type d | grep -v "$SOURCES$"`
exit 0 exit 0

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
SILENT=false SILENT=false
NICE_CMD=nice -n 19 ionice -c2 -n7
# available parameters # available parameters
eval set -- "`getopt -o hs --long help,silent -- \"$@\"`" eval set -- "`getopt -o hs --long help,silent -- \"$@\"`"
@ -45,22 +46,22 @@ fi
grep 'CONFIG_X86_MARCH_NATIVE=y' .config &>/dev/null grep 'CONFIG_X86_MARCH_NATIVE=y' .config &>/dev/null
jobs=$((`grep "^processor" /proc/cpuinfo -c`+1)) jobs=$((`grep "^processor" /proc/cpuinfo -c`+1))
if [[ "$?" == 0 ]]; then if [[ "$?" == 0 ]]; then
make -j$jobs $NICE_CMD make -j$jobs
[ 0 -ne $? ] && echo "Kernel build failed ;-(" && exit -1 [ 0 -ne $? ] && echo "Kernel build failed ;-(" && exit -1
else else
# pump make -j$((jobs*3)) || make -j$jobs # pump make -j$((jobs*3)) || make -j$jobs
make -j$jobs $NICE_CMD make -j$jobs
[ 0 -ne $? ] && echo "Kernel build failed ;-(" && exit -1 [ 0 -ne $? ] && echo "Kernel build failed ;-(" && exit -1
fi fi
mount -o remount,rw /boot mount -o remount,rw /boot
make install $NICE_CMD make install
make modules_install $NICE_CMD make modules_install
REVISION=`cat /usr/src/linux/include/config/kernel.release` REVISION=`cat /usr/src/linux/include/config/kernel.release`
which dracut &>/dev/null && dracut --hostonly --force /boot/initramfs-$REVISION.img $REVISION which dracut &>/dev/null && $NICE_CMD dracut --hostonly --force /boot/initramfs-$REVISION.img $REVISION
sed -i "s~\/boot\/vmlinuz-[0-9][^ ]*~\/boot\/vmlinuz-$REVISION~g; sed -i "s~\/boot\/vmlinuz-[0-9][^ ]*~\/boot\/vmlinuz-$REVISION~g;
s~\/boot\/initramfs-[0-9][^ ]*~\/boot\/initramfs-$REVISION.img~g" \ s~\/boot\/initramfs-[0-9][^ ]*~\/boot\/initramfs-$REVISION.img~g" \