Category Archives: linux

Zoneminder can’t chmod /dev/videoN, operation not permitted, and not starting at boot

Zoneminder has reached its current peak with version 1.24.2 since quite some time, so you can finally get it off the official repositories of Ubuntu, instead of finding then the older 1.23 as it was at the time of Jaunty, when you had to compile off the source.

Running configure and make install comes with the added benefit of making you feel nerdy, but it’s still a pain, and why doing it when you can download a deb to install it automatically?

So well, when I installed off the repos in Lucid everything went fine since the beginning, I only had to load http://localhost/zm in Firefox to get it going.

This time after upgrading to Maverick (on a new hard disk, so new fresh install), I instead faced some errors.

First I couldn’t get to the console URL, but this thread at UbuntuForums gave the solution:

sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf

to create a link between Apache’s configuration file and Zoneminder’s shipped one, and then

sudo /etc/init.d/apache2 reload

to have Apache refresh its configuration from said file; after this, the console’s web GUI can be reached under the /zm subfolder of the webserver root.

Then, I had another problem where the sources appeared red no matter what; enabling debug I found an error relating to zmfix not being able to apply a chmod on /dev/videoN, since the operation was not permitted. Manually doing:

sudo chown www-data /dev/video*

and restarting zoneminder with

sudo /etc/init.d/zoneminder restart

solved it, but didn’t survive a reboot, as the ownership of /dev/video* goes back to root:video.

What did it for me was a:

sudo adduser www-data video

as suggested in this topic on ZoneMinder forums.

So this solved the operation not permitted error, but I was still getting an unresponsive ZoneMinder console after reboot, the status was reported as “Stopped”, and after manually starting it all went fine; there had to be something preventing ZoneMinder from properly and automatically start right after first run, so searching I found a tip in ZoneMinder Wiki, that suggested the problem lying in Ubuntu starting ZoneMinder so soon that MySQL wasn’t ready yet; delaying the start of ZoneMinder solves this, so you just need to add

sleep 15

before

zmfix -a

in the ZoneMinder startup script, which is, in the standard repository installation, /etc/init.d/zoneminder

Enjoy your videosurveillance!

sudo /etc/init.d/apache2 reloadsudo /etc/init.d/apache2 reload

Extract string between two tokens inside a text in bash shell scripting

The other day, as a total newbye, I was writing a script in bash to process an HTML page, look for a URL inside it, and then download the content at that URL, recursively for a series of pages; I had it already done in AutoHotKey language, but since I don’t keep my Windows workstation always on, while my linux homeserver is, I decided I was better off learning a little of bash language to make the procedure more efficient.

In this script I need to extract a segment of string between two known “tokens”, in order to get the needed URL off the HTML page; in AutoHotKey I saved the string position inside the text for both of the tokens, and then did a precalculated substring operation between those two offsets, and was obviously looking to do the same in bash, as I was translating step-by-step from AutoHotKey.

With my big surprise, this is not possible, as the only operation to search for a string inside another string, actually searches only for the first occurrence of the first caracter of the key string; in other words, you can search for “my” inside “The mellow fur of my cat is brown”, but the result would be 4, and not the expected 18, because as said expr index "$string" $substring only matches the first character of substring, hence the first position of “m” inside the string.

Now, I didn’t really care to find the position of those tokens, I only cared about the string in the middle, so any other operation that did the trick was fine; alas, I realized it only after about a hour of wasting time, but in the end I came up with the solution, and I am publishing it here to save time to other wanderers.

It basically consists in stripping from the string everything that is before the first token (including first token), and then stripping, from the result of this first operation, everything that is after the second token (including the second token):

#variables declaration
text="longtexttoprocess"
firsttoken="something"
secondtoken="somethingelse"

