Friday, July 3, 2015

Watching Nabawi-TV via VLC on Raspberry Pi

A new Indonesian da'wah TV has provided a streaming.

To watch, install vlc.  Once installed, open the VLC, click "Media", and then "Open Network Stream".  Enter:

rtsp://wowza60.indostreamserver.com:1935/nabawitv/live

Friday, April 3, 2015

Script to simulate multiple DHCP clients

#!/bin/sh
#simulate 255 IPhones requesting DHCP
 
 
# Apple OUI = D8:96:95
BASE="d8:96:95:08:96"
FROM=$1
shift
TO=$2
 
if [ -e $FROM ]; then FROM=1; fi
if [ -e $TO ]; then TO=1; fi
 
for i in `seq $FROM $TO`
do
    LSB=`echo "obase=16; $i" | bc`
    MAC="$BASE:$LSB"
    HNAME="`uname -n`-fakehost-$i"
    #CMD="$HOME/bin/dhtest -m $MAC -V -i eth1 -h '$HNAME'"
    CMD="$HOME/bin/dhtest -m $MAC -i eth1 -h '$HNAME'"
    echo $CMD
    $CMD
    sleep 1
done

Another way, the program dhtest (source code) can be download from  https://github.com/saravana815/dhtest.  

For example:
 
git clone https://github.com/saravana815/dhtest
cd dhtest
make

Daily backup of local git changes

While working on a ticket and not ready to commit, it's a good idea to backup all of our changes to an archive file.

The following script does all that and executed daily by cronjob automatically.
  1. create a file, say "backup" in /etc/cron.daily
  2. Type the following (change '<yourhome directory>' to your own login name and <git location> to the git directory where source codes are located):
backing up changed files to tarball
#!/bin/sh
pushd <your source-code location>
LIST=`git status --porcelain | sed -n -e '/^ [D|M]/p' | sed -e 's/^ [D|M] //'`
backupname=`git branch | sed -n -e "/^* /p" | sed  -e 's/** //'`
backupname=$backupname-`date "+%s"`.backup.tar.bz2
dest='<your home directory>'
if [ ! -d "$dest" ]
then
    mkdir -p $dest
fi
tar jcvf $dest/$backupname $LIST > /dev/null

Make the file executable:
chmod +x /etc/cron.daily/backup

Sunday, March 22, 2015

Block Access during certain period using EBTABLES


Say, we want to block any packets coming from a device with mac address 00:01:02:03:04:05 (in other words, our router/switch should just silently drop any packets coming from this MAC address) during period of time 00:00 (00:00 AM) to 6:00 AM, do:

#ebtables -A INPUT -s 00:01:02:03:04:05  --timestart 0:0 --timestop 06:00 -j DROP


If we just want to drop IPv4 packets for the above:

#ebtables -A INPUT -p IPv4 -s 00:01:02:03:04:05  --timestart 0:0 --timestop 06:00 -j DROP


So, parameters for ebtables are actually similar (yet subset) of iptables (netfilter).

Wednesday, March 11, 2015

To fix Mute button keyboard shortcut issue on LXDE

Create a script call "amixertoggle" and save it in /usr/local/bin:

#!/bin/bash

amixer $1 sset Headphone toggle
amixer $1 sset Speaker toggle
amixer $1 sset PCM toggle
amixer $1 sset Master toggle




Edit file $HOME/.config/openbox/lxde-rc.xml and replace block that has "XF86AudioMute" to call our script.  For example:

...
...

    <keybind key="XF86AudioMute">
      <action name="Execute">
              <command>amixertoggle -c 1 toggle</command>
      </action>


...
...

(" -c 1" above is for machine, where the mixer control is actually on card 1.  If doesn't work, we can try different number)

Reload the modified file lxde-rc.xml by doing:

openbox --reconfigure

That's it.  Everytime we press "Mute" button on our PC keyboard, the mute/unmute will toggle.

Thursday, February 26, 2015

Raspberry Pi 2

Got this New Raspberry Pi 2 I ordered a few weeks ago.  It's significantly faster than the first version.  I only wish it had USB 3.0 ports so I can have much bigger and faster storage.