четверг, 16 декабря 2010 г.

autologon in linux

Вариант 1
Закомментировать в /etc/inittab строчку
   1:2345:respawn:/sbin/getty 38400 tty1
т.е.
#  1:2345:respawn:/sbin/getty 38400 tty1
ниже  ее добавить
   1:2345:respawn:/bin/login -f YOUR_USER_NAME tty1 /dev/tty1 2>&1

в /home/YOUR_USER_NAME в .bashrc или .bash_profile добавить строку для авто запуска иксов

if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
    startx
fi

Вариант 2 
1) в /etc/inittab комментируем туже строку но добавляем:
   1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologin 38400 tty1
2)
su -
mkdir -p /usr/local/sbin/
touch /usr/local/sbin/autologin
chmod u+x /usr/local/sbin/autologin


3) nano /usr/local/sbin/autologin добавляем
#!/usr/bin/python
import os
os.execlp('login', 'login', '-f', 'my_user_name', '0')
 



4) ~/.bashrc добавить
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
   startx
fi

воскресенье, 12 декабря 2010 г.

upgrade minor version of OpenERP

For each minor version like this one, the procedure is simple because there is no change that requires a real migration.

1. Make a fresh backup of all existing databases, as well as a backup of the files of your OpenERP installation (server, web and addons), just in case.
2. Stop the OpenERP server as well as Web Server (if present).
3. Update the source files to the latest release, or simply install the new releases over the previous ones.
4. Start the server once with the following additional parameters, to trigger an update of all module data and views in the database based on the new source files:
openerp-server.py -d DB_NAME -u all
(include your usual startup parameters too, and replace DB_NAME with the name of the OpenERP database you wish to update)
5. Stop the server and repeat step 4 for each database on this OpenERP installation (any database not updated will use the latest business logic but might have errors or missing improvements in the views until you update it using this procedure)
6. Stop the server again and restart it normally.
7. Start again the Web Server if present.
8. You can now proceed with the update of the clients, which can be done separately by simply reinstalling the latest version.

вторник, 23 ноября 2010 г.

extracting flv from a rtmp stream

There are several tools to create flv files from a rtmp stream in linux, two of them being rtmpdump and its fork flvstreamer.
I tried to retrieve a stream where i constantly got ping messages in the process and it just stopped, so i looked for alternative ways.
The one i found was this huge script, which did crash on me: http://ubuntuforums.org/showthread.php?t=1159309
I was unwilling to search for the error or analyze the stream myself, so i came up with the following solution:

  1. capture stream with tcpdump
  2. extract streaming data with tcpflow
  3. pipe data through netcat
  4. connect rtmpdump to netcat
  5. ???
  6. profit!
sudo tcpdump -i ~device~ -p -s 0 -w ~dumpfile~ -v tcp src port 1935
tcpflow ~dumpfile~
# or use wireshrack like that http://www.youtube.com/watch?v=hNe70CbTlng

cat ~streamfile~ |netcat -l 1935&
rtmpdump -r "rtmp://localhost/streamer/stream.flv" -o 


Works quite reliable for me and is not as much code as the script which does not work.
If you end up downloading huge masses of files you can check them using flvtool2 with this script:

#!/bin/sh
if [ "$1" = "" ]
then
 echo "no filename given"
 exit
fi
if [ $(stat -c%s "$1") -eq 0 ]
then
 echo false
 exit
fi
if [ $(stat -c%s "$1") -eq `flvtool2 -P $1 /dev/null|grep filesize|sed 's/[^0-9]//g'` ]
then
 echo true
else
 echo false
fi


It returns "true" or "false", depending if projected filesize and actual filesize are equal, which means an incomplete file returns "false".

source: http://my.opera.com/dduenker/blog/show.dml/21695332

вторник, 28 сентября 2010 г.

tcpdump ascii http traffic

tcpdump -i eth0  -s0 -A -q 'dst port 80 && src host IP'

среда, 8 сентября 2010 г.

mc colors schema

~/.mc/ini

[Colors]
base_color=normal=,default:selected=,:marked=,default:markselect=,:menu=,:menuhot=,:menusel=,:menuhotsel=,:dnormal=,:dfocus=,:dhotnormal=,:dhotfocus=,:input=,:reverse=,:executable=,default:directory=,default:link=,default:device=,default:special=,:core=,:helpnormal=,:helplink=,:helpslink=,:


or 

[Colors]
base_color=lightgray,default:normal=lightgray,default:selected=black,green:marked=yellow,default:markselect=white,green:errors=white,red:menu=lightgray,default:reverse=black,lightgray:dnormal=white,default:dfocus=black,green:dhotnormal=brightgreen,default:dhotfocus=brightgreen,green:viewunderline=brightred,default:menuhot=yellow,default:menusel=white,black:menuhotsel=yellow,black:helpnormal=black,lightgray:helpitalic=red,lightgray:helpbold=blue,lightgray:helplink=black,cyan:helpslink=yellow,default:gauge=white,black:input=black,green:directory=white,default:executable=brightgreen,default:link=brightcyan,default:stalelink=brightred,default:device=brightmagenta,default:core=red,default:special=black,default:editnormal=lightgray,default:editbold=yellow,default:editmarked=black,cyan:errdhotnormal=yellow,red:errdhotfocus=yellow,lightgray

вторник, 7 сентября 2010 г.

git remove from history

src: http://stackoverflow.com/questions/307828/git-remove-file-accidentally-added-to-the-repository

git filter-branch --index-filter 'git rm --cached --ignore-unmatch config/databases.yml' 38934e4182..HEAD

or

# create and check out a temporary branch at the location of the bad merge
git checkout -b tmpfix 

# remove the incorrectly added file
git rm somefile.orig

# commit the amended merge
git commit --amend

# go back to the master branch
git checkout master

# replant the master branch onto the corrected merge
git rebase tmpfix

# delete the temporary branch
git branch -d tmpfix

понедельник, 23 августа 2010 г.

php unzip

     $zip = new ZipArchive;
     $res = $zip->open('111.zip');
     if ($res === TRUE) {
         $zip->extractTo('./');
         $zip->close();
         echo 'ok';
     } else {
         echo 'failed';
     }

src: http://www.bjw.co.nz/developer/php