Sunday, 10 October 2010

xenconsole-ng

Hi there, long time I haven't used this blog!!

I'll explain how to create an Ubuntu 10.04 installation on a XenServer without using XenConsole at all!!

First of all, I'll assume you already have XenServer 5.6.0 or newer installed, and also the linux tools templates.

Then, we will create the template for the network install of our Ubuntu 10.04. Thanks to Anthony Francis for his post and his script makeubuntu.sh

Basically what this script does is to create a new template using xe commands based on the Debian Lenny template already existent.

Once done, we can create our own installation by issuing the following commands:


VM_NAME="TheVMNameIWant"
VM_UUID=$(xe vm-install new-name-label=$VM_NAME template="Ubuntu 10.04 (32-bit)")
PIF_UUID=$(xe network-list bridge=xenbr0 --minimal)
VIF_UUID=$(xe vif-create network-uuid=PIF_UUID vm-uuid=$VM_UUID device=0)
xe vm-param-set uuid=$VM_UUID other-config:disable_pv_vnc=1 #To disable automatic XenCenter console. Be careful as if we do not do this, we will experience insane behaviors when connecting through SSH


Now you already have your new fresh vm installation, but waiting to be started and controlled so everything gets installed. To do so you can issue these commands or better, use my scripts at the bottom of this post ;)


#so now start the new VM
xe vm-start uuid=$VM_UUID
#search for the new domain id
DOM_ID=$(xe vm-list params=dom-id uuid=$VM_UUID --minimal)
#and connect to it
/usr/lib/xen/bin/xenconsole $DOM_ID


Scripts section:

cat << EOF >/root/bin/xenconsole-ng
#!/bin/bash

RUNNING_VM_NAMES=$(xe vm-list power-state=running is-control-domain=false params=name-label --minimal)

echo "List of running virtual machines to attach to:"
i=0
for vmn in $RUNNING_VM_NAMES
do
echo "$i - $vmn"
i=$(expr $i + 1)
done
i=$(expr $i - 1)
echo -n "Select a number (0-$i): "
read s

i=0
for vmn in $RUNNING_VM_NAMES
do
if [[ $i -eq $s ]] ;
then
echo -n "Searching vm $i ($vmn) ... "
VM_UUID=$(xe vm-list name-label=$vmn params=uuid --minimal)
DOM_ID=$(xe vm-list name-label=$vmn params=dom-id --minimal)
if [[ -z "$DOM_ID" ]]
then
echo "FATAL!! No Domain found for that vm!"
exit -2
else
echo "(if nothing happends press enter key)"
echo "Remember, Ctrl+] on guest or xenconsole-dettach-ng on host escapes this console"
/usr/lib/xen/bin/xenconsole $DOM_ID 2>/dev/null
reset
fi
exit 0
else
i=$(expr $i + 1)
fi
done
echo "Virtual Machine not found!"
exit -1
EOF

cat << EOF > /root/bin/xenconsole-dettach-ng
#!/bin/bash

RUNNING_VM_NAMES=$(xe vm-list power-state=running is-control-domain=false params=name-label --minimal)

ATTACHED_CONSOLES=$(ps aux | grep "/xenconsole " | sed "s/ */ /g" | cut -f 12 -d " ") #field 2=pid, 12=dom_id

echo "List of running virtual machines to dettach from:"
i=0
avmn=""
avmp=""
for vmn in $RUNNING_VM_NAMES
do
DOM_ID=$(xe vm-list name-label=$vmn params=dom-id --minimal)

if [[ -z "$(echo $ATTACHED_CONSOLES | grep $DOM_ID)" ]]
then
echo "$vmn not attached"
else
echo -n "$vmn attached with pid "
PID=$(ps aux | grep "/xenconsole $DOM_ID" | sed "s/ */ /g" | cut -f 2 -d " ")
echo "$PID"
avmn="$avmn $vmn"
avmp="$avmp $PID"
fi
i=$(expr $i + 1)
done

i=0
for vmn in $avmn
do
echo "$i - $vmn"
i=$(expr $i + 1)
done
i=$(expr $i - 1)
echo -n "Select a number (0-$i): "
read s

i=0
for pid in $avmp
do
if [[ $i -eq $s ]] ;
then
echo -n "Dettaching console $i ($pid) ..."
kill -9 $pid
echo " Done!"
exit 0
else
i=$(expr $i + 1)
fi
done
echo "Console not found!"
exit -1
EOF


Sure they can be polished, or even completely rewritten, but they work for me and I just wanted to share with you all ;) and have them for the records :P

Thanks also to this document site where I finally found a way to connect to the text-based console and much much more information ;)

Of course, you can alo use OpenXenManager for Linux or XenCenter for Windows, but my way is more geeky ;)

Monday, 31 May 2010

Migración IMAP

Tanto si vais a cambiar de servidor de correo, como si queréis migrar a gmail o a Google Apps, aquí va una receta de cómo migrar todo el correo de un lado al otro usando IMAP.

En Gmail o Google Apps, las etiquetas se tratan como carpetas desde una conexión IMAP. Lo primero es habilitar la conexión IMAP en la configuración de GMail.

