Monday, January 15, 2007

Siemens-Sk65 udev script for GPRS

When I use GPRS some times my phone move to ttyUSB0 to ttyUSB1 and it disconnect me.

For the details doc: click here

I just add this in my udev.rules

KERNEL=="ttyUSB*", BUS=="usb", SYMLINK+="siemens-sk65"

then in my wvdial.conf
Modem = /dev/siemens-sk65

example:
Jan 16 13:30:29 localhost kernel: usb 4-2: new full speed USB device using uhci_hcd and address 3
Jan 16 13:30:29 localhost kernel: usb 4-2: configuration #1 chosen from 1 choice
Jan 16 13:30:29 localhost kernel: pl2303 4-2:1.0: pl2303 converter detected
Jan 16 13:30:29 localhost kernel: usb 4-2: pl2303 converter now attached to ttyUSB0
Jan 16 13:30:52 localhost kernel: CSLIP: code copyright 1989 Regents of the University of California
Jan 16 13:30:52 localhost kernel: PPP generic driver version 2.4.2
Jan 16 13:30:52 localhost pppd[3339]: pppd 2.4.4 started by root, uid 0
Jan 16 13:30:53 localhost pppd[3339]: Using interface ppp0
Jan 16 13:30:53 localhost pppd[3339]: Connect: ppp0 <--> /dev/ttyUSB0
Jan 16 13:30:55 localhost pppd[3339]: CHAP authentication succeeded
Jan 16 13:30:55 localhost pppd[3339]: CHAP authentication succeeded
Jan 16 13:30:55 localhost kernel: PPP BSD Compression module registered
Jan 16 13:30:55 localhost kernel: PPP Deflate Compression module registered
Jan 16 13:31:25 localhost pppd[3339]: IPCP: timeout sending Config-Requests
Jan 16 13:31:25 localhost pppd[3339]: Connection terminated.
Jan 16 13:31:25 localhost pppd[3339]: Exit.
Jan 16 13:31:33 localhost pppd[3388]: pppd 2.4.4 started by root, uid 0
Jan 16 13:31:33 localhost pppd[3388]: Using interface ppp0
Jan 16 13:31:33 localhost pppd[3388]: Connect: ppp0 <--> /dev/ttyUSB0
Jan 16 13:31:36 localhost pppd[3388]: CHAP authentication succeeded
Jan 16 13:31:36 localhost pppd[3388]: CHAP authentication succeeded
Jan 16 13:31:39 localhost pppd[3388]: Cannot determine ethernet address for proxy ARP
Jan 16 13:31:39 localhost pppd[3388]: local IP address 10.87.9.211
Jan 16 13:31:39 localhost pppd[3388]: remote IP address 192.168.254.254
Jan 16 13:31:39 localhost pppd[3388]: primary DNS address 192.168.80.66
Jan 16 13:31:39 localhost pppd[3388]: secondary DNS address 202.134.13.3
Jan 16 14:07:29 localhost kernel: hub 4-0:1.0: port 2 disabled by hub (EMI?), re-enabling...
Jan 16 14:07:29 localhost kernel: usb 4-2: USB disconnect, address 3
Jan 16 14:07:29 localhost kernel: pl2303 4-2:1.0: device disconnected
Jan 16 14:07:29 localhost pppd[3388]: Modem hangup
Jan 16 14:07:29 localhost pppd[3388]: Connect time 35.9 minutes.
Jan 16 14:07:29 localhost pppd[3388]: Sent 283895 bytes, received 1000779 bytes.
Jan 16 14:07:29 localhost pppd[3388]: Connection terminated.
Jan 16 14:07:29 localhost pppd[3388]: Exit.
Jan 16 14:07:29 localhost kernel: usb 4-2: new full speed USB device using uhci_hcd and address 4
Jan 16 14:07:30 localhost kernel: usb 4-2: configuration #1 chosen from 1 choice
Jan 16 14:07:30 localhost kernel: pl2303 4-2:1.0: pl2303 converter detected
Jan 16 14:07:30 localhost kernel: usb 4-2: pl2303 converter now attached to ttyUSB1
Jan 16 14:07:30 localhost kernel: pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
Jan 16 14:07:41 localhost pppd[3981]: pppd 2.4.4 started by root, uid 0
Jan 16 14:07:41 localhost pppd[3981]: Using interface ppp0
Jan 16 14:07:41 localhost pppd[3981]: Connect: ppp0 <--> /dev/ttyUSB1
Jan 16 14:07:44 localhost pppd[3981]: CHAP authentication succeeded
Jan 16 14:07:44 localhost pppd[3981]: CHAP authentication succeeded
Jan 16 14:07:47 localhost pppd[3981]: Cannot determine ethernet address for proxy ARP
Jan 16 14:07:47 localhost pppd[3981]: local IP address 10.87.10.34
Jan 16 14:07:47 localhost pppd[3981]: remote IP address 192.168.254.254
Jan 16 14:07:47 localhost pppd[3981]: primary DNS address 192.168.80.66
Jan 16 14:07:47 localhost pppd[3981]: secondary DNS address 202.134.13.3

