Audio only capture from a video/audio usb capture stick 
#> apt-get install xawtv

I assume the usb stick become /dev/video0 and audio became card 1 (card 0 is an onboard audio device)

#> v4lctl -c /dev/video0 setattr input Composite1
#> v4lctl -c /dev/video0 setattr mute off
#> amixer -c 1 sset Line,0 50%,50% unmute cap

test with:

#> arecord -D hw:1,0 -f S16_LE -c2 -r48000 | aplay

To execute this commands automatically on plugin udev could be used:

I have a cheap msi movie vox mini stick using em28xx driver with an option set:

options em28xx card=38

ACTION=="add", KERNEL=="video*", DRIVERS=="usb", ATTRS{idVendor}=="eb1a", ATTRS{idProduct}=="2861", RUN+="/usr/bin/v4lctl -c /dev/%k setattr input Composite1"                      
ACTION=="add", KERNEL=="video*", DRIVERS=="usb", ATTRS{idVendor}=="eb1a", ATTRS{idProduct}=="2861", RUN+="/usr/bin/v4lctl -c /dev/%k setattr mute off"
ACTION=="add", KERNEL=="video*", DRIVERS=="usb", ATTRS{idVendor}=="eb1a", ATTRS{idProduct}=="2861", RUN+="/usr/bin/logger video init %k done"
ACTION=="add", KERNEL=="controlC[0-9]*", DRIVERS=="usb", ATTRS{idVendor}=="eb1a", ATTRS{idProduct}=="2861", RUN+="/usr/bin/amixer -c %n sset Line,0 50%,50% unmute cap"
ACTION=="add", KERNEL=="controlC[0-9]*", DRIVERS=="usb", ATTRS{idVendor}=="eb1a", TTRS{idProduct}=="2861", RUN+="/usr/bin/logger audio init card %n done"

v4lctl needs some time to finish, to check the settings use:

v4lctl -c /dev/video0 show

[ view entry ] ( 5024 views )   |  print article
initramfs script's to backup system's (also raid1) and restore from a usb stick 
These are scripts to backup system's and build an image for an usb stick or kvm for testing:


The only thing to configure is the backup-script:

All your partition's must have an UUID.

With "uuidgen | xargs mkswap /dev/sda1 -U" and "uuidgen | xargs tune2fs /dev/sda1 -U" you can generate one.

This is an example of a backup of a system with two partitions:

cat >root_exclude <<EOF

cat >var_exclude <<EOF

sudo tar -cSp --one-file-system --numeric-owner --atime-preserve \
--exclude-from=root_exclude -f $(hostname).root.tar /

sudo tar -cjSp --one-file-system --numeric-owner --atime-preserve \
--exclude-from=var_exclude -f $(hostname).var.tar.bz2 --directory /var .

uuid() { sudo blkid -o value -s UUID /dev/$1; }
fstype() { sudo blkid -o value -s TYPE /dev/$1; }
inodesize() { sudo tune2fs -l /dev/$1 | grep "Inode size" | sed -e 's/[^0-9]//g'; }
raiduuid() { sudo sed -n "s/^.*$1.*UUID=\(.*\)/\1/p" /etc/mdadm/mdadm.conf; }
partitioninfo() { echo "$(echo $1|sed -e 's/[^0-9]//g') $(uuid $1) $(fstype $1)"; }

cat >$(hostname).cfg <<EOF
ARCHIVES="$(partitioninfo sda2) $(hostname).root.tar.bz2
$(partitioninfo sda3) $(hostname).var.tar.bz2"
SWAP="1 $(uuid sda1)"
GRUB1_INODESIZE=$(inodesize sda2)
* for each tar an exlude-file can be defined
* files are named HOSTNAME.root.tar.bz2, HOSTNAME.var.tar.bz2 and HOSTNAME.cfg
* this backup needs a small config-file (HOSTNAME.cfg)

