lunes, 13 de julio de 2009

Nueva Pagina -> http://manuel.verrastro.com.ar

Despues de unos dias me hice un tiempo para migrar a Wordpress, asi que me mude de dominio. http://manuel.verrastro.com.ar

jueves, 25 de junio de 2009

Recuperar Grub

Recuperar Grub

Booteamos con un live cd de alguna distribución, abrimos una consola.


sudo grub
find /boot/grub/stage1
(hd0,2)
root (hdX,X)
setup (hdX,X)

quit

El resultado del find va remplazando el ejemplo del (hdX,X) en mi caso (hd0,2)

Minimizar Thunderbird al System Tray

Thunderbird: Minimize to tray

#apt-get install alltray
#alltray "thunderbird --component=mail"

Despues editámos los launchers y cambiamos el comando por este

miércoles, 3 de junio de 2009

Convertir rmvb a avi con mencoder

rmvb2avi

apt-get install mencoder
mencoder -oac mp3lame -lameopts cbr=128 -ovc xvid -xvidencopts bitrate=1200 video_input.rmvb -o video_output.avi

lunes, 1 de junio de 2009

Rename Script

mcedit rename.sh

#!/bin/bash

#Get all files in current directory
originalFiles=$(ls *.jpg)

# Loop through all files and do your changes
for loopFile in $originalFiles
do
# Create your new filename including the extension
mv $loopFile penguin$loopFile
done

Instalar Flash Player 10 en Linux

Como instalar flash player 10 64bits en linux.

1. Vamos a asegurarnos que no tenemos otro plugin de flash instalado.

apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper

2. Vamos a limpiar todas las carpetas por si quedo alguna libreria dando vueltas.