Thursday, January 11, 2007

Java player and streaming server for Ogg

wiki news using it. Link

JOrbis is a pure Java Ogg Vorbis decoder.
===========================
JOrbis accepts Ogg Vorbis bitstreams and decodes them to raw PCM. Link

JRoar is a streaming server for Ogg in pure Java
===================================
JRoar casts live Ogg streams to Ogg Vorbis players as IceCast2 does and shouts live Ogg streams to IceCast2 and JRoar. Link

Wednesday, January 03, 2007

chkrootkit and logcheck

chkrootkit and logcheck mail notification

#apt-get install cron
#crontab /etc/crontab
#apt-get install chkrootkit

write a script 'chkrootkit' and save in /

#/bin/bash
cd /usr/sbin/ && ./chkrootkit 2>&1 | mail -s "chkrootkit output" yourname@xyz.com

#chmod 777 / chkrootkit
#apt-get install logcheck

we edit the /etc/logcheck/logcheck.conf
INTRO=1
REPORTLEVEL="server"
SENDMAILTO="yourname@xyz.com"
FQDN=1
RULEDIR="/etc/logcheck"

then we write a script 'logcheck' and save in /
#/bin/bash
su -s /bin/bash -c "/usr/sbin/logcheck" logcheck


#chmod 777 /logcheck
we add the chkrootkit and logcheck script in the /var/spool/cron/crontabs/root
46 12 * * * /./chkrootkit
46 12 * * * /./logcheck

done :)

Rsync and SSH

This Rsync and ssh is to automatically backup files from one server to another.

for more doc follow this link

We generate a key

$ ssh-keygen -t dsa -b 2048 -f /home/thisuser/cron/thishost-rsync-key
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase): [press enter here]
Enter same passphrase again: [press enter here]
Your identification has been saved in /home/thisuser/cron/thishost-rsync-key.
Your public key has been saved in /home/thisuser/cron/thishost-rsync-key.pub.
The key fingerprint is:
2e:28:d9:ec:85:21:e7:ff:73:df:2e:07:78:f0:d0:a0 thisuser@thishost

Copy the public key to remove PC
$ scp /home/thisuser/cron/thishost-rsync-key.pub remoteuser@remotehost:/home/remoteuser/

Configuring remotehost
$ ssh remoteuser@remotehost remoteuser@remotehost's password: [type correct password here]


need to make sure we have the directory and files we need to authorize connections with this key
$ if [ ! -d .ssh ]; then mkdir .ssh ; chmod 700 .ssh ; fi
$ mv thishost-rsync-key.pub .ssh/
$ cd .ssh/
$ if [ ! -f authorized_keys ]; then touch authorized_keys ; chmod 600 authorized_keys ; fi
$ cat thishost-rsync-key.pub >> authorized_keys


we edit the 'authorized_keys' file (with vi)

before edit
ssh-dss AAAAB3NzaC1kc3MAAAEBAKYJenaYvMG3nHwWxKwlWLjHb77CT2hXwmC8Ap+ fG8wjlaY/9t4uA+2j2yBgN5cy8arlZ80q1Mcy763RjYGkR/FkLJ611HWIA= thisuser@thishost

we made the following change
from="10.1.1.1",command="/home/remoteuser/cron/validate-rsync" ssh-dss AAAAB3Nza
C1kc3MAAAEBAKYBgN5cy8arlZ80q1Mcy763RjYGkR/FkLJ611HWIA= thisuser@thishost
your can omit the 'from="10.1.1.1",' part of the line (including the comma), then 'rsync' will be possible using this key from anywhere.

create a script /home/remoteuser/cron/validate-rsync
#!/bin/sh