Luego usamos un comando de este estilo:

imapsync --host1 imap.server.org \
--user1 user@server.org \
--passfile1 ./passfile1 \
--host2 imap.gmail.com \
--port2 993 --user2 user@gmail.com \
--passfile2 ./passfile2 --ssl2 \
--split1 100 --split2 100 \
--buffersize 18192000 --maxsize 18192000 \
--noauthmd5 \
--folderrec ElDirQueSea \
--syncinternaldates \
--authmech1 LOGIN --authmech2 LOGIN \
--useheader 'Message-Id' --skipsize

Explicación de la falla:
Los primeros parámetros son obvios, datos de configuración de la conexión IMAP, que para el caso de GMail es especial ya que requiere SSL (de ahí el --ssl2) y no soporta authmd5 (de ahí el --noauthmd5). En los passfiles se guardan en texto plano los passwords y listos. Tmb se puede meter el pass directamente en la línea de comandos pero es un poco más salvaje a nivel de seguridad ya que al fichero siempre le puedes meter un chmod 600.
Después --syncinternaldates se asegura de que los correos vayan con su fecha, y no con la fecha de la migración, que siempre es interesante.
Los --buffersize 18192000 y --maxsize 18192000 lo que hacen es ampliar la memoria de imapsync, y limitar el tamaño del mensaje máximo para evitar que pete por out-of-memory, muy típico de imapsync.
Imapsync sincronizará la etiqueta o carpeta que le pongas en el --folderrec de manera rec-ursiva, jeje.
La última línea es muy importante si estás usando GMail, ya que de lo contrario vuelve a copiar los correos ya existente, que si bien no es problema por los duplicados ya que GMail lo detecta y elimina duplicados, sí es un engorro pq estás ejecutando el comando 20.000 horas de más, así que --useheader 'Message-Id' --skipsize obligado! ;)
Y por último los splits ... la verdad no he notado diferencia de velocidad, pero según reza la ayuda es el número de peticiones simultaneas a servidor origen y servidor destino respectivamente ... o eso creo :P

Por si sirve de ayuda, yo primero he hecho un --justfolders para que cree la estructura de directorios/etiquetas, y luego he creado un fichero de texto con cada folder en una línea. Luego con lo siguiente he ido saltando de folder en folder para evitar que un fallo me pare el proceso entero:

while read i
do
imapsync bla bla bla ... --folder $i
done < folder.list.txt

Ale, felices migraciones ;)

Links de interés:
http://www.thamtech.com/blog/2008/03/29/gmail-to-google-apps-email-migration/
http://www.linux-france.org/prj/imapsync/FAQ
http://wiki.zimbra.com/wiki/Guide_to_imapsync

Monday, 10 May 2010

Trust Slimline Sketch Tablet en Ubuntu Karmic (9.10)

Pues eso, me he comprado por fin, después de varios años de deseo, una tableta digitalizadora Trust Slimline Sketch Tablet. Y como uno trabaja en Ubuntu ... pues me ha tocado ver cómo hacerla ir. Afortunadamente me he encontrado con este post que paso a traducir/resumir/adaptar.

http://jan.varho.org/blog/computers/linux-computers/trust-slimline-sketch-tablet-on-ubuntu-karmic/

Primero instalamos el wizardpen
#> sudo add-apt-repository ppa:doctormo/xorg-wizardpen
#> sudo aptitude update
#> sudo aptitude install xserver-xorg-input-wizardpen

Después creamos el fichero de configuración
#> sudo gedit /etc/hal/fdi/policy/99-x11-wizardpen.fdi






wizardpen
true
1688
2831
30748
30619
30748
30619





Y por último calibramos nuestra tableta ejecutando este comando y sustituyendo en el fichero .fdi anterior.
#> sudo wizardpen-calibrate /dev/input/by-id/usb-UC-LOGIC_Tablet_WP8060U-event-mouse

Cada vez que retoquemos el .fdi tenemos que reconectar la tableta para que la coja.

Y ee e e eeesstooo es toooodo amigoooos ;)

Tuesday, 11 August 2009

Instalando el TPTP en Ubuntu 8.04

Necesito hacer un profile de mi aplicación en Java, así que me he decidido a poner en marcha el TPTP para eclipse. El tema es que no va ... y es por una de esas chorradas que te pasas 2h mirando.

Tu lo instalas normalmente, pero luego da errores, no rellena la nueva pestaña de monitors, etc. Es, símplemente, pq le falta un paquete a tu sistema ...

http://packages.ubuntu.com/dapper/i386/libstdc++2.10-glibc2.2/download

La información original útil después de tanto marear la perdiz la he obtenido de:
http://weblogs.java.net/blog/felipeal/archive/2008/06/configuring_ecl.html
y el link al paquete que no está en los repositorios, de:
http://ubuntuforums.org/archive/index.php/t-104778.html

Espero que mejoren el tema pq ... tiene guasa tener que perder tanto tiempo ... en fin, al menos ha valido la pena pq me está dando información muy valiosa.

Un saludo!

Saturday, 8 August 2009