rm -f /usr/lib/mozilla/plugins/*flash*
rm -f ~/.mozilla/plugins/*flash*
rm -f /usr/lib/firefox/plugins/*flash*
rm -rfd /usr/lib/nspluginwrapper

3. Instalamos ia32-libs y nspluginwrapper

apt-get install ia32-libs nspluginwrapper

4. Descargamos y descomprimimos la ultima version de flash player

cd ~
wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
tar zxvf flashplayer10_install_linux_051508.tar.gz
cp install_flash_player_10_linux/libflashplayer.so /usr/lib/mozilla/plugins/
rm -rf ~/install_flash_player_10_linux/

5. Ahora usamos nspluginwrapper para instalar y linkear el plugin con firefox

nspluginwrapper -i /usr/lib/mozilla/plugins/libflashplayer.so
ln -sf /usr/lib/nspluginwrapper/plugins/npwrapper.libflashplayer.so /usr/lib/mozilla/plugins/
ln -sf /usr/lib/nspluginwrapper/plugins/npwrapper.libflashplayer.so /usr/lib/firefox-addons/plugins/

Ahora reiniciamos firefox, y en la barra de url tipeamos about:plugins y tenemos que tener algo asi.

Shockwave Flash
File name: npwrapper.libflashplayer.so
Shockwave Flash 10.0 r22
MIME Type Description Suffixes Enabled
application/x-shockwave-flash Shockwave Flash swf Yes
application/futuresplash FutureSplash Player spl Yes

martes, 19 de mayo de 2009

Free memory Bash Script

Script Similar al anterior que comprueba la memoria Swap en uso y envia un mail avisando que nos excedimos del limite, tambien puede ser usada para comprobar la ram, simplemente cambian Mem, por Swap.

Para agregarla al cron.hourly mcedit
/etc/cron.hourly/freemem.sh

No olviden cambiar el valor de la variable limit por el limite que quieren setear para que se envie el email. El resultado esta expresado en Mb.

#!/bin/bash

total=`free -m | grep Swap | awk '{print $(2)}'`;
used=`free -m | grep Swap | awk '{print $(3)}'`;
free=`free -m | grep Swap | awk '{print $(4)}'`;
limit=512

if (("$used" '>=' "$limit"));
then
echo "Memoria Swap en uso: $used MB" | mail -s "Memoria en uso" mail@host.com
fi

lunes, 18 de mayo de 2009

Freedisk Bash Scripting

Script que comprueba el espacio en disco y envia un email de aviso. Bastante util para correrlo en un cron hourly.

Ejecutan mcedit
/etc/cron.hourly/freedisk.sh y pegan el script de abajo.

#!/bin/bash
df -h > dfd
limite=90;
for i in $(df |awk '{print $(5)}');
do
i=`echo $i | cut -f 1 -d "%"`
if (("$i" '>=' "$limite")); then
cat dfd | mail -s "Discos Llenandose" mail@host.com
break;
fi
done

viernes, 15 de mayo de 2009

Configurando PROFTPD con Mysql en Debian

Como instalar y configurar proftpd con mysql en Debian Lenny

1 - Instalamos proftpd con soporte mysql desde el aptitude.

apt-get install proftpd-mysql

Run proftpd from inetd or standalone? <-- standalone

2- Luego creamos el usuario y el grupo. (Reemplazamos el grupo y el id de usuario por alguno que tengamos libre).

groupadd -g 2001 ftpgroup
useradd -u 2001 -s /bin/false -d /bin/null -g ftpgroup ftpuser

3- Ahora vamos a crear la base de datos "ftp" y un usuario llamado proftpd. Con el que mysql se conectara a la base de datos.

mysql -u root -p
create database ftp;

GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost.localdomain' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Luego creamos las tablas.

USE ftp;

CREATE TABLE ftpgroup ( groupname varchar(16) NOT NULL default '', gid smallint(6) NOT NULL default '5500', members varchar(16) NOT NULL default '', KEY groupname (groupname) ) TYPE=MyISAM COMMENT='ProFTP group table';CREATE TABLE ftpuser ( id int(10) unsigned NOT NULL auto_increment, userid varchar(32) NOT NULL default '', passwd varchar(32) NOT NULL default '', uid smallint(6) NOT NULL default '5500', gid smallint(6) NOT NULL default '5500', homedir varchar(255) NOT NULL default '', shell varchar(16) NOT NULL default '/sbin/nologin', count int(11) NOT NULL default '0', accessed datetime NOT NULL default '0000-00-00 00:00:00', modified datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id),
UNIQUE KEY userid (userid) ) TYPE=MyISAM COMMENT='ProFTP user table';
quit;


4- Ahora vamos a configurar proftpd, vamos a editar el archivo conf de proftpd.En este link hay una lista de todos los parametros de configuracion. http://www.proftpd.org/docs/directives/linked/by-name.html

Para editar el archivo de conf :

mcedit /etc/proftpd/proftpd.conf

En algunos casos el archivo puede estar en /etc/proftpd.conf

deberia quedar asi:

Include /etc/proftpd/modules.conf

UseIPv6 on

IdentLookups off

ServerName "Pro Ftpd Server"
ServerType standalone
DeferWelcome off

MultilineRFC2228 on
DefaultServer on
ShowSymlinks on

TimeoutNoTransfer 600
TimeoutStalled 600
TimeoutIdle 1200

#DisplayLogin welcome.msg
DisplayChdir .message true
ListOptions "-l"

DenyFilter \*.*/

Port 21

DefaultRoot ~

# DynMasqRefresh 28800

MaxInstances 30

User ftpuser
Group ftpgroup

Umask 022 022
#Normally, we want files to be overwriteable.
AllowOverwrite on

TransferLog /var/log/proftpd/xferlog
SystemLog /var/log/proftpd/proftpd.log

AllowRetrieveRestart on
AllowStoreRestart on

QuotaEngine off

Ratios off

DelayEngine on

ControlsEngine off
ControlsMaxClients 2
ControlsLog /var/log/proftpd/controls.log
ControlsInterval 5
ControlsSocket /var/run/proftpd/proftpd.sock

AdminControlsEngine off

# The passwords in MySQL are encrypted using CRYPT
SQLAuthTypes Plaintext Crypt
SQLAuthenticate users* groups*
# used to connect to the database
# databasename@host database_user user_password
SQLConnectInfo ftpuser@localhost proftpd ******

# Here we tell ProFTPd the names of the database columns in the "usertable"
# we want it to interact with. Match the names with those in the db
SQLUserInfo ftpuser userid passwd uid gid homedir shell

