Raspberry Pi, Raspbian and an old TV with DVI

rpi_8

I finally bought some Raspberry Pi stuff. I picked up the package yesterday after my night shift at and mounted one of them in the case I got for it and connected it to my ancient tv, with DVI as the most modern input choice.
The first thing I tried was raspbmc. It boots, and works, bMy Raspberry Pi in its Pi Holder aluminum case, and some dust.ut I’m not very impressed with XBMC, and not with the analog audio, which doesn’t work at all in it, except for a few seconds when listening to a radio stream, but most of the time it was only giving some clicks in the speakers when switching streams. It’s not for me anyway. Moving on.

Then I fell asleep, and now it is Saturday.

 

Raspbian

So, off with that. Next thing to try will be the Raspberry Pi foundation Raspbian image. (After that I will probably end up using the Raspbian installer and make my own stripped down base image, or check if there exists some sane image from here, we’ll see.). Continue reading “Raspberry Pi, Raspbian and an old TV with DVI”

Cron, crontab example reference and how to run things periodically in GNU/Linux and Unix

Cron is a job scheduler found in most Unix-like operating systems. “Chronos”, which is the Greek word for “time”, is where the name cron comes from. Cron makes it possible to schedule jobs, which can be commands, a series of commands, or scripts, that you want to run periodically. Common uses are backups, notifications, periodic checks on availability of services, networks, machines, or other things, and administration and maintenance tasks like rotating of logs, to mention a few. It is very general-purpose though, (like Unix tools is and should be) and can be used for whatever you can think of that needs to run periodically.
Image showing the Big Ben clock.

Jobs that should be run by cron are specified in crontab (cron table) files. A crontab is a configuration file that specifies commands (shell commands, including programs, scripts, or pipelines thereof) to be run, and when they should be executed.

Each line in a crontab file represents a “job”, and is composed of a CRON expression (specifying the time) followed by the command or commands to be executed. There are two different crontab files, the ones installed by system software, and editable only by root (but in most cases best left alone), and crontab files written by and belonging to users (including root). The authorization control to cron, who will be allowed to have a crontab or not, are done with the files /etc/cron.allow and /etc/cron.deny.

The manpages of cron and the crontab format are nice. “crontab” is both the name of the program installing, listing and editing user’s crontabs, and the file format manpage, so do read them:

man cron
man 1 crontab
man 5 crontab

The page in section 5, about the format is most interesting. However I prefer to keep a short reference in my user’s crontab file itself for quick reference, feel free to grab it:

# mycrontab.txt
# beardy
# My example crontab, kept in ~/

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# Send the mail to another address than the local user
##MAILTO=foo@foo.bar

##############################################################################
#
# The following example should run "true" every day of every month, at half
# past eight, every day of the week.
#
# Example:
#
# 30 8  * * *   true
# |  |  | | |    |
# |  |  | | |    +--- command, or script, to run
# |  |  | | +-------- day of week, 0-7 or mon, Tue, FRI
# |  |  | +---------- month, 1-12, or names, jan, Mar, AUG (case doesn't matter)
# |  |  +------------ date, 1-31
# |  +--------------- hour, 0-23
# +------------------ minute, 0-59
#
# see "man 5 crontab"
#
#     Instead of the first five fields, one of eight special strings may
#     appear:
#
#           string          meaning
#           ------          -------
#           @reboot         Run once, at startup.
#           @yearly         Run once a year, "0 0 1 1 *".
#           @annually       (same as @yearly)
#           @monthly        Run once a month, "0 0 1 * *".
#           @weekly         Run once a week, "0 0 * * 0".
#           @daily          Run once a day, "0 0 * * *".
#           @midnight       (same as @daily)
#           @hourly         Run once an hour, "0 * * * *".
#
##############################################################################

# Run beep every Christmas Eve, at 14:40 (20 min before Kalle Anka)
#40 14  24 12 * beep -f 1000 -r 5 -l 150 -D 250
# next job goes after this line
40 14   24 12 * echo "God Jul!"

