Como empaquetar un directorio de un enlace simbólico

in GNU / Linux

Si queremos empaquetar un directorio usando un enlace simbólico que apunta a él, por ejemplo webmail -> webmail_20120430 :


tar cvfz webmail.tar.gz webmail

Sucederá que se empaquetará el enlace, no el directorio. Para que se empaquete el directorio hay que usar la opción “-h”:


tar cvfz webmail.tar.gz webmail -h

0 Comments

Como evitar los cierres continuos en sesiones SSH por inactividad

in GNU / Linux

Si al dejar una sesión sin actividad un rato y de repente se queda como bloqueada y esto es de manera continua.

Hay una forma de mantenerla activa para que no la cierre.

Hay que editar el fichero:

/etc/ssh/ssh_config

Y añadirle la siguiente linea:

ServerAliveInterval 5

Con el “5″ le estamos diciendo que mande una señal de actividad cada 5 segundos.

0 Comments

OpenRemote Presentations at NSConference, DroidCon and FOSDEM

in Sin categoría

News Item
edited by
Juha Lindfors

OpenRemote Presentations at NSConference and DroidCon

Some presentations about OpenRemote are now available online for those of you who weren’t able to participate live at the events.

OpenRemote presentation slides at NSConference (iOS developer conference) are online and viewable at NSConference 2012 Blitz Talks – OpenRemote, check it out.

OpenRemote was also presented at DroidCon in Berlin this month by Jayneil Dalal and Sohil Patel. You can view their presentation slides online at DroidCon 2012 Berlin – Smart Homes Using Android.

Finally, if you missed the OpenRemote FOSDEM presentation this year, the video of the event and OpenRemote presented by Eric Bariaux is online for you to view: FOSDEM 2012 Lightning Talks – OpenRemote

Enjoy!

0 Comments

OpenRemote Belgium Meet-up

in Sin categoría

News Item
edited by
Juha Lindfors

OpenRemote Belgium Meet-up

We are announcing the first OpenRemote meet-up in Belgium.

It will happen on March 24th, starting at 2PM and will be held in Nivelles. Free attendance, please register for a seat: http://openremote.eventbrite.com/

We will introduce OpenRemote, how to install and configure it for end-users. The second half of the afternoon will be targeted at advanced users who want to add support of their favorite device in OR.

Agenda:

  • Introduction
  • Downloading and installing the ORB
  • Using the On-line designer to configure your system
  • Controlling your system with an OR Console
  • end-users Q&A
  • Getting the latest source code and compiling the different OR components
  • Adding your own protocol to OR
  • developer Q&A

More information can be found on Eventbrite. It is totally free, but please do register using Eventbrite so we can better plan the meeting.

0 Comments

Acceder y resetear el router Zyxel P-660HW-D1 desde Python

in Python

Es un ejemplo sencillo en Python, el cual efectúa un acceso Telnet al Router Zyxel P-660HW-D1 y su posterior reseteo:

#!/usr/bin/python

import getpass
import sys
import telnetlib

HOST = “192.168.4.1″
PASS = “1234″

tn = telnetlib.Telnet(HOST)

tn.set_debuglevel(1)

tn.read_until(“Password: “)
tn.write(PASS + “\n”)

# System maintenance
tn.write(“24\n”)

# Diagnostic
tn.write(“4\n”)

# Reset xDSL
tn.write(“1\n”)

# Reboot System
#tn.write(“21\n”)

 

La misma secuencia que se realizaría desde la consola de texto trasladada a código.

 

0 Comments

Como extraer los ficheros de un RPM o de un DEB

in GNU / Linux

Para los RPMs se necesitan dos utilidades de linea de comandos: rpm2cpio y cpio.

Los contenidos se extraen asi:

rpm2cpio mipaquete.rpm | cpio -vid

Para ver los ficheros contenidos sin extraerlos, se usa lo siguiente:

rpm2cpio mypackage.rpm | cpio -vt

Para los ficheros DEB, hay que aclarar que contienen 3 ficheros:

debian-binary
control.tar.gz
data.tar.gz