# Here we tell ProFTPd the names of the database columns in the "grouptable"
# we want it to interact with. Again the names match with those in the db
SQLGroupInfo ftpgroup groupname gid members

# set min UID and GID - otherwise these are 999 each
SQLMinID 500

# create a user's home directory on demand if it doesn't exist
#SQLHomedirOnDemand on
CreateHome on
# Update count every time user logs in
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid='%u'" ftpuser

# Update modified everytime user uploads or deletes a file
SQLLog STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser

RootLogin off
RequireValidShell off

Tengan en cuenta 2 cosas.

En algunas versiones de proftpd se usa el parametro CreateHome en vez de SQLHomedirOnDemand por eso lo deje comentado.

En SQLConnectInfo van los datos de la base de datos de mysql que creamos anteriormente

Una vez que terminamos de editar el .conf, tenemos que descomentar en modules.conf los modulos de sql que estan comentados.

Lo que quedaria algo asi:

mcedit /etc/proftpd/modules.conf

#
# This file is used to manage DSO modules and features.
#

# This is the directory where DSO modules reside

ModulePath /usr/lib/proftpd

# Allow only user root to load and unload modules, but allow everyone
# to see which modules have been loaded

ModuleControlsACLs insmod,rmmod allow user root
ModuleControlsACLs lsmod allow user *

LoadModule mod_ctrls_admin.c
LoadModule mod_tls.c

# Install proftpd-mod-mysql or proftpd-mod-pgsql to use this
LoadModule mod_sql.c

# Install proftpd-mod-ldap to use this
#LoadModule mod_ldap.c

#
# 'SQLBackend mysql' or 'SQLBackend postgres' directives are required
# to have SQL authorization working. You can also comment out the
# unused module here, in alternative.
#

# Install proftpd-mod-mysql to use this
LoadModule mod_sql_mysql.c

# Install proftpd-mod-pgsql to use this
#LoadModule mod_sql_postgres.c

LoadModule mod_radius.c
LoadModule mod_quotatab.c
LoadModule mod_quotatab_file.c


# Install proftpd-mod-ldap to use this
#LoadModule mod_quotatab_ldap.c

# Install proftpd-mod-pgsql or proftpd-mod-mysql to use this
LoadModule mod_quotatab_sql.c
LoadModule mod_quotatab_radius.c
LoadModule mod_wrap.c
LoadModule mod_rewrite.c
LoadModule mod_load.c
LoadModule mod_ban.c
LoadModule mod_wrap2.c
LoadModule mod_wrap2_file.c
# Install proftpd-mod-pgsql or proftpd-mod-mysql to use this
#LoadModule mod_wrap2_sql.c
LoadModule mod_dynmasq.c


# keep this module the last one
LoadModule mod_ifsession.c

5 - Creamos los usuarios en mysql.

Nos conectamos a mysql y creamos el grupo en la tabla ftpgroup que contienen el nombre del grupo el id y el nombre de usuario que creamos anteriormente

mysql -u root -p
USE ftp;

INSERT INTO `ftpgroup` (`groupname`, `gid`, `members`) VALUES ('ftpgroup', 2001, 'ftpuser');

Ahora hacemos un insert de un nuevo usuario

INSERT INTO `ftpuser` (`id`, `userid`, `passwd`, `uid`, `gid`, `homedir`, `shell`, `count`, `accessed`, `modified`) VALUES (1, 'exampleuser', 'secret', 2001, 2001, '/home/newuser', '/sbin/nologin', 0, '', '');
quit;

Iniciamos Proftpd

/etc/init.d/proftpd start

Hacemos un ls en el home y vemos como se creo un nuevo directorio con el nombre de nuestro usuario.

ls -l /home

Ya tenemos configurado proftpd y listo para usarlo. Ahora si queremos agregar proftp al incio de linux ejectuamos el siguiente comando (en debian):

ln -s /etc/init.d/proftpd /etc/rcX.d/S20proftpd

Donde X sera nuestro runlevel, para saber cual es nuestro runlevel ejecutamos.

cat /etc/inittab | grep id

El resultado es algo asi:

id:X:initdefault:

Y eso es todo. Si a alguien le trae problemas la instalacion son bienvenidos de comentar.