To install a new crontab, the crontab(1) program is used:

crontab mycrontab.txt

To later list it, and edit it (with the editor configured with the $EDITOR environment variable usually):

crontab -l
crontab -e

Read more about cron and crontab:

cron(8)
crontab(1)
crontab(5)
Time – An important Subject with any OS

Fixing missing menu entries of Opera and Skype in Debian GNU/Linux

Unfortunately the third-party packages of Opera and Skype do not contain menu entries for the Debian menu system. Not very surprisingly one might think, but I just think it’s sloppy. If you, like me, like the Debian menu system and want Opera and Skype available in it, do the following to solve that, until the packagers have included the menu entry files themselves:

(Update: I noticed that Opera has apparently had a menu entry in its package before, but has now removed it. It’s explained in this post, but I still think that was a bad choice.)
Continue reading “Fixing missing menu entries of Opera and Skype in Debian GNU/Linux”

A revised opinion on apache2-mpm-prefork and apache2-mpm-worker, and php5 and php5-cgi on Debian, regarding performance

It’s now over a year since I wrote about “Exchanging apache2-mpm-prefork for apache2-mpm-worker, and using php5-cgi on Debian to improve performance“. Since then I have re-evaluated my opinion about running apache2-mpm-worker and php5-cgi on a low memory machine, specifically a virtual machine running under Xen, running Debian.
Continue reading “A revised opinion on apache2-mpm-prefork and apache2-mpm-worker, and php5 and php5-cgi on Debian, regarding performance”

Jag och mitt skal – Verktygslådan, omdirigering av I/O

Bild som visar rör.Förhoppningsvis är du bekant med grunderna rörande omdirigering av I/O (Input, Output) i skalet, i synnerhet grundkoncepten “standard input”, “standard output” och “standard error”. Om inte, så följer här en snabb genomgång, “standard input” är en datakälla, från vilken data kommer. Ett program varken behöver, eller ska bry sig om, varifrån data kommer, vare sig det är från en fil, tangentbordet, ett magnetband, eller en hålkortsläsare. På samma sätt är “standard output” ett ställe där data skickas till, ett program ska inte heller behöva veta, eller bry sig om vad det är för något. Det kan vara en bildskärm, en fil, en dvd-brännare, eller vad som helst.
Program som bara läser standard input, gör någonting med datan som det läser, och sedan skickar det vidare ut genom standard output, kallas för “filter”, detta kan bildligt jämföras med filter i en vattenledning, eller ett avloppsrör.
Continue reading “Jag och mitt skal – Verktygslådan, omdirigering av I/O”

Jag och mitt skal – Verktygslådan, introduktion och filosofi

Filosofin bakom verktygslådan var ett mycket viktigt koncept när Unix (av vilket GNU/Linux i stort sett är en klon) först  designades och utvecklades. Olyckligtvis, i dagens värld av “webben” grafiska gränssnitt, “moln” och andra buzz-fjanterier, verkar denna filosofi till viss del glömts bort. Det är synd, eftersom denna filosofi ger oss den kraftfulla mentala modell, som är så användbar för att lösa många olika typer av problem.

Bild som visar en gigantisk schweisisk armékniv av märket Wenger.Många människor bär dagligen en schweizisk armé-kniv i byxfickan, eller väskan. En schweizisk armé-kniv (fick-kniv i allmänhet också för den delen) är ett bra verktyg att ha till hands; Det har flera knivblad, en skruvmejsel, pincett, tandpetare, nagelfil, korkskruv, och kanske en mängd andra saker också. För att lösa småproblem och småjobb av olika slag i vardagen, som kräver ett enkelt allt-i-allo-verktyg, är fickkniven av schweizisk typ, (eller en multifunktionstång), helt okej.
Continue reading “Jag och mitt skal – Verktygslådan, introduktion och filosofi”

Jag och mitt skal – Introduktion till terminaler och shells