Los ficheros que se extraen estan en el “data.tar.gz”

El proceso se hace con dos pasos:


ar vx mipaquete.deb
tar -xzvf data.tar.gz

O si solo se quieren ver los ficheros:


ar vx mipaquete.deb
tar -tzvf data.tar.gz

0 Comments

KNX Video Contest

in Sin categoría

News Item
added by
Juha Lindfors

KNX Video Contest

Mathieu Gallissot and team have submitted their “KNX social bar” video to KNX contest.

This is not your usual KNX demo but shows KNX used in some new and imaginative scenarios. They’ve also got a nice OpenRemote user interface included in the demo.

If you like KNX and like the video, please help and submit your vote.

http://contest.knx.org/en/videos/view/theonlylimitisyourimagination

0 Comments

Russound and KNX with Rule Integration

in Sin categoría

News Item
edited by
Juha Lindfors

Russound and KNX with Rule Integration

In the previous month’s video (if you missed it watch it here), Marcus Redeker showed an integration of OpenRemote, iPhone/Android UI, Russound and KNX. He created an iPhone interface to control audio output from Russound controller and integrated it with a touch interface on iPhone and also with physical KNX switches with OpenRemote controller rules.

This second part of the video shows how the iPhone UI panel was constructed with OpenRemote Designer. It also demonstrates the new Russound Import Wizard which automatically creates commands, sensors, sliders and audio zones. Finally the new rules feature is demonstrated with a rule editor in the OpenRemote Designer.

See the ‘OpenRemote Russound Integration’ video for Part 1 with live system in action. In this Part 2 you will learn how to use OpenRemote tools to create a similar system yourself.

The new features in this video will be available in the next update of the OpenRemote Designer online, scheduled for February 2012. Enjoy!

Lower Knowledge Acquisition Costs in Home Automation

Today, building a home automation system is riddled with barriers-to-entry by proprietary vendors. The software and protocols are closed, training and information is shared only with authorized dealers and integrator network.

This leaves market control to those willing to invest in the knowledge acquisition – and investment that usually requires a dedicated dealership and client-base development with which to earn back the initial investment. This results in higher prices that makes automated homes too expensive for too many households.

OpenRemote Inc’s philosophy to automation is to approach it with open standards and open systems. Not only is the software free (and you’re free to install it on any off-the-shelf hardware that meets the system requirements) but it also enables a lower knowledge acquisition costs to those who are interested in automating their homes themselves. The investment required is your time. The knowledge is free for you to use as you see fit.

To help realize this vision of an open standard to automation, we will attempt to develop further videos, tutorials, how-to documents and other documentation to enable anyone – whether a professional installer or DIY user – to invest their time to learn how to create automation installations with OpenRemote. You may only be interested in automating your own home, or you may be interested in becoming a professional installer, the choice is yours.

This work is just a beginning. Watch this space for more to come.

And for those interested in some help with the learning process, OpenRemote Inc. can offer you training services. Please contact sales@openremote.org for more information.

Enjoy!

0 Comments

OpenRemote at FOSDEM, February 4-5 2012

in Sin categoría

News Item
added by
Juha Lindfors

OpenRemote at FOSDEM

February 4-5, 2012

Brussels Belgium

Eric Bariaux will be presenting OpenRemote at the upcoming Free and Open Source Software Developer’s European Meeting (FOSDEM) this coming February, the weekend of 4th and 5th, held in Brussels, Belgium.

If you’re planning to attend, do come by and say hello!

Talk description:

“After a quick business introduction, covering the business model, the raison d’etre for a standards based, open source platform in the crowded field of home automation, this presentation will address: – the global architecture of the OpenRemote ecosystem and its components – a detail presentation of each components, their role and the technologies used – a short video of the great applications the community has used OpenRemote for – a technical walk-through of the how to implement a new protocol – the OpenRemote community”

More information about the FOSDEM conference: http://www.fosdem.org/2012/schedule/event/openremote

0 Comments

Arrancar JBoss en el puerto 80 sin ser root ni usar apache

in GNU / Linux, JBoss Community