#actual processing
middlestring=${text#*$firsttoken}
middlestring=${middlestring%%$secondtoken*}

This returns $middlestring as the string contained between the first occurrence of $firsttoken (single # symbol), and the first occurrence of $secondtoken (double %% symbol, indicating the farthest occurrence from the end of string).

  This article has been Digiproved

WinKey+Ubuntu, cool! Windows Key keyboard shortcuts in Maverick Meerkat

Maybe I’m posting about nothing new, and if that’s the case, I beg your pardon. Not.

’tis my website and I can write whatever I like.

Anyway I just completed the update of Ubuntu to Maverick Meerkat on my laptop, and well, I was trying to get to the desktop with the good old Ctrl-Ald-D combo, but it didn’t work. Hammered those keys at least 5 times to make sure, but then my lateral thinking suggested me to do WinKey+D instead (the combo I tried the very first time I used Ubuntu), and that worked!

So I went into a Windows Key frenzy, and tried, like, every combo I could test.

Here are my findings:

WinKey+W, WinKey+A
Show all windows in a tiles fashion

WinKey+D
As I said, goes to desktop

WinKey+Tab
A very cool version of the Alt-Tab

but here are the cool ones:

WinKey+MouseWheelUp/Down
Zooms in/out the whole screen, moving the mouse shifts  the view, and
WinKey+MouseWheelClick
Zooms in all the way

WinKey+M, WinKey+N
Negative colour! Useless for practical uses, anyway the N combo renders negative only the currently active window space, while M makes negative everything onscreen.

D5DF1FB7827AEF908CAA513321D2–>

Starcraft under Wine freezes, hangs and crashes at random interval

After having played Starcraft II on my Windows 7 desktop, yesterday I was trying to get the first Starcraft to work on my laptop under Ubuntu Lucid with Wine; the wine-hq website reported the game as perfectly working, and in fact I only needed to install a patch to let the game start without the mounted CD, but no matter if I tried to play with original Starcraft or the Brood War expansion, I always got random freezes: the game just hung up after a while, it freezed either on the menu or in the playing screen, the cursor wouldn’t respond anymore and all the screen stopped; the audio seemed to be fine though, because sound kept on playing.

I tried changing almost everything under wine configuration, enabling windowed mode with virtual desktop or disabling it, enabling or disabling hardware acceleration and all the other checkboxes under “Graphics” tab. I tried setting up the audio driver… no matter what I did I still got the random freezes.

Until I tried adding a couple of registry values that were reported in the Wine forum for that game but weren’t apparently addressing this particular issue.
Anyway, after adding these keys, I was able to end the first level and go through almost all the second one (time for lunch now) without a glitch, except for the occasional sluggishness.
Run wine regedit and add these couple values under:

HKEY_CURRENT_USER > Software > Wine > Direct3D

The values are two REG_SZ strings:

DirectDrawRenderer = opengl
RenderTargetLockMode = readtex

Should work for you too.

  This article has been Digiproved

Enable XGA 1024×768 resolution in Ubuntu Linux for Compaq Presario 1800

[7.4.2009] I installed Linux flavor Ubuntu Jaunty Jackalope on a very old Compaq Presario 1800, to make it into a small internet station. What I absolutely don’t like about the system is the fact that 64MB of the installed 256MB of RAM are wasted for the UMA (Unified Memory Architecture), that is are used on a videocard (ATI Rage Mobility M3) which is so dam old that you are not going to need it to play games, so the dedicated 8MB of video memory, as per specifications, are much more than enough for 2D display, and the added memory goes literally to waste. But what really startled me is the apparent impossibility to make the screen reach the XGA resolution it’s made for, 1024×768, no matter whatever lines I added to the xorg.conf file.

After half a day worth of fruitless searches, I found a page with a bug report on launchpad, regarding another display issue with a Presario 1800T, that incidentally let me enable XGA with a xorg.conf, so I decided to report the guide here for posterity, in a page easier, much easier, to find in a Google search.

Following you find the code to paste inside the /etc/X11/xorg.conf file overwriting whatever its content may be. If you have no idea how to do that (I am supposing you’re using the vanilla flavor of Ubuntu, with the Gnome desktop), press Alt-F2 from desktop, and in the dialogue write (respecting letter case):

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

to create a backup copy of the configuration file (you’ll be asked your system password), as you never know, and after that once again Alt-F2 and:

sudo gedit /etc/X11/xorg.conf

a text editor will appear, and you have to delete the whole contents of it, and paste the code you find in this page.

# /etc/X11/xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the /etc/X11/xorg.conf manual page.
# (Type "man /etc/X11/xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following commands:
#
#   cp /etc/X11/xorg.conf /etc/X11/xorg.conf.custom
#   sudo sh -c 'md5sum /etc/X11/xorg.conf >/var/lib/xfree86/xorg.conf.md5sum'
#   sudo dpkg-reconfigure xserver-xorg

Section "Files"
    RgbPath		"/usr/lib/X11/rgb.txt"
	FontPath	"unix/:7100"			# local font server
	# if the local font server has problems, we can fall back on these
	FontPath	"/usr/lib/X11/fonts/misc"
	FontPath	"/usr/lib/X11/fonts/cyrillic"
	FontPath	"/usr/lib/X11/fonts/100dpi/:unscaled"
	FontPath	"/usr/lib/X11/fonts/75dpi/:unscaled"
	FontPath	"/usr/lib/X11/fonts/Type1"
	FontPath	"/usr/lib/X11/fonts/CID"
	FontPath	"/usr/lib/X11/fonts/100dpi"
	FontPath	"/usr/lib/X11/fonts/75dpi"
        # paths to defoma fonts
	FontPath	"/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
	FontPath	"/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
EndSection

Section "Module"
    Load	"dbe"
    SubSection  "extmod"
      Option    "omit xorg-dga"   # don't initialise the DGA extension
    EndSubSection
	Load	"freetype"
	Load	"glx"
    Load	"type1"
    Load	"dri"
EndSection

Section "InputDevice"
	Identifier	"Generic Keyboard"
	Driver		"keyboard"
	Option		"CoreKeyboard"
	Option		"XkbRules"	"xorg"
	Option		"XkbModel"	"pc104"
	Option		"XkbLayout"	"us"
EndSection

Section "InputDevice"
	Identifier	"Configured Mouse"
	Driver		"mouse"
	Option		"CorePointer"
	Option		"Device"		"/dev/input/mice"
	Option		"Protocol"		"ImPS/2"
	Option		"Emulate3Buttons"	"true"
	Option		"ZAxisMapping"		"4 5"
EndSection
Section "InputDevice"
        Identifier      "Synaptics Touchpad"
        Driver          "synaptics"
        Option          "SendCoreEvents"        "true"
        Option          "Device"                "/dev/psaux"
        Option          "Protocol"              "auto-dev"
        Option		"HorizScrollDelta"	"0"
EndSection

Section "Device"
    Identifier  "ati"
    Driver      "ati"
EndSection

Section "Monitor"
    Identifier  "Generic Monitor"
    HorizSync   31.5 - 48.5
    VertRefresh 50-70
EndSection

Section "Device"
    Identifier	"Standard VGA"
    VendorName	"Unknown"
    BoardName	"Unknown"
    Driver     "vga"
EndSection

Section "Screen"
    Identifier  "Default Screen"
    Device      "ati"
	Monitor		"Generic Monitor"
	DefaultDepth	24
	SubSection "Display"
		Depth		1
		Modes		"1024x768" "800x600" "640x480"
	EndSubSection
	SubSection "Display"
		Depth		4
		Modes		"1024x768" "800x600" "640x480"
	EndSubSection
	SubSection "Display"
		Depth		8
		Modes		"1024x768" "800x600" "640x480"
	EndSubSection
	SubSection "Display"
		Depth		15
		Modes		"1024x768" "800x600" "640x480"
	EndSubSection
	SubSection "Display"
		Depth		16
		Modes		"1024x768" "800x600" "640x480"
	EndSubSection
	SubSection "Display"
		Depth		24
		Modes		"1024x768" "800x600" "640x480"
	EndSubSection
EndSection

Section "ServerLayout"
	Identifier	"Default Layout"
	Screen		"Default Screen"
	InputDevice	"Generic Keyboard"
	InputDevice	"Configured Mouse"
	InputDevice	"Synaptics Touchpad"
EndSection