miércoles, 25 de agosto de 2010

QMAIL - de tcp.smtp a tcp.smtp.cdb

QMAIL usa el fichero  /etc/tcp.smtp.cdb  Si se hace un cambio en /etc/tcp.smtp hay que hacer lo siguiente para compilar el cdb:

cat /etc/tcp.smtp | tcprules /etc/tcp.smtp.cdb /tmp/rules

miércoles, 18 de agosto de 2010

gentoo - genkernel modules

Cada vez que compile un nuevo núcleo o recompile el actual, necesitará reinstalar los módulos del núcleo de nVidia. Una forma fácil de seguir la pista de los módulos instalados por los ebuilds (como nvidia-drivers es instalar sys-kernel/module-rebuild. Una vez lo haya instalado, simplemente ejecute module-rebuild populate para llenar su base de datos con una lista de paquetes que deben reconstruirse. Una vez haya terminado de compilar o recompilar un núcleo, simplemente ejecute module-rebuild rebuild para reconstruir los controladores para su nuevo núcleo. 

martes, 17 de agosto de 2010

Openbox & sesiones ssh - ssh-agent ssh-add -

El problema que tenia es que cuando arrancaba el agente de ssh (eval `ssh-agent`) y ssh-add en un terminal, las variables de entorno que hacen referencia a la ubicación de los archivos y pid no eran visibles para otras sesiones de terminal y por lo tanto me pedia de nuevo hacer ssh-add en cada consola.

SSH_AUTH_SOCK=/tmp/ssh-xBlFuc3166/agent.3166; export SSH_AUTH_SOCK;
SSH_AGENT_PID=3167; export SSH_AGENT_PID;

La solución que me ha funcionado en openbox es añadir en el fichero .xinitrc eval `ssh-agent -s` para que qeuede así:

eval `ssh-agent -s`
exec ck-launch-session dbus-launch openbox-session

jueves, 5 de agosto de 2010

Wrapper sobre ncsvc cliente vpn juniper

Nueva forma de conectarme sin usar el cliente de juniper network connect. Un sencillo wrapper que ahorra usar java. Solo es necesario el binario de ncsvc y ejecutar el script como root.


#!/bin/bash
# Wrapper sobre ncsvc.
set +o posix

ok() { echo -ne "\e[32m#\n#\t$1\n#\e[m\n"; }
nk() { echo -ne "\e[31m#\n#\t$1\n#\e[m\n"; exit 1; }

USER="usuario"
HOST="hostvpn.dominio.com"
REALM="sistemas"
[ $HOST ] && [ $REALM ] || nk "Falta especificar HOST y/o REALM en el script."

PATH=$PATH:$(dirname $0)
ok "Verificando binarios wvdial pppd y grep:"
which ncsvc pgrep openssl kill || nk "Faltan binarios!"
[ $(uname -m) = "x86_64" ] && ok ": Se necesita comp. 32 bits. Arch: pacman -S lib32-glibc lib32-gcc-libs lib32-zlib"

pgrep ncsvc > /dev/null && {
ok "Procesos ncscv corriendo, los mato..."
ncsvc -K || for i in `pgrep ncsvc`; do kill -9 $i; done
ok "OK!"
} || {
[ $USER ] || { ok "Usuario: "; read -r USER; }
[ $USER ] || nk "El usuario no puede ser nulo!"
ok "Conectando..."
ncsvc -u $USER -h $HOST -r $REALM -f <(openssl x509 -in <(openssl s_client -connect secure.dominio.com:443 /dev/null | sed -n '1h;1!H;${;g;s/.*\(-----BE.*TE-----\).*/\1/p;}') -outform der)    reset } 
Gracias Oscar por esta solucion :)

miércoles, 4 de agosto de 2010

Powermt Management

Un pequeño script para escanear las HBAs y descubir los targets que hay asignados

lun_scan.sh



