Sunday, January 24, 2010

WebCam on Slug

Hi all,
I just added an old webcam on my slug and wanted to share in here. First of all if you want to add webcam to your system go ahead and upgrade your system as explained in the previous post.

Anyway, I upgraded my system and plugged in the webcam to one of the empty slots. Surprisingly the green webcam light was on which means it if successfully loaded. I checked lsusb
Bus 002 Device 003: ID 0ac8:301b Z-Star Microelectronics Corp. ZC0301 WebCam

then video port by typing ls /dev/video* and I had /dev/video0 in there. But when I tried to get some pictures it failed...

It was automatically loading zc0301 module (check with lsmod) but I soon realized that this module bad. I had to prevent that module loading. To do so,
nano /etc/modprobe.d/blacklist
and add
blacklist zc0301


We need another module at this point, gspca.To load this module debian has an easy and beatiful application module-assistant. Go ahead and install it

apt-get install module-assistant


then to install gspca module

m-a auto-install gspca


That is it. Your webcam should be ready now. To test

apt-get install streamer

then
streamer -t 10 -r 2 -o foobar00.jpeg


should capture ten frames, two per second.

To setup a system that captures images and put them to your webserver you can use webcam software. To install write

apt-get install webcam


After that you should put your config file to /root/.webcamrc.
nano /root/.webcamrc


paste the lines below


[grab]
device = /dev/video0
text = "NSLU2 webcam %Y-%m-%d %H:%M:%S (EST)"
# infofile =
fg_red = 255
fg_green = 255
fg_blue = 255
width = 640
height = 480
# delay = number of seconds between snapshots
delay = 30
wait = 1
input = ZC301-2
# norm = webcam
rotate = 0
top = 0
left = 0
bottom = -1
right = -1
quality = 100
trigger = 0
once = 0
# archive =
[ftp]
host = 127.0.0.1
user = root
pass = xxxx
dir = /var/www/webcam
file = webcam.jpeg
tmp = uploading.jpeg
passive = 1
debug = 0
auto = 0
# local = 1 means just use the local directory specified above, do not use ftp or ssh
local = 1
ssh = 0



now if you type
webcam


it should start capturing images and put them to the folder you specified. There is something to mention though
input = ZC301-2

this line is catchy. I guess it differs at different webcams. To learn the correct input name of your device first install v4l-conf
apt-get install v4l-conf

Then,
v4l-info | grep name

should give you the correct name. In my case I got
ioctl VIDIOCGTUNER: Invalid argument
ioctl VIDIOCGAUDIO: Invalid argument
name : "Z-star Vimicro zc0301p"
name : "ZC301-2"


and I used ZC301-2 as the input.Try and see what is yours.
After the setup if you want it to work automatically after restart you can set up a crontab:


crontab -e
@reboot /usr/bin/webcam

I hope this helps someone...

Friday, November 27, 2009

Upgrade Slug

Well it has been some time since I installed my server. By the way it still goes as it should, no problem so for. Today, i needed to upgrade the packages on the slug, so I decided to write it in here too.

As it noted

apt-get -u upgrade


It's useful to run this command with the -u option. This option causes APT to show the complete list of packages which will be upgraded. Without it, you'll be upgrading blindly

After upgrading the packages on the system we may also need to check if there is a new debian version. Type:

apt-get -u dist-upgrade


Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
linux-image-2.6.26-2-ixp4xx
The following packages will be upgraded:
apache2-mpm-prefork apache2-utils apache2.2-common apt apt-utils base-files bind9-host dbus dbus-x11 dhcp3-client dhcp3-common dnsutils gnupg gpgv
libapache2-mod-php5 libapr1 libaprutil1 libavcodec51 libavformat52 libavutil49 libbind9-40 libcurl3 libdbus-1-3 libdns45 libexpat1 libfreetype6
libgd2-xpm libgnutls26 libisc45 libisccc40 libisccfg40 libkrb53 liblwres40 libmysqlclient15off libnewt0.52 libpam-modules libpam-runtime libpam0g
libpng12-0 libpq5 libsasl2-2 libssl-dev libssl0.9.8 libvolume-id0 libvorbis0a libvorbisenc2 libvorbisfile3 libxcb-xlib0 libxcb1 libxml2
linux-image-2.6-ixp4xx linux-image-2.6.26-1-ixp4xx linux-libc-dev mt-daapd mysql-common openssl php5 php5-cgi php5-common php5-dev php5-gd
php5-sqlite screen tzdata udev wget whiptail x11-common
68 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 54.6MB of archives.
After this operation, 33.8MB of additional disk space will be used.
Do you want to continue [Y/n]?


Unfortunately that much of disk space is too much for me now. I only have 1 gb of flash as the main drive so it should wait for now. But you might need to upgrade ...

Happy slugging

Sunday, April 5, 2009

Lighttpd password protected folders

If you have followed these guides you should already have a Lihgttpd webserver with some funky things going on. In some cases you will want to password protect a directory. This is how it is done...

Edit /etc/lighttpd/lighttpd.conf
nano /etc/lighttpd/lighttpd.conf

Add "mod_auth" to server.modules section. It should look like...
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_alias",
"mod_compress",
"mod_auth",


Then to the end of the lighttpd.conf add

$HTTP["url"] =~ "^/DIRECTORY_YOU_WANT_TO_PROTECT/" {
auth.debug = 2
auth.backend = "plain"
auth.backend.plain.userfile = "/home/PASSWORD_FILE.pass"
auth.require = ( "/DIRECTORY_YOU_WANT_TO_PROTECT/" =>
(
"method" => "basic",
"realm" => "Password protected area",
"require" => "user=aspedisca"
)
)



You should create a password file at the location you entered above. This file should include a line saying.
username:secretepassword

Change acording to your needs.You may add more than one user though. Make sure that the password file can be read by lighttpd.
chown lighttpd:lighttpd /home/PASSWORD_FILE.pass

Also change the part saying "/DIRECTORY_YOU_WANT_TO_PROTECT/". It should be relative to your www directory.
Finally, restart lighttpd server:
/etc/init.d/lighttpd restart


Test to reach your directory by using your beloved web browser and see if it works..