Denna video är ju rolig på sitt vis, många tar den säkert dock på allvar, och tror verkligen att terminaler och skal i *nix (Unix, GNU/Linux, BSD, jag kommer i fortsättningen skriva *nix) är något svårt och komplicerat att använda sig utav. Men så är det inte, terminalen, och skalet, är det Sanna sättet att använda en dator på, och är inget som är svårt, farligt, eller långsamt, tvärtom.
Continue reading “Jag och mitt skal – Introduktion till terminaler och shells”

How to set up a SIP trunk in the Asterisk PBX

In my previous article we configured Asterisk with some SIP-devices, and created a basic dialplan so that they could dial eachother. We also created two additional extensions for test purposes. This time I will show you how to configure a SIP trunk, and add extensions in the dialplan so that the telephones can dial out through the trunk. And if you also have a telephone number (DID) associated with the trunk, for others to be able to dial your phones, through your Asterisk PBX.

What is a SIP trunk?

A SIP trunk is often defined using many buzz- and marketing words throughout the web, but, what it basically is, is a two-way connection to a VOIP-provider, that routes the calls you send to it, out on the PSTN for you, and charges you for the calls you make. If you also have a DID (Direct Inward Dialing) number at the provider, calls made to you are forwarded to your Asterisk PBX, then you switch the calls as you see fit. Through a trunk, many calls can be sent, the limit is only your bandwidth and computer resources at the machine where your Asterisk runs, unless your VOIP-provider, or you for that matter, limit the number of calls in some way (by configuring the PBX at either end of the trunk), that are allowed to go through it. Continue reading “How to set up a SIP trunk in the Asterisk PBX”

An introduction to Asterisk, The Open Source Telephony Project

Asterisk is software that turns an ordinary computer into a voice communications server. Asterisk is the world’s most powerful and popular telephony development tool-kit. It is used by small businesses, large businesses, call centers, carriers and governments worldwide. Asterisk is open source and is available free to all under the terms of the GPL.

That is what the Asterisk website describes Asterisk as. I thought I should write a little about it, since it is quite a high first step, to start using and experimenting with it the first time, atleast I found it so, when I first did. Like with many things, there are good, and bad, documentation, and sources thereof. Sometimes both kinds are found in the same place, and it is up to you to judge on the quality. This is quite frustrating when you are looking for answers and don’t already know, or are able to judge, which is correct, and which is not.

Get the book

The first thing to start reading is Asterisk: The Future of Telephony, 2nd Edition, published by O’Reilly Media, Inc. and written by Jim van Meggelen, Jared Smith, and Leif Madsen. The book is  released under a Creative Commons license, it is available for free in PDF-, and HTML-form here. I suggest you buy the book in paper form though, as it is most often nicer to read a book away from the screen. But the PDF version is great as a reference when moving on with the configuration/experimentation.

I will now describe, in a how-to manner, to get you started, how to install Asterisk in Debian GNU/Linux, connect two SIP devices (telephones), and create a minimal dialplan so that they can call each other. I do not use any web-frontend or GUI, just the configuration files. You will find that it gives the best control and understanding of how things work, if you just take it one step at a time, and learn what you are doing.

What we need is:

  • A machine running Debian GNU/Linux
  • Asterisk itself (Asterisk is packaged in Debian.)
  • Two SIP telephones, “softphones”, or “hardware” telephones using SIP

I presume that you have basic knowledge of package installation and standard Unix tools, and know how to use a text editor of your choice. Allright, let’s begin.

Continue reading “An introduction to Asterisk, The Open Source Telephony Project”

Installing Debian Lenny on an Asus EeePC 900, part two

I have had my EeePC for a while now, and I have set it up how I want it, for the most part. When I wrote the first part, about installing Debian on an Asus EeePC 900, I wasn’t very detailed about what I had, or were going to do, to make it run as I liked. Hopefully that will be remedied now.

I have done a couple of things mentioned in the DebianEeePC wiki http://wiki.debian.org/DebianEeePC/ to reduce the disk writes to the SSD disk a bit.

Continue reading “Installing Debian Lenny on an Asus EeePC 900, part two”