#!/bin/sh
#
#/*******************************************************************
# * This file is part of the Emulex Linux Device Driver for *
# * Fibre Channel Host Bus Adapters. *
# * Copyright (C) 2003-2005 Emulex. All rights reserved. *
# * EMULEX and SLI are trademarks of Emulex. *
# * www.emulex.com *
# * *
# * This program is free software; you can redistribute it and/or *
# * modify it under the terms of version 2 of the GNU General *
# * Public License as published by the Free Software Foundation. *
# * This program is distributed in the hope that it will be useful. *
# * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
# * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
# * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
# * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
# * TO BE LEGALLY INVALID. See the GNU General Public License for *
# * more details, a copy of which can be found in the file COPYING *
# * included with this package. *
# *******************************************************************/
#
# scripts/lun_scan Rev : 1.2
# This script is provided by Emulex to use with its 7.x and 8.x linux device
# drivers for Light Pulse Fibre Channel adapters.
#
# This script performs a scan on either specific lpfc HBAs or on all
# lpfc HBAs. When scanning an HBA, all discovered targets, and all
# luns will be probed.
#
#
# USAGE: The script is invoked with at least 1 argument. The arguments
# specify either the SCSI Host numbers corresponding to the specific
# lpfc HBA that are to be scanned, or the keyword "all" which indicates
# that all lpfc HBAs are to be scanned.
#

VERSION="1.2"
OS_REV=`uname -r | cut -c1-3`

usage()
{
echo ""
echo "Usage: lun_scan [ <#> [<#>] | all ]"
echo " where "
echo " <#> : is a scsi host number of a specific lpfc HBA that is to"
echo " be scanned. More than 1 host number can be specified. "
echo " all : indicates that all lpfc HBAs are to be scanned."
echo ""
echo " Example:"
echo " lun_scan all : Scans all lpfc HBAs"
echo " lun_scan 2 : Scans the lpfc HBA with scsi host number 2"
echo " lun_scan 2 4 : Scans the lpfc HBAs with scsi host number 2 and 4"
echo ""
echo " Warning: Scanning an adapter while performing a tape backup should"
echo " be avoided."
echo ""
}

abort_exit() {
echo ""
echo "Error: Cannot find an lpfc HBA instance with scsi host number : $host"
echo "... Aborting lun_scan."
echo ""
exit 2
}

# Validate argument list
if [ $# -eq 0 -o "$1" = "--help" -o "$1" = "-h" ] ; then
usage
exit 1
fi

# Get list of lpfc HBAs to scan
hosts=$*;

if [ ${OS_REV} = 2.4 ]; then
lowhost=0
ha=`ls /proc/scsi/lpfc/? 2> /dev/null | cut -f5 -d'/'`
hb=`ls /proc/scsi/lpfc/?? 2> /dev/null | cut -f5 -d'/'`
hc=`ls /proc/scsi/lpfc/??? 2> /dev/null | cut -f5 -d'/'`
all_hosts="$ha $hb $hc"
lowhost=`echo $all_hosts | sed "s/ .*//"`
else
all_hosts=`ls -1 -d /sys/bus/pci/drivers/lpfc/*/host* | sed -e "s/.*host//"`
fi

# If all option is used get all the lpfc host numbers.
if [ "$hosts" == "all" ] ; then
hosts="$all_hosts"
fi

if [ ${OS_REV} = 2.4 ]; then

for host in $hosts ; do
# Convert host number to lpfc instance number.
instance=`expr $host - $lowhost`

if [ ! -e /proc/scsi/lpfc/$host ] ; then
abort_exit
fi

echo Scanning lpfc$instance, scsi host number : $host;

max_lun=256

targets=`cat /proc/scsi/lpfc/$host | grep 'lpfc*t*' | cut -f2 -d't' | cut -f1 -d' '`

for target in $targets ; do
# Convert target ID to decimal from Hex format
let "dec_target = 0x$target"
echo " Scanning Target Id $dec_target..."
for ((lun=0; lun<$max_lun; lun++)) ; do echo "scsi add-single-device $host 0 $dec_target $lun" >/proc/scsi/scsi
done
done
done

else

for host in $hosts ; do
if [ ! -e /sys/bus/pci/drivers/lpfc/*/host$host ] ; then
abort_exit
fi

echo Scanning lpfc HBA instance with scsi host number : $host;
echo '- - -' > /sys/class/scsi_host/host$host/scan
done

fi

echo ""
Ejecutamos el script:
lun_scan.sh all

Hacemos que powermt vea la nueva lun

powermt check
powermt config
powermt save

Mostramos lo que ve powermt
powermt display dev=all