Pelea con un Huawei E156G en UK ... VICTORIA!

A las buenas. Hoy me he tenido que pegar con un modem 3G Huawei E156G, que como dice la propaganda, funciona sólo con conectarlo ... sí, claro, si usas windoze o mac ... pero para linux q t den dos duros!

Total que al final, y con la ayuda de un tlf con inet, he conseguido hacerlo así de simple:

Configuración "inteligente" del modem ... luego la modificaremos ...
#>sudo wvdialconf

Modificación de la inteligencia ... ;)
#>sudo joe /etc/wvdial.conf

[Dialer Defaults]
Modem = /dev/ttyUSB1

[Dialer three]
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Stupid Mode = 1
Modem Type = Analog Modem
; Phone =
Phone = *99\#
ISDN = 0
username = username
password = password
Dial Command = ATDT
; Password =
;New PPPD = yes
; Username =
Modem = /dev/ttyUSB0
Baud = 466600
Init4 = AT+CGDCONT=1,"IP","three.co.uk"

Llamada
#>sudo wvdial three

Ojo que Firefox inicia en "offline" si no tiene algún eth del NetworkManager en marcha ... ;)

Basado en:
TODO: PONER LINK!

Ale, a disfrutar!

Monday, 20 July 2009

Para esos que tienen que mantener mil y un Ubuntus ...

Cuando tu Ubuntu llega al fin de sus días ...

Sí, esto pasa, y más de lo que nos gustaría ... En https://wiki.ubuntu.com/Releases podemos ver cuándo ... es como la crónica de una muerte anunciada ... snif snif ...
Cuando llegue el día nuestra distro desaparecerá de su habitual lugar en http://archive.ubuntu.com/ubuntu/dists/ para dejar lugar a las nuevas generaciones ... es triste ... pero es ley de vida ... y de los de Ubuntu tmb vaya!

Cuando llega ese día ... o bien te pones triste, te rearmas de valor, y actualizas con uno de los 30mil posts que hay por internet explicando el proceso, o bien ... te resignas y no instalas nada más ... o ... habrá otra solución?

Pues sí, señoras, señores, perros, gatos, y demás usuarios de Ubuntu, símplemente cambiando nuestro maravilloso /etc/apt/sources.list y sustituyendo todas las ocurrencias de es.archive, o fr.archive, o us.archive, o símplemente archive en las URLs de los repositorios por old-releases (incluyendo las URLs de security ... que tmb caducan ... manda webs) conseguimos que nuestro flamante sistema vuelva a la vida ... un poco carrasposete y tosiendo de "vellet" pero weno ... funcionando ... que no es poco ...

Así que a rezarle a san http://old-releases.ubuntu.com/ubuntu/dists/ que con tanto cariño nos proporciona versiones retrasadas (en el tiempo, que no subnormales) de Ubuntu.

Weeeeee, un poblema menoz!
Salutem!

Sunday, 29 March 2009

imagine...

Just imagine, it is early in the morning....
It is 6 O'clock, half an hour before you normally get up. The thermostat in the bedroom already informs the boiler to adjust the temperature of the bedroom and bathroom to a pleasant 21°C. At twenty past six the coffee machine turns itself on, while the towel and floor in the bathroom are warmed.
At six thirty your favourite morning radio programme can be heard through the loudspeakers in your bedroom. Simultaneously the bedroom lamp turns on at 5% capacity. Within 5 minutes the light has become progressively brighter, like during sunrise. As soon as your feet touch the ground beside your bed, lamps leading you to the bathroom and kitchen automatically switch on. You proceed to the bathroom, where the shower automatically starts to spray water at your desired temperature.

On the way to the kitchen you pass sensors that turn on the kitchen lights automatically. You push a button, resulting in news headlines appearing on a screen. During breakfast you read the news that has been selected according to your interests.

On the way to the front door you push a button that informs your home that you are leaving: all the lighting is switched off, curtains automatically open, the coffee machine turns off, the heating lowers a few degrees in temperature and the security alarm automatically switches on.

Just imagine, in the evening....
At sunset the lighting system gradually introduces a warm and safe atmosphere to the various rooms of your home. Just before you drive into your garage, a sensor has recognised your car and has automatically opened the garage, turned on the lights and started to increase the temperature in your home by a few degrees. Of course you can also inform your home from work that you are about to leave work, so that it is already warm by the time you arrive home.

It has been a long day and you would like to relax awhile. You sit yourself in front of the "home theatre" with a pizza you picked up on the way. You touch a touch screen and the audio-video system turns on, the lights dim and the video screen automatically appears. You decide to watch your favourite programme that commenced screening live half an hour ago. However, you are able to watch the programme "live" from the very beginning, because the server was familiar with your favourite programmes and had already started recording it. The programme is therefore being displayed while simultaneously being recorded.
After dinner and a spot of relaxation, it is time to do a bit of work. Using a terminal and high-speed connection you are in direct contact with the computer at your work.

It is time for bed. All you need to do is push the "goodnight button". Your home enters the night setting: all lights are turned off, the heating is lowered by a few degrees, curtains and/or blinds are closed and the alarm is automatically set.