transcode a mjpeg ip cam on demand with a cgi script using ffmpeg 
To minimize bandwidth for video streaming i have to transcode mjpeg to h264.
To do this on demand ffserver is no option for me.
Therefore a small cgi script on the webserver with ffmpeg did the trick:

#!/bin/bash

echo -e "Content-type: video/avi\n"

#ffmpeg -an -analyzeduration 0 -f mjpeg -r 8 -i http://IP_CAM:PORT \
# -c:v libx264 -preset ultrafast -r 8 -threads 2 -b:v 150k -f avi - 2>/dev/null &

avconv -an -analyzeduration 0 -f mjpeg -r 8 -i http://IP_CAM:PORT \
-c:v libx264 -pre ultrafast -r 8 -threads 2 -b:v 150k -f avi - 2>/dev/null &
pid=$!
trap "kill $pid" SIGTERM SIGPIPE
wait


[ view entry ] ( 2667 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:

/etc/udev/rules.d/90-local.rules:
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
<?php

function sispm_status() {
$pins1=array(0=>'0'); $pins2=array(0=>'1');
while ($pins1 !== $pins2) {
unset($pins1);
unset($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();

?>
<html>
<body>
<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">
</form>
</body>
</html>

perl:
#!/usr/bin/perl

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"; }
}
$cnt++;
}
print "</UL>\n";

print "</BODY></HTML>"


[ view entry ] ( 1590 views )   |  print article
run webalizer over existing (also compressed) logs 
webalizer.conf:
LogFile /var/log/apache2/access.log.1
OutputDir /var/www/webalizer
Incremental yes
To have the right sorting order (oldest logs first) i use ls -tr.
for i in $(ls -tr access.log*); do \
webalizer -c /etc/webalizer/webalizer.conf $i; \
done


[ view entry ] ( 1962 views )   |  print article
Wildcard certificate with virtual hosts and one IP 
apache
NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:443>
ServerName one.domain.at

SSLEngine on
SSLCertificateFile /etc/ssl/certs/domain.at.pem
SSLCertificateKeyFile /etc/ssl/private/domain.at.key

CustomLog /var/log/apache2/one.access.log combined
ErrorLog /var/log/apache2/one.errors.log
.
.
.
</VirtualHost>

<VirtualHost *:443>
ServerName two.domain.at

SSLEngine on
SSLCertificateFile /etc/ssl/certs/domain.at.pem
SSLCertificateKeyFile /etc/ssl/private/domain.at.key

CustomLog /var/log/apache2/two.access.log combined
ErrorLog /var/log/apache2/two.errors.log
.
.
.
</VirtualHost>
lighttpd
$SERVER["socket"] == "0.0.0.0:443" {
ssl.engine = "enable"
ssl.use-sslv2 = "disable"
ssl.pemfile = "/etc/lighttpd/ssl/domain.at.pem"
ssl.ca-file = "/etc/lighttpd/ssl/cacert.pem"
$HTTP["host"] == "one.domain.at" {
server.name = "one.domain.at"
server.errorlog = "/var/log/lighttpd/one_error.log"
accesslog.filename = "/var/log/lighttpd/one_access.log"
server.document-root = "/var/www/one"
}

$HTTP["host"] == "two.domain.at" {
server.name = "two.domain.at"
server.errorlog = "/var/log/lighttpd/two_error.log"
accesslog.filename = "/var/log/lighttpd/two_access.log"
server.document-root = "/var/www/two"
}
}


[ view entry ] ( 924 views )   |  print article
mirror my website 
chmod 700 /etc/cron.daily/websitesync

#!/bin/sh

wget -q --mirror --no-host-directories --cut-dirs=1 --directory-prefix=/var/www \
--user=USERNAME --password=XXXXX ftp://www.holik.at/htdocs

I mirror to my homeserver/var/www and to prevent wget to add
directorynames i use --no-host-directories --cut-dirs=1
without this it would be homeserver/www.holik.at/htdocs/var/www.



[ view entry ] ( 750 views )   |  print article

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |