version 1.1 del script kernel compiler
corrigo un error gramatical al preguntar si quieres instalarlo al HDD
corregido un par de bugs sin importancia...al final del script busca las variables
TAG
BUILD
y no estaban definidas
#!/bin/bash
# Script by USUARIONUEVO @ www.seguridadwireless.net
# Version del script
SCRIPT_VERSION=1.1
# Colores
CIERRE=${CIERRE:-"[0m"}
ROJO=${ROJO:-"[1;31m"}
VERDE=${VERDE:-"[1;32m"}
CYAN=${CYAN:-"[1;36m"}
AMARILLO=${AMARILLO:-"[1;33m"}
BLANCO=${BLANCO:-"[1;37m"}
ROSA=${ROSA:-"[1;35m"}
# Bienvenida
clear
echo $ROSA
echo "
__ __ __ _____ _ __
/ //_/__ _______ ___ / / / ___/__ __ _ ___ (_) /__ ____
/ ,< / -_) __/ _ \/ -_) / / /__/ _ \/ ' \/ _ \/ / / -_) __/
/_/|_|\__/_/ /_//_/\__/_/ \___/\___/_/_/_/ .__/_/_/\__/_/
/_/ "
echo ""
echo ""$AMARILLO" ##### By USUARIONUEVO @ www.seguridadwireless.net #####"$CIERRE""
echo ""$VERDE" ##### For wifislax & awireless slackware based systems #####"$CIERRE""
echo ""
sleep 5
# Sin internet el script no continua al no poder saber version online ni descargarla
# Comprobar conexion by geminis_demon @ www.seguridadwireless.net
# Se hace un ping a google si no hay respuesta se determina que no hay internet y se sale.
# Si hay respuesta al ping el script continuara.
echo "$CYAN"Comprobando si hay acceso a internet"$CIERRE..."
if [ "$(ping google.com -c1 2>/dev/null)" ]; then
echo "$VERDE"Tengo internet"$CIERRE ... $BLANCO"la tarea continuara..."$CIERRE"
echo ""
else
echo "$ROJO"No tengo internet"$CIERRE ... $BLANCO"el script se cerrara..."$CIERRE"
echo ""
sleep 5
exit 0
fi
# Variables
# Definimos arquitectura del sitema anfitrion
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
# Cantidad de nucleos del sistema usables para make -j
NUCLEOS=$(grep -c \^processor /proc/cpuinfo)
# Nombre del paquete
PRGNAM=linux
# Numero de modulo xzm
M0DNUM=000
# Nombre de modulo xzm
MODNAM=Kernel
# Numero de build
BUILD=1
# Numero de Kernel completo instalado en el sistema
KERNEL_SISTEMA=`uname -r | cut -d '-' -f1`
# Rama de kernel eliminando del numero de kernel la parte final por ejemplo 3.12.4 se cortaria a 3.12
RAMA=`uname -r | cut -d '-' -f1 | cut -d "." -f-2`
# Pagina web de kernel org donde se buscara actualizacion sobre la misma rama de nuestro kernel
WEB=https://www.kernel.org/
# Grepeando numero kernel mas nuevo para nuestra rama en kernel.org
KERNEL_ONLINE=`curl -s $WEB | grep linux-$RAMA.* | cut -d 'x' -f 4 | cut -d '-' -f 2 | cut -d " " -f 2 | cut -d "t" -f1 | sed 's/.$//g'`
# Web completa para descargar el source code
DESCARGA=https://www.kernel.org/pub/linux/kernel/v3.x/linux-$KERNEL_ONLINE.tar.xz
# Comparamos version sistema con version online si son iguales se sale del script
if [ $KERNEL_SISTEMA = $KERNEL_ONLINE ]; then
echo ""$VERDE"No hay updates para la rama de kernel "$AMARILLO"$RAMA"$CIERRE""
sleep 3
echo ""$AMARILLO"Bye Bye."
echo ""
sleep 3
exit 0
fi
# Se comprueba si el archivo a descargar ya existe por pruebas anteriores y evitar descargar de nuevo
# Entramos a la ruta de trabajo
cd /usr/src/
# Si el paquete no existe se descargara de internet
if [ ! -f linux-$KERNEL_ONLINE.tar.xz ]; then
echo ""
echo "$CYAN"Descargando sources de $PRGNAM-$KERNEL_ONLINE "$CIERRE"
sleep 5
# Bajamos el kernel
wget $DESCARGA
fi
# Descomprimir en /usr/src
# Si existen restos de una prueba anterior seeliminaran
rm -rf /usr/src/$PRGNAM-$KERNEL_ONLINE &>/dev/null
# Descomprimir fichero
echo ""
echo "$VERDE"Descomprimiendo ..."$CIERRE"
sleep 5
tar xvf $PRGNAM-$KERNEL_ONLINE.tar.xz
# Entrar a la ruta del kernel descomprimido
cd $PRGNAM-$KERNEL_ONLINE
###################################
### Generamos parche wireless ####
###################################
cat > Negative-channel-multi.patch << "EOF"
--- a/net/wireless/chan.c 2013-08-29 18:47:51.000000000 +0200
+++ b/net/wireless/chan.c 2013-08-31 22:20:45.014734447 +0200
@@ -441,4 +441,2 @@
return -EOPNOTSUPP;
- if (!cfg80211_has_monitors_only(rdev))
- return -EBUSY;
--- a/net/mac80211/cfg.c Tue May 28 16:57:23 2013 -0400
+++ b/net/mac80211/cfg.c Tue May 28 17:16:15 2013 -0400
@@ -801,3 +801,4 @@
}
- } else if (local->open_count == local->monitors) {
+ // Patch: Always allow channel change, even if a normal virtual interface is present
+ } else /*if (local->open_count == local->monitors)*/ {
local->_oper_channel = chandef->chan;
--- a/net/mac80211/tx.c 2013-08-29 18:47:51.000000000 +0200
+++ b/net/mac80211/tx.c 2013-08-31 22:35:10.386721602 +0200
@@ -1454,7 +1454,10 @@
}
}
- ieee80211_set_qos_hdr(sdata, skb);
+ // Don't overwrite QoS header in monitor mode
+ if (likely(info->control.vif->type != NL80211_IFTYPE_MONITOR)) {
+ ieee80211_set_qos_hdr(sdata, skb);
+ }
ieee80211_tx(sdata, skb, false, band);
}
--- a/drivers/net/wireless/rtl818x/rtl8187/dev.c 2013-08-29 18:47:51.000000000 +0200
+++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c 2013-08-31 22:50:38.266707828 +0200
@@ -252,9 +252,14 @@
flags |= RTL818X_TX_DESC_FLAG_NO_ENC;
flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24;
- if (ieee80211_has_morefrags(tx_hdr->frame_control))
- flags |= RTL818X_TX_DESC_FLAG_MOREFRAG;
if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
+ if (ieee80211_has_morefrags(tx_hdr->frame_control))
+ {
+ // If info->control.vif is NULL it's mostly likely in monitor mode
+ if (info->control.vif != NULL && info->control.vif->type != NL80211_IFTYPE_MONITOR) {
+ flags |= RTL818X_TX_DESC_FLAG_MOREFRAG;
+ }
+ }
flags |= RTL818X_TX_DESC_FLAG_RTS;
flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19;
rts_dur = ieee80211_rts_duration(dev, priv->vif,
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3588,9 +3589,9 @@ static int ieee80211_cfg_get_channel
if (chanctx_conf) {
*chandef = chanctx_conf->def;
ret = 0;
- } else if (local->open_count > 0 &&
+ } else /*if (local->open_count > 0 &&
local->open_count == local->monitors &&
- sdata->vif.type == NL80211_IFTYPE_MONITOR) {
+ sdata->vif.type == NL80211_IFTYPE_MONITOR)*/ {
if (local->use_chanctx)
*chandef = local->monitor_chandef;
else
EOF
# Aplicamos parche si hay error se parara el proceso ( exit 1 )
echo ""
echo ""$VERDE"Aplicando parche wireless para channel -1 "$BLANCO"..."$CIERRE""
sleep 5
patch -p1 < Negative-channel-multi.patch || exit 1
# Si el sistema anfitrion es wifislax se baja el logo para kernel
# Buscamos si estamos en wifislax
ANFITRION=`cat /etc/*version | grep wifislax |cut -d " " -f 1`
# Declaramos el tag para el name del modulo xzm
if [ $ANFITRION = wifislax ]; then
TAG=sw
else
TAG=awireless
fi
# Definimos regla si es wifislax, solo en ese caso ..baja el logo del ftp
# Si el ftp no responde en 10 segundos el script continuara
# Codigo parcial copiado de wpspingenerator,regla escrita por geminis_demon @ www.seguridadwireless.net
if [ $ANFITRION = wifislax ]; then
echo ""
echo ""$CYAN"Detectado sistema wifislax ...intentando descargar logo del ftp..."$CIERRE""
[ ! "$(timeout -s SIGTERM 10 wget http://www.downloadwireless.net/Logo_Kernel_Wifislax/logo_linux_clut224.ppm)" ] &&
echo ""
fi
# Verificamos si finalmente el logo se bajo y en caso afirmativo , lo moveremos a su sitio
if [ -f logo_linux_clut224.ppm ]; then
echo ""
echo ""$AMARILLO"Fichero de logo detectado ..moviendo a /usr/src/$PRGNAM-$KERNEL_ONLINE/drivers/video/logo"
echo ""
mv logo_linux_clut224.ppm /usr/src/$PRGNAM-$KERNEL_ONLINE/drivers/video/logo &>/dev/null
fi
# Movemos si existe el fichero .config del kernel de sistema
# Para reautilizarlo usando make oldconfig
if [ -f /usr/src/$PRGNAM-$KERNEL_SISTEMA/.config ]; then
echo ""$VERDE"Se detecto un fichero config del kernel de sistema actual ...moviendo para reutilizarlo..."$CIERRE""
cp -r /usr/src/$PRGNAM-$KERNEL_SISTEMA/.config /usr/src/$PRGNAM-$KERNEL_ONLINE/.config &>/dev/null
fi
# Esta variable avisa si no hay fichero .config
# Verificamos que existe un fichero .config
if [ -f /usr/src/$PRGNAM-$KERNEL_ONLINE/.config ]; then
echo "$VERDE"
echo "Se detecto un fichero .config , la tarea continua"$CIERRE" .... "
sleep 3
else
echo "$ROJO"
echo "No se ha detectado el fichero .config $AMARILLO PRESIONE ENTER $ROJO si desea continuar$CIERRE... "
echo "$CYAN"
echo "Si no hay fichero config copialo antes de pulsar enter"
echo "Si vas a configurarlo desde cero ... entonces dale a enter sin copiar un .config $CIERRE."
read junk
fi
# Descargamos version de aufs correspondiente a nuestra rama y aplicamos
# Indicamos version aufs igual a rama de kernel
# Ruta donde se enviara patch de aufs que es a las sources del kernel
DEST=/usr/src/$PRGNAM-$KERNEL_ONLINE/aufs$RAMA.patch
# Creamos parche y aplicamos
echo ""
echo ""$VERDE"Creamos y aplicamos el parche aufs "$BLANCO"..."$CIERRE""
sleep 3
mkdir /tmp/aufs$$
cd /tmp/aufs$$
git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git aufs3-standalone.git
cd aufs3-standalone.git
git checkout origin/aufs$RAMA
mkdir ../a ../b
cp -r {Documentation,fs,include} ../b
cd ..
diff -rupN a/ b/ > $DEST
cat aufs3-standalone.git/aufs3-base.patch >> $DEST
cat aufs3-standalone.git/aufs3-standalone.patch >> $DEST
cat aufs3-standalone.git/aufs3-kbuild.patch >> $DEST
cat aufs3-standalone.git/aufs3-mmap.patch >> $DEST
cat aufs3-standalone.git/aufs3-loopback.patch >> $DEST
rm -r /tmp/aufs$$
# aplicamos parche aufs
cd /usr/src/$PRGNAM-$KERNEL_ONLINE
patch -f -p1 -i aufs$RAMA.patch
# Compilamos el kernel
make oldconfig
make xconfig
# Comienza la compilacion del kernel
make -j$NUCLEOS
# Compilados los modulos del kernel
make modules -j$NUCLEOS
# Variable que se consultara despues de configurar kernel
# Comprobar si es un kernel PAE
if [ -z "`grep -i 'CONFIG_HIGHMEM64G=y' .config`" ]; then
PAE=""
else
PAE="PAE-"
fi
# Creamos la tuta de destina a instalar el kernel
mkdir -p $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG
make modules_install INSTALL_MOD_PATH=$HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG
# Instalamos las cabeceras kernel-headers
# Esto se cumplira solo si el anfitrion es wifislax
if [ $ANFITRION = wifislax ]; then
make headers_install ARCH=i386 INSTALL_HDR_PATH=$HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr
rm -r $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr/include/*/.install
rm -r $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr/include/*/..install.cmd
fi
# Copiamos vmlinuz a escritorio
if [ -z "`grep -i 'CONFIG_HIGHMEM64G=y' .config`" ]; then
VMLINUZ="vmlinuz"
else
VMLINUZ="vmlinuz2"
fi
cp /usr/src/$PRGNAM-$KERNEL_ONLINE/arch/x86/boot/bzImage $HOME/Desktop/$VMLINUZ &>/dev/null
# Generamos kernel sources recortadas
mv System.map ../
make clean
mv ../System.map .
make prepare
make scripts
rm -Rf Documentation drivers fs net sound firmware
ls -1d arch/* | grep -v x86 | xargs rm -Rf
ls -1d include/* | grep asm- | grep -v x86 | grep -v generic | xargs rm -Rf
cp include/generated/* include/linux &>/dev/null
# Preparamos creacion de xzm
mkdir -p $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr/src
cp -r /usr/src/$PRGNAM-$KERNEL_ONLINE $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr/src
# Realizamos limpieza
rm $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr/src/$PRGNAM-$KERNEL_ONLINE/kernel.txt &>/dev/null
rm $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr/src/$PRGNAM-$KERNEL_ONLINE/Negative-channel-multi.patch &>/dev/null
rm $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr/src/$PRGNAM-$KERNEL_ONLINE/aufs$RAMA.patch &>/dev/null
rm aufs$RAMA.patch &>/dev/null
rm $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr/src/$PRGNAM-$KERNEL_ONLINE/.config.old &>/dev/null
# Esta regla eliminara la carpeta firmwares del kernel si el sistema es wifislax
# Por que usa una script que baja todos los firmwares desde el git
if [ $ANFITRION = wifislax ]; then
rm -Rf $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/lib/firmware
fi
# Esta regla eliminara las crippled sources si el anfitrion no es wifislax
if [ ! $ANFITRION = wifislax ]; then
rm -r $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG/usr
fi
# Creamos xzm de kernel + sources
dir2xzm $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG.xzm
mv $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG.xzm $HOME/Desktop/$M0DNUM-$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG.xzm
# Limpiamos
rm -Rf $HOME/Desktop/$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG
# Comprobamos si es wifislax y si esta en livecd para intentar instalar el kernel a sistema
if [ -d /mnt/live ]; then
echo "$AMARILLO"
echo "Detectado modo live ...el nuevo kernel no se instalara a sistema"
echo "$VERDE"
echo "Bye Bye"
exit 0
fi
# Si el sistema esta en hdd y no es wifislax se sale
if [ ! $ANFITRION = wifislax ]; then
echo "$AMARILLO"
echo "El sistema esta en HDD ...pero no es wifislax,no se instalara el nuevo kernel"
echo "$VERDE"
echo "Bye Bye"
exit 0
exit 0
fi
# Si no salio en las dos opciones anteriores es un wifislax en hdd se da opcion de instalar el kernel en sistema
echo ""
echo ""$ROSA"Detectado wifislax instalado en HDD..."$CIERRE""
echo ""
echo ""$AMARILLO"Pulsa ENTER si quieres instalar el nuevo kernel,si no te interesa cierra el scipt."$CIERRE""
read junk
echo ""
echo ""$VERDE"Instalando Kernel $KERNEL_ONLINE en sistema ..."$CIERRE""
cp -r $HOME/Desktop/$VMLINUZ /boot/$VMLINUZ-$KERNEL_ONLINE-$PAE$ANFITRION
dir2xzm $HOME/Desktop/$M0DNUM-$PAE$MODNAM-$KERNEL_ONLINE-$ARCH-$BUILD$TAG.xzm /
update-grub
echo ""
echo ""$CYAN"Instalacion completada ..."$CIERRE""
echo ""
echo ""$AMARILLO"Bye Bye"$CIERRE""