-Arrancar en puertos por debajo del 1024 sólo lo pueden hacer usuarios privilegiados, y no se quiere usar un usuario privilegiado porque si se toma el control de este proceso se tendran los mismos privilegios que dicho usuario.

-Se puede usa Apache con mod_proxy, mod_jk, mod_cluster,… esto esta muy bien para balancear o para ofrecer recursos con Apache, pero si lo único que queremos es cambiar el puerto es demasiado.

-Para hacer lo que dice el título vamos a usar IPTABLES para hacer redireccionamiento de puertos (80 -> 8080, 443 -> 8443).

Hay que ejecutar los siguientes comandos:

iptables -F
iptables -X
iptables -t nat -A OUTPUT -d localhost -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A OUTPUT -d -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -d -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A OUTPUT -d localhost -p tcp --dport 443 -j REDIRECT --to-ports 8443
iptables -t nat -A OUTPUT -d -p tcp --dport 443 -j REDIRECT --to-ports 8443
iptables -t nat -A PREROUTING -d -p tcp --dport 443 -j REDIRECT --to-ports 8443
/etc/init.d/iptables save
/etc/init.d/iptables restart

Para que funcione del todo hay que añadir lo siguiente al “server.xml” del jbossweb:



0 Comments

Arrancar a OpenERP-Web por el puerto 80 con un usuario diferente a root

in Sin categoría

Es bien sabido que si arrancamos un servicio en Linux en puertos por debajo de 1000 con un usuario distinto a root, el sistema no nos lo permite.

En nuestro caso, la parte web de OpenERP arranca en el puerto 8080 con el usuario openerp por lo que sólo nos queda tocar las reglas de iptables para que cuando entre por el puerto 80/443 redireccione al 8080/8443.

Agregamos las reglas:

iptables -A FORWARD -p tcp --destination-port 443 -j ACCEPT
iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 443 --to-ports 8443
iptables -A FORWARD -p tcp --destination-port 80 -j ACCEPT
iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 80 --to-ports 8080

Finalmente, guardamos las reglas o de lo contrario las perderemos al rearrancar el servidor:

/etc/init.d/iptables save

0 Comments

Android: No veo en el file explorer los archivos del dispositivo

in Sin categoría

Si se tiene una rom basada en CyanogenMod y no se ven los ficheros del dispositivo con el “File Explorer” del ADT con Eclipse.

Hay que cambiar el fichero “/system/bin/toolbox” del dispositivo por el que viene en el emulador del SDK de la misma version de android que la del dispositivo. Se hace de la siguiente manera:

1.- Hay que sacar el fichero del emulador:

adb pull /system/bin/toolbox .

2.- Hay que reiniciar el dispositivo en modo recovery y montar desde ahi el “/system”.

3.- Hay que poner el fichero del emulador en el dispositivo:

adb push ./toolbox /system/bin/toolbox

4.- Entrar en el dispositivo, cambiarle los permisos y crear un link para el “ls”

adb shell
# cd /system/bin
# chmod +x toolbox
# ln -s toolbox ls

5.- Reiniciar el dispositivo

6.- Comprobar entrando al “File Explorer” del ADT que ya se ve el arbol de directorios.

0 Comments

Android: Como enviar emails sin pedirle al usuario que interactue

in Sin categoría

Para enviar emails en Android se lanzan Intents que piden la interacción del usuario. Pero si queremos enviar emails en aplicaciones empresariales para temas de debug y control de errores. No se le puede estar al usuario pidiendo que este enviando emails todo el rato.

Esto no se puede hacer directamente con las librerias que vienen con Android. Para poder hacer esto se puede usar un port que hay de las JavaMail para Android.

Para ello es necesario descargar los jar que salen aqui:

Y añadirlos como librerias a nuestro proyecto.

Despues necesitamos implementar una clase que use las javamail para enviar emails como en cualquier otra aplicación Java.

Aqui voy a poner un ejemplo de una clase con la que se pueden enviar email con ficheros adjuntos:
(Como regalo o modificación los adjuntos se envian comprimidos en zip)