DISK_PARTITIONS is used by sfdisk and has to be definded in its INPUT FORMAT
ARCHIVES takes a config line for each partition with an optional tar archive at the end
SWAP starts with the number of the partition and the uuid of it
GRUB needs the version of grub
GRUB1_PARTITION is only needed for grub 1 and is the boot partition (counting starts with 0)
GRUB1_INODESIZE is needed because older grub1 can not boot with a filesystem of different inode size

For a raid1 system with only one filesystem the config looks like
DISK_PARTITIONS=",8000,S;,,L,* ,8000,S;,,L,*"
RAID_UUIDS="$(raiduuid md0) $(raiduuid md1)"
ARCHIVES="$(partitioninfo md1) $(hostname).root.tar.bz2"
SWAP="0 $(uuid md0)"
GRUB1_INODESIZE=$(inodesize md1)
After running the backup script HOSTNAME.root.tar.bz2, HOSTNAME.var.tar.bz2 and HOSTNAME.cfg are build.
Now you can run ./ or copy these files to your backup server (where you put the files from other systems) and run there ./ Now you got a directory called image with all your archives, your running kernel and a configured initrd (initramfs).
With ./ /dev/STICKDEVICE your stick to restore is prepared (Warning all data on the stick is erased!).

With kvm you can test the restore process:

Therefore run sudo ./
The build image can be mounted with sudo ./ to ./mnt and unmounted with sudo ./
Test the image with and test the restored image with ./

[ view entry ] ( 1063 views )   |  print article
php script for sispmctl (power supply switching) 
#> apt-get install sispmctl

Switch Socket on with sispmctl -o 1, off with sispmctl -f 1 and get status with sispmctl -m all

To have premission for a webserver to execute the command:

ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", \
ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="fd13", \
GROUP="www-data", MODE="0660"
Because sometimes a wrong status came back i read it twice and compare it

function sispm_status() {
$pins1=array(0=>'0'); $pins2=array(0=>'1');
while ($pins1 !== $pins2) {
exec("/usr/bin/sispmctl -qnm all", $pins1);
exec("/usr/bin/sispmctl -qnm all", $pins2);
return $pins1;
$pins = sispm_status();

if (isset($_POST['update']))
for ($i = 0; $i <= 3; $i++)
if (isset($_POST["pin$i"])) {
if (!$pins[$i]) exec("/usr/bin/sispmctl -qno ".($i+1)); }
else if ($pins[$i]) exec("/usr/bin/sispmctl -qnf ".($i+1));

$pins = sispm_status();

<form method="post">
<input type="checkbox" name="pin0" value="1" <?= ($pins[0]?'checked':'') ?>> Socket 1<br>
<input type="checkbox" name="pin1" value="1" <?= ($pins[1]?'checked':'') ?>> Socket 2<br>
<input type="checkbox" name="pin2" value="1" <?= ($pins[2]?'checked':'') ?>> Socket 3<br>
<input type="checkbox" name="pin3" value="1" <?= ($pins[3]?'checked':'') ?>> Socket 4<br>
<input type="submit" name="update">


use strict;
use warnings;
use CGI;

my $cgi = CGI->new();

my @ports=("PC","Printer","-","-");

print "Content-type: text/html\n";

print "\n";

print "<HTML><HEAD><TITLE>USB Steckdosenleiste</TITLE><META http-equiv=\"refresh\" content=\"60;steckdose.cgi\"></HEAD>\n\n";

print "<BODY>\n";

for my $port ($cgi->param()) {
if ($cgi->param($port) eq "on") { system "/usr/bin/sispmctl -q -o $port"; }
elsif ($cgi->param($port) eq "off") { system "/usr/bin/sispmctl -q -f $port"; }

print "<H1>USB Steckdosenleiste</H1><UL>\n";
my @states = `/usr/bin/sispmctl -q -g all`;
my $cnt = 1;
for my $state (@states) {
if ($ports[$cnt-1] ne "-") {
if ($state eq "off\n") { print "<LI>".$ports[$cnt-1]." ist ausgeschaltet [<A href=\"steckdose.cgi?$cnt=on\">einschalten</A>]\n"; }
else { print "<LI>".$ports[$cnt-1]." ist eingeschaltet [<A href=\"steckdose.cgi?$cnt=off\">ausschalten</A>]\n"; }
print "</UL>\n";

print "</BODY></HTML>"

[ view entry ] ( 932 views )   |  print article
bluetooth network with bluez4 and udev 
Many things changed for bluez4. Now everything is made through dbus commands.

apt-get install bluetooth bluez (on server and client)

First check for bdaddr on server and client:

Server:> hcitool dev
hci0 00:01:1A:63:49:33

Client:> hcitool dev
hci0 00:02:6E:53:42:78


Server:> /usr/share/doc/bluez/examples/test-adapter discoverable on
Server:> /usr/share/doc/bluez/examples/simple-agent

Client:> /usr/share/doc/bluez/examples/simple-agent 00:02:6E:53:42:78 00:01:1A:63:49:33

Hint: On newer systems use /usr/bin/bluez-test-adapter, /usr/bin/bluez-simple-agent and bluez-test-network

On Server:
Agent registered
RequestPinCode (/org/bluez/25897/hci0/dev_00_02_6E_53_42_78)
Enter PIN Code: 1234
(keep simple-agent running)

On Client:
RequestPinCode (/org/bluez/4078/hci0/dev_00_01_1A_63_49_33)
Enter PIN Code: 1234
New device (/org/bluez/4078/hci0/dev_00_01_1A_63_49_33)

Pairing keys are stored hashed in /var/lib/bluetooth/<local bdaddr>/linkkeys

--- /usr/share/doc/bluez/examples/test-network
+++ /usr/share/doc/bluez/examples/
@@ -35,9 +35,10 @@
print "Press CTRL-C to disconnect"

- time.sleep(1000)
- print "Terminating connection"
+ while 1:
+ time.sleep(1000)

+print "Terminating connection"
Client:> /usr/share/doc/bluez/examples/ 00:01:1A:63:49:33
(keep test-network running)

On Server:
Authorize (/org/bluez/25897/hci0/dev_00_02_6E_53_42_78, 0000000f-0000-1000-8000-00803f9b24fa)
Authorize connection (yes/no): yes

Now you can stop simple-agent.

Server:> ifconfig ifconfig bnep0 netmask up
Client:> ifconfig ifconfig bnep0 netmask up

Now you can ping each other.

To avoid start simple-agent on server for connection authorisation each time you can trust the client with:

Server:> /usr/share/doc/bluez/examples/test-device trusted 00:01:1A:63:49:33 on


On my server i'm running a bridged network with dhcp support, therefore i use udev to add bnep to my bridge:

ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/usr/sbin/brctl addif br0 %k"


ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/sbin/dhclient -nw -pf /var/run/ %k"
ACTION=="remove", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/usr/bin/pkill -9 dhclient"

maybe you need to reload udev!

On clientside you only have to keep running
/usr/share/doc/bluez/examples/ 00:01:1A:63:49:33

Usually this should be done by networkmanager but this is not supported (now)

[ view entry ] ( 2426 views )   |  print article
dnstunnel with iodine and bind9 
Iodine server with public IP:

#> apt-get install iodine

For "good" connection i used a mtu of 256 through my provider DNS.
On local network no mtu change was necessary.

#> sysctl -e net.ipv4.ip_forward=1
#> iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

Bind9 server:

zone "DOMAIN" in {
type master;
file "/etc/bind/zones/DOMAIN";
allow-query { any; };

zone "tunnel.DOMAIN" in {
type forward;
forward only;
forwarders {
tunnel      1D   IN   NS    tunnelhost


#> apt-get install iodine
#> iodine -m 256 -P mypassword tunnel.DOMAIN
#> route add default gw

Well it seams that my provider drop's packets with some payload in it:

#> ping -c1 -s 109 fails


#> ping -c1 -s 109 -p ff succeeds

[ view entry ] ( 1239 views )   |  print article

<<First <Back | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Next> Last>>