howtos:alternative_to_the_200_lines_kernel_patch_that_does_wonders_which_you_can_use_right_away

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

howtos:alternative_to_the_200_lines_kernel_patch_that_does_wonders_which_you_can_use_right_away [d/m/Y H:i] (current)
Line 1: Line 1:
 +<file>
 +#!/bin/bash
 +#credits: superpiwi 
 +#http://ubuntulife.wordpress.com/2010/11/22/el-parche-milagro-de-linux-ahora-con-script-de-instalacion/
 +#in English and with 3 small fixes by Andrew @ http://www.webupd8.org
  
 +YELLOW="\033[1;33m"
 +RED="\033[0;31m"
 +ENDCOLOR="\033[0m"
 +
 +#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 +# PARCHEAR
 +#
 +# Aplica las mejoras del kernel (parche de 200 lineas)
 +# pero en 4 lineas de bash.
 +#
 +#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 +function PARCHEAR ()
 +{
 +
 +FICHERO="$HOME/.bashrc"
 +
 +echo ""
 +echo -e $YELLOW"Patching [${FICHERO}]..."$ENDCOLOR
 +echo ""
 +
 +# Añadiendo cadenas a .bashrc
 +
 +# Primero buscamos una cadena "base" para ver si esta o no ya añadido
 +LINEAS=`cat $FICHERO | grep "/dev/cgroup/cpu/user" | wc -l`
 +if [ "$LINEAS" == "0" ];
 +then
 + echo "Adding the patch..."
 + echo "if [ \"\$PS1\" ] ; then" | tee -a $FICHERO
 + echo "mkdir -p -m 0700 /dev/cgroup/cpu/user/\$\$ > /dev/null 2>&1" | tee -a $FICHERO
 + echo "echo \$\$ > /dev/cgroup/cpu/user/\$\$/tasks" | tee -a $FICHERO
 + echo "echo \"1\" > /dev/cgroup/cpu/user/\$\$/notify_on_release" | tee -a $FICHERO
 + echo "fi" | tee -a $FICHERO
 +else
 + echo "It seems the patch is already included in $FICHERO"
 +fi
 +
 +FICHERO="/etc/rc.local"
 +echo ""
 +echo -e $YELLOW"Patching [${FICHERO}]..."$ENDCOLOR
 +echo ""
 +
 +# Añadiendo cadenas a /etc/rc.local
 +
 +# Primero buscamos una cadena "base" para ver si esta o no ya añadido
 +LINEAS=`cat $FICHERO | grep "/dev/cgroup/cpu/release_agent" | wc -l`
 +if [ "$LINEAS" == "0" ];
 +then
 +
 + echo "Adding the patch..."
 + POSI=`cat $FICHERO | grep -n "exit 0" | sort -nr | head -n 1 | awk -F: '{print $1}'`
 + #echo "Posi es [$POSI]"
 + echo "Making backup of $FICHERO in /etc/rc.local.backup.txt"
 + cp /etc/rc.local /etc/rc.local.backup.txt
 + sed "${POSI}imkdir -p /dev/cgroup/cpu\nmount -t cgroup cgroup /dev/cgroup/cpu -o cpu\nmkdir -m 0777 /dev/cgroup/cpu/user\necho \"/usr/local/sbin/cgroup_clean\" > /dev/cgroup/cpu/release_agent" /etc/rc.local | tee /etc/rc.new.local
 + mv /etc/rc.new.local /etc/rc.local
 +
 + #echo "#========== 200 lines kernel patch alternative ============" | tee -a $FICHERO
 + #echo "mkdir -p /dev/cgroup/cpu" | tee -a $FICHERO
 + #echo "mount -t cgroup cgroup /dev/cgroup/cpu -o cpu" | tee -a $FICHERO
 + #echo "mkdir -m 0777 /dev/cgroup/cpu/user" | tee -a $FICHERO
 + #echo "echo \"/usr/local/sbin/cgroup_clean\" > /dev/cgroup/cpu/release_agent" | tee -a $FICHERO
 + #echo "#====================================" | tee -a $FICHERO
 +else
 + echo "It seems the patch is already included in $FICHERO"
 +fi
 +
 +echo ""
 +echo -e $YELLOW"Making [${FICHERO}] executable"$ENDCOLOR
 +echo ""
 +sudo chmod +x $FICHERO
 +
 +FICHERO="/usr/local/sbin/cgroup_clean"
 +echo ""
 +echo -e $YELLOW"Creating [${FICHERO}]..."$ENDCOLOR
 +echo ""
 +if [ ! -e $FICHERO ];
 +then
 + echo "#!/bin/sh" | tee $FICHERO
 + echo "if [ \"\$*\" != \"/user\" ]; then" | tee -a $FICHERO
 + echo "rmdir /dev/cgroup/cpu/\$*" | tee -a $FICHERO
 + echo "fi" | tee -a $FICHERO
 +
 +else
 + echo "File $FICHERO already exists."
 +fi;
 +
 +echo ""
 +echo -e $YELLOW"Making [${FICHERO}] executable"$ENDCOLOR
 +echo ""
 +sudo chmod +x $FICHERO
 +
 +echo "DONE. The patch has been applied. Restart your computer..."
 +
 +}
 +#-----------------------------------------------------------------------------
 +
 +# Comprobar que eres usuario root
 +if [ $USER != root ]; then
 +  echo -e $RED"Error: you need to run this script as root."
 +  echo -e $YELLOW"Exiting..."$ENDCOLOR
 +  exit 0
 +fi
 +
 +# Parchear el Sistema
 +PARCHEAR
 +
 +# end of parche.sh
 +</file>
howtos/alternative_to_the_200_lines_kernel_patch_that_does_wonders_which_you_can_use_right_away.txt · Last modified: d/m/Y H:i (external edit)