case "$SSH_ORIGINAL_COMMAND" in
*\&*)
echo "Rejected"
;;
*\(*)
echo "Rejected"
;;
*\{*)
echo "Rejected"
;;
*\;*)
echo "Rejected"
;;
*\<*) echo "Rejected" ;; *\`*) echo "Rejected" ;; rsync\ --server*) $SSH_ORIGINAL_COMMAND ;; *) echo "Rejected" ;; esac

for test we give
$ rsync -avz -e "ssh -i /home/thisuser/cron/thishost-rsync-key" remoteuser@remotehost:/remote/dir /this/dir/


Cron Script
We save it in /root/rsync
http://salahuddin66.blogspot.com/
#chmod 777 /root/rsync
#!/bin/sh

RSYNC=/usr/bin/rsync
SSH=/usr/bin/ssh
KEY=/home/thisuser/cron/thishost-rsync-key
RUSER=remoteuser
RHOST=remotehost
RPATH=/remote/dir
LPATH=/this/dir/

$RSYNC -az -e "$SSH -i $KEY" $RUSER@$RHOST:$RPATH $LPATH


We add the line in vi /var/spool/cron/crontabs/root or /etc/crontab
0 23 * * * /root/./rsync

done :)

Icecast2 Streaming server

I have test in Debian testing (Sid)

for more doc www.xiph.org

# apt-get install icecast2

edit /etc/default/icecast2
icecast2
=====
ENABLE=true
=====

start the icecast
/etc/init.d/icecast2 start

edit /etc/icecast2/icecast.xml enable the relay if you want.

There are two types of relays: a "Master server relay" or a "Specific Mountpoint relay." A Master server relay is only supported between icecast2 servers and is used to relays all mountpoints on a remote icecast2 server.

icecast.xml
=======
master-server 127.0.0.1 master-server
master-server-port 8001 master-server-port
master-update-interval 120 master-update-interval
master-password hackme master-password

relays-on-demand 1 relays-on-demand
on-demand 1 on-demand
relay-shoutcast-metadata 1 relay-shoutcast-metadata

example:

relay
server 127.0.0.1 server
port 8001 port
mount /example.ogg mount
local-mount different.ogg local-mount
on-demand 1 on-demand

(if your want to stream the mounted /example.ogg via /different.ogg in server)
========

restart the icecast server
/etc/init.d/icecast2 restart

with your browser
http://localhost:8000/
(user: admin, pass: hackme, by default)

copy a audio.ogg or video.ogg in your "/usr/share/icecast2/web/" and test it with your player.


Ices2 config
(Ogg Vorbis streaming source for Icecast 2)

#apt-get install ices2

cd /usr/share/doc/ices2/examples/

To stream some pre-encoded ogg files

cp /usr/share/doc/ices2/examples/ices-playlist.xml /usr/share/icecast2/web/

edit the /usr/share/icecast2/web/ices-playlist.xml

ices-playlist.xml
==========
hostname localhost hostname
port 8000 port
password hackme password
mount /example1.ogg mount

param name="restart-after-reread" 1 param (optional)
==========
you can hear it via
http://localhost:8000/example1.ogg

if you change it to /example.ogg,
then you can hear it via
http://localhost:8000/example.ogg
or
http://localhost:8000/different.ogg (via the relay)

create a playlist "playlist.txt" in /usr/share/icecast2/web/

playlist.txt
=======
fordername/01-name.ogg
fordername/02-name.ogg
fordername/03-name.ogg
...........................
=======

start the stream
# ices2 ices-playlist.xml


To stream from Input (alsa or oss)

cp /usr/share/doc/ices2/examples/ices-alsa.xml /usr/share/icecast2/web/

edit the /usr/share/icecast2/web/ices-alsa.xml if your need.

ices-alsa.xml
=========
hostname localhost hostname
port 8000 port
password hackme password
mount /example1.ogg mount
===========
you can hear it via
http://localhost:8000/example1.ogg

if you change it to /example.ogg,
then you can hear it via
http://localhost:8000/example.ogg
or
http://localhost:8000/different.ogg (via the relay)


start the live stream
# ices2 ices-alsa.xml


Video Streaming

#apt-get install ffmpeg ffmpeg2theora oggfwd

example:
#ffmpeg2theora output.ogg -x 320 -y 240 -V 150 -A 64 -o - --optimize | oggfwd localhost 8000 hackme /theora.ogg

(if your want to stream the output.ogg via mountpoint /theora.ogg in icecast server)
play http://localhost:8000/theora.ogg

done :)