Category Archives: Linux

Primitive webcam server using inetd and fswebcam

Hi all!

This weekend I was thinking how to make my webcam connected to OrangePI send a picture “on demand”. There are daemons (e.g. motion or webcam-mjpg) which do this but they capture images even when you are not watching and I wanted to avoid this. There are also projects (fswebcam) which are able to take single picture, save it to disk and end. I just needed to run it after http request and send back the image. Installing full webserver with some kind of interpreter (php, lua,…) seemed to me like an overkill. So I came to an idea to use inetd.

And this is how I did.

Continue reading

Yet another IoT thermostat

Hi all,

this post will be about my homemade IoT thermostat.¬† The goal was to not install any cables (because I live in a rented flat), to go really cheap and to be able to set the temperature from anywhere. I’ll also give you some tips you should think about when building your own. Let’s get started.

Continue reading

OrangePi: Installing Debian chroot into OpenELEC

Hi all,

I have an OrangePi running jernej’s OpenELEC build connected to my TV.¬† It works very well and stable, but on the other side, you can’t do much more with it because OE is very limited Linux distribution. This is a short guide how to run standard Debian services (nginx, samba, openvpn, … anything) in Debian chroot. Continue reading

Fixing non-working WiFi on RT5350

I have a favorite cheap chinese router based on RT5350 (running OpenWRT).

img_20160324_121441

Recently, I was wondering, why I can’t get WiFi on a few of them working. I have one piece running quite old (4xxx svn) OpenWRT where the WiFi works OK. So I tried to compile exactly the same version and install it on the non working piece. I also put the same wifi config there but nothing. It didn’t work. Continue reading

amavisd-new: disable e-mail filtering per destination domain

Testing SPAM filtering from shell

echo "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X" | mail -s Spam_test danman@example.com

Disable filtering for example.com

add following lines to /etc/amavis/conf.d/50-user (don’t forget the dot before domain, it has to be there):

@bypass_spam_checks_maps = (
[".example.com"],
);

@spam_lovers_maps = (
[".example.com"],
);

Using socat for multicast receiving and proxying

socat is a very handy networking tool. Here are some examples for multicast manipulation

Receive multicast data to stdout or file

If you save common mpeg-ts IPTV multicast this way, you can play it with any decent player, like vlc or mplayer.

SRC=239.1.2.3;SRCP=1234;IF=eth0

socat -T 3 UDP4-RECV:$SRCP,bind=$SRC,ip-add-membership=$SRC:$IF,reuseaddr -

socat -T 3 UDP4-RECV:$SRCP,bind=$SRC,ip-add-membership=$SRC:$IF,reuseaddr - > stream.ts

Create high-available multicast proxy

socat relays packets from 239.1.1.1:1234 to 239.2.1.1:1234 with multicast ttl=8.
If no packet arrives in 3 seconds (-T 3), socat exits and script runs another socat which joins another multicast 239.1.1.2:1234 and continues with relaying. You can add as many sources as you want, they will be used in a round-robin fashion. If you want to switch to next source, just kill currently running socat.

DST=239.2.1.1:1234
while true
do
 SRC=239.1.1.1;SRCP=1234;IF=eth0
 socat -T 3 UDP4-RECV:$SRCP,bind=$SRC,ip-add-membership=$SRC:$IF,reuseaddr UDP4-SENDTO:$DST,ip-multicast-ttl=8
 SRC=239.1.1.2;SRCP=1234;IF=eth0
 socat -T 3 UDP4-RECV:$SRCP,bind=$SRC,ip-add-membership=$SRC:$IF,reuseaddr UDP4-SENDTO:$DST,ip-multicast-ttl=8
 ...
done