-
Convert file extensions to lower case (rename, Linux shell script)
Posted on November 20th, 2012 5 commentsI am using Unison more and more, and recently I decided to try to use it to keep my digital image archive synchronized. It seems that at some time I have not explicitly instructed the image importing program of the day (Shotwell being the program I mostly use) to rename the image files in order to consequently use a lower case file extension.
Thus I felt the need to rename all image files (in the shotwell folder) to a lower case file extension. There may or may not be a program out there to do this, but I wrote my own shell script for this purpose. My experience is that I learn more by doing it myself, and a lot of the tricks I learn can be reused the next time.
This is how I did it, I cannot promise that it will work for anyone else (indentation lost in WordPress):
#!/bin/sh
imgdir=‘pwd‘
imgucext=$(find ${imgdir} –type f –name ‘.’ | awk –F’.’ ‘NF > 0 { print $NF }’ | sort | uniq | LC_ALL=C egrep ”[[:upper:]]”)
for ucext in ${imgucext}
do
lcext=$(echo ${ucext}|awk ’{print tolower($0)}’)
find ${imgdir} –type f –name “.${ucext}” –print | \
sed ’{s/ /\\ /g}’ – | \
sed ’{s/(/\\(/g}’ – | \
sed ’{s/)/\\)/g}’ – | \
sed ”{s/\(.\.\)${ucext}$/mv –n –v \1${ucext} \1${lcext}/g}” – | \
sh
done
Starting in the current folder/directory, I check what upper case extensions are present, find all files using them, rewrite spaces and parenthesis for the shell, and create a rename command for each file, which is then piped to the shell. For debugging purposes the sh close to the end would be substituted for a cat. -
USB sound on Alix running Voyage
Posted on May 18th, 2011 1 commentI thought that using a USB sound card with Linux would be easy, just plug and play, but I was wrong, it seems. Plugging in the Terratec Aureon Dual USB (ID: 0ccd:0077) that I bought rendered a promising output from dmesg and lsusb, and lsmod showed that even relevant modules were loaded. The problem was that mpd and other programs did not find any way to actually output sound to any device. They had the firm belief that my system was lacking any sound card. Maybe I would need some sound related packages?
aptitude install alsa-base alsaplayer alsaplayer-text alsa-utils
No luck… The mpd configuration file /etc/mpd.conf seemed mostly confusing when it came to output devices, and the wiki page it referred to did not help either. A search with Google on the USB ID was helpful though, as usual. Someone with the alias BigRon also had problems with Debian and this Terratec USB sound card. The results from his attempts, documented with verbose output, was similar to mine. User bandan’s reply was the beginning of the end of my trouble! I had to edit /etc/modprobe.d/alsa-base.conf to comment out a line preventing USB devices from becoming the first (default) device, substituting it for a line with the opposite effect.
## Keep snd-usb-audio from beeing loaded as first soundcard<br/> #options snd-usb-audio index=-2
# Fix from http://forum.doozan.com/read.php?2,4119,4166<br/>- Allow snd-usb-audio to be loaded as first soundcard options snd-usb-audio index=0
Now I was at least able to get alsamixer to acknowledge the mere existence of a sound related device, but alas it chose an input only device (most likely my Logitech webcam with microphone) as the default device even though it called the Terratec one default by name. Luckily for me the just mentioned forum thread linked to a more substantial thread describing the problem in more depth. I added myself and the mpd user to the audio group, to make sure that there would not be any problems with permissions regarding the devices
addgroup jadler audio addgroup mpd audio
I was still unable to play anything (without explicitly chosing what Alsa refers to as sound card 1). So I kept trying the stuff that had worked for the person reporting in the forum, creating an /etc/asound.conf file with basically the same content as suggested in the last thread referred to above, but changing all references to hw:0 to hw:1, and from card 0 to card 1. Now mplayer works, but I still can’t get mpd to do its thing. -
Alix2d13 — Voyage Linux or Debian Live?
Posted on May 12th, 2011 No commentsI am not sure whether it is caused by the Ubuntu 10.10 amd64 running on my workstation or on some bug in the Emdebian package, but I do have a hard time to get Emdebian installed. I have tried Multistrap, Debootstrap, and Debian Installer, and I have done it on the Alix computer using PXE boot, on my workstation (followed by chroot etc), and on virtual machines using qemu/kvm or Virtualbox, but so far no luck.
All of this makes it less and less attempting to actually install any Emdebian based Debian, and so I gradually turned back to Voyage Linux. When I was browsing the Voyage site I learned about Debian Live, the system that “punkytse” uses to create the Voyage images, and also offers for download under tha name “Voyage SDK”. So now I am testing Debian Live and trying to learn more about it.
The wiki and the manual seems to be a good place to start when learning about Debian Live.
For those interested in PC Engines Alix the Alix forum may also be a good source of information.
(I should really find a better WordPress theme, I know…)
-
Installing Linux on PC Engines Alix2d13 (part 2.5)
Posted on May 10th, 2011 No commentsAfter publishing I realized that I could have supplied more information, and more downloads, than I did in my previous post.
Here are links to patched versions of Debian netboot.tar.gz (stable/Squeeze, testing/Wheezy and daily build), all downloaded and patched today, 2011-05-10:
- netboot-ttyS0-stable-110510.tar.gz
- netboot-ttyS0-testing-110510.tar.gz
- netboot-ttyS0-daily-110510.tar.gz
I have also made a diff file for the stable mod.What my script does, basically, is this:
- Untar the tarball and cd to debian-installer/i386/boot-screens/ where all changes are made.
- In the file syslinux.cfg (which is actually a file with PXELINUX configurations) two lines are added:
- serial 0 38400—telling PXELINUX to use ttyS0 for I/O (i.e. as console).
- console 0—do not try to use any video console
- In the files adtxt.cfg, rqtxt.cfg and txt.cfg substitute any occurence of vga=788 for ttyS0,38400n8. This is done in order to tell the kernel that:
- There is no graphic/video console
- The console that should be used is the first serial port, and with the specified settings.
This is a simplification, since my script also includes a variable for the number of the serial port, in case your console is not on ttyS0. I have not included any such convenience regarding speed and other settings for the serial port chosen. -
Installing Linux on PC Engines Alix2d13 (part 2)
Posted on May 8th, 2011 No commentsI have found it to be quite nice to be able to boot the Alix board over the network using PXE. Using the Debian netboot.tar.gz tarball and TFTP I can boot the Debian Installer or a rescue system, and the former lets me install Debian Linux without physically touching the CF.
In order to make netboot use the serial port as console I have patched the Debian netboot tarball, and I made a script that does all the patching, just for you…
I have tested it with the Debian stable and testing netboot.tar.gz downloaded today and it works, and also with the daily snapshot from Debian installer.
The script will modify the file syslinux.cfg in order to make PXELinux use the serial port, and the files adtxt.cfg, rqtxt.cfg and txt.cfg to make sure that the Linux kernel (actually the Debian installer in this case) also uses the serial port as console. (Look at the script to see the actual changes. You should of course have a look at it before running it, anyway.)
Making my ancient Netgear WGT634U running OpenWRT serve PXE images was really a no-brainer. In the Services/Dnsmasq page I entered the three choices shown below, with the patched netboot untarred on a USB stick mounted on /mnt/sda2.
References (other that links above):
- http://www.debian.org/releases/stable/i386/ch04s05.html.en—about setting up a TFTP server for netboot.
- http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html—as above, for dnsmasq
- http://www.debian-administration.org/articles/478—more on dnsmasq
- http://etherboot.org/wiki/dnsmasq—even more on dnsmasq and PXE
Some more patching lets me use preseeding too, but more on that another time.