package mypackage;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Date;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import javax.activation.CommandMap;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.activation.MailcapCommandMap;
import javax.mail.BodyPart;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

/**
 * Clase para el envio email
 *
 */

public class Mail extends javax.mail.Authenticator {
	private String _user;
	private String _pass; 

	private String[] _to;
	private String _from; 

	private String _port;
	private String _sport; 

	private String _host; 

	private String _subject;
	private String _body; 

	private boolean _auth; 

	private boolean _debuggable; 

	private Multipart _multipart; 

	public Mail() {
		_host = "smtp.gmail.com"; // default smtp server
		_port = "465"; // default smtp port
		_sport = "465"; // default socketfactory port 

		_user = ""; // username
		_pass = ""; // password
		_from = ""; // email sent from
		_subject = ""; // email subject
		_body = ""; // email body 

		_debuggable = false; // debug mode on or off - default off
		_auth = true; // smtp authentication - default on 

		_multipart = new MimeMultipart(); 

		// There is something wrong with MailCap, javamail can not find a handler for the multipart/mixed part, so this bit needs to be added.
		MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
		mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
		mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
		mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
		mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
		mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
		CommandMap.setDefaultCommandMap(mc);
	} 

	public Mail(String user, String pass) {
		this(); 

		_user = user;
		_pass = pass;
	} 

	public boolean send() throws Exception {
		Properties props = _setProperties(); 

		if(!_user.equals("") && !_pass.equals("") && _to.length > 0 && !_from.equals("") && !_subject.equals("") && !_body.equals("")) {
			Session session = Session.getInstance(props, this); 

			MimeMessage msg = new MimeMessage(session); 

			msg.setFrom(new InternetAddress(_from)); 

			InternetAddress[] addressTo = new InternetAddress[_to.length];
			for (int i = 0; i < _to.length; i++) {
				addressTo[i] = new InternetAddress(_to[i]);
			}
			msg.setRecipients(MimeMessage.RecipientType.TO, addressTo); 

			msg.setSubject(_subject);
			msg.setSentDate(new Date()); 

			// setup message body
			BodyPart messageBodyPart = new MimeBodyPart();
			messageBodyPart.setText(_body);
			_multipart.addBodyPart(messageBodyPart); 

			// Put parts in message
			msg.setContent(_multipart); 

			// send email
			Transport.send(msg); 

			return true;
		} else {
			return false;
		}
	} 

	public void addAttachment(String filename) throws Exception { 

		// Antes de adjuntar el fichero se comprime en zip
		String outputFilename = filename+".zip";
		File outputFile = new File(outputFilename);
		FileOutputStream fos = new FileOutputStream(outputFile);
		File inputFile = new File(filename);
		BufferedInputStream fis =  new BufferedInputStream(new FileInputStream(inputFile)); 

		ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));
		try {

			byte[] buffer = new byte[1024];
			ByteArrayOutputStream stream = new ByteArrayOutputStream();
			int len1 = 0;
			while ((len1 = fis.read(buffer)) != -1) {
				stream.write(buffer, 0, len1);
			}				        

			byte[] bytes = stream.toByteArray();
			ZipEntry entry = new ZipEntry(outputFilename);
			zos.putNextEntry(entry);
			zos.write(bytes);
			zos.closeEntry();
		} finally {
			zos.close();
			fos.close();
			fis.close();
		}		

		// Se adjunta el zip
		BodyPart messageBodyPart = new MimeBodyPart();
		DataSource source = new FileDataSource(outputFilename);
		messageBodyPart.setDataHandler(new DataHandler(source));
		messageBodyPart.setFileName(filename); 

		_multipart.addBodyPart(messageBodyPart);
	} 

	@Override
	public PasswordAuthentication getPasswordAuthentication() {
		return new PasswordAuthentication(_user, _pass);
	} 

	private Properties _setProperties() {
		Properties props = new Properties(); 

		props.put("mail.smtp.host", _host); 

		if(_debuggable) {
			props.put("mail.debug", "true");
		} 

		if(_auth) {
			props.put("mail.smtp.auth", "true");
		} 

		props.put("mail.smtp.port", _port);
		props.put("mail.smtp.socketFactory.port", _sport);
		props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.socketFactory.fallback", "false"); 

		return props;
	} 

	// the getters and setters
	public String getBody() {
		return _body;
	} 

	public void setBody(String _body) {
		this._body = _body;
	} 

	public String getFrom() {
		return _from;
	} 

	public void setFrom(String _from) {
		this._from = _from;
	} 

	public String[] getTo() {
		return _to;
	} 

	public void setTo(String[] _to) {
		this._to = _to;
	} 

	public String getHost() {
		return _host;
	} 

	public void setHost(String _host) {
		this._host = _host;
	}   

	public String getPort() {
		return _port;
	} 

	public void setPort(String _port) {
		this._port = _port;
	}   

	public String getSport() {
		return _sport;
	} 

	public void setSport(String _sport) {
		this._sport = _sport;
	}   

	public String getSubject() {
		return _body;
	} 

	public void setSubject(String _subject) {
		this._subject = _subject;
	}
}

Un ejemplo de uso de esta clase podria ser el siguiente:

	/**
	 * Enviar un email con fichero adjunto
	 * */
	public static void send(String emailTo, String nameTo, String emailFrom, String nameFrom,
			String subject, String body, String fileName){

		Log.d("Mail","Enviando email con los datos: "+emailTo +" / "+nameTo +" / "+emailFrom +
				" / "+nameFrom +" / "+subject +" / "+body +" / "+fileName +" / ");

		Mail m = new Mail(); 

		String[] toArr = {emailTo};
		m.setTo(toArr);
		m.setFrom(emailFrom);
		m.setSubject(subject);
		m.setBody(body); 

		try { 

			m.addAttachment(fileName); 

			if(m.send()) {
				Log.i("Mail","Se ha enviado el email con los datos: "+emailTo +" / "+nameTo +" / "+emailFrom +
						" / "+nameFrom +" / "+subject +" / "+body +" / "+fileName +" / ");
			} else {
				Log.e("Mail","No se ha podido enviar el email con los datos: "+emailTo +" / "+nameTo +" / "+emailFrom +
						" / "+nameFrom +" / "+subject +" / "+body +" / "+fileName +" / ");
			}
		} catch(Exception e) {
			Log.e("Mail",("Ha habido algun problema con el email con los datos: "+emailTo +" / "+nameTo +" / "+emailFrom +
					" / "+nameFrom +" / "+subject +" / "+body +" / "+fileName +" / ");
		}     	

	}
0 Comments

Android: Como comprimir un archivo a Zip

in Sin categoría

	public void comprimirFichero(String filename) throws Exception {
		String outputFilename = filename+".zip";
		File outputFile = new File(outputFilename);
		FileOutputStream fos = new FileOutputStream(outputFile);
		File inputFile = new File(filename);
		BufferedInputStream fis =  new BufferedInputStream(new FileInputStream(inputFile)); 

		ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));
		try {

			byte[] buffer = new byte[1024];
			ByteArrayOutputStream stream = new ByteArrayOutputStream();
			int len1 = 0;
			while ((len1 = fis.read(buffer)) != -1) {
				stream.write(buffer, 0, len1);
			}				        

			byte[] bytes = stream.toByteArray();
			ZipEntry entry = new ZipEntry(outputFilename);
			zos.putNextEntry(entry);
			zos.write(bytes);
			zos.closeEntry();
		} finally {
			zos.close();
			fos.close();
			fis.close();
		}

          return outputFilename;
      }
0 Comments

“ADT requires ‘org.eclipse.wst.sse.core 0.0.0′ but it could not be found”

in Sin categoría

Si da este error al intentar instalar el plugin ADT en Eclipse, es porque no esta activo el repositorio necesario para encontrar esa dependencia. En el caso de Eclipse Indigo el siguiente:

http://download.eclipse.org/releases/indigo

Añadirlo en “Install software…” o activarlos en “Available Software” si ya estaba añadido.

0 Comments