Convert Apple Lossless files to FLACs

Quick shell snippet to convert those Apple Lossless files to FLACs:


for filename in *.m4a; do
    avconv \
        -i "$filename" \
        -acodec flac \
        -compression_level 12 \
        "$(basename "$filename" ".m4a").flac";
done

Comments off

Configuring fingerprint reader in Ubuntu 13.04

Compared to Ubuntu 11.10, this is much-much easier. Just install PAM fingerprint module:

sudo apt-get install libpam-fprintd

No need to run pam-auth-update anymore, because fingerprint login is enabled immideately after the module is installed.

Final step is to enroll your fingerprints:

fprintd-enroll

Comments off

Ubuntu 12.04, LTSP ja ID-kaart

Juhend eeldab Ubuntu 12.04 desktop paigladust. Uuenda pakette:

apt-get update
apt-get dist-upgrade

Paigalda LTSP serveri metapakett, see paigaldab DHCP serveri ja muud LTSP jaoks tarvilikud teenused:

apt-get install ltsp-server-standalone

Seadista võrk failis /etc/network/interfaces, asenda 192.168.77.1 omale sobiliku IP-ga:

echo "auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
    address 192.168.77.1
    netmask 255.255.255.0" > /etc/network/interfaces

Asenda DHCP serveri seadistuste failis 192.168.0.0/24 alamvõrk:

sed -i "s/192\.168\.0\./192.168.77./g" /etc/ltsp/dhcpd.conf

Taaskäivita võrguteenused:

/etc/init.d/networking restart
/etc/init.d/network-manager restart
/etc/init.d/isc-dhcp-server restart
/etc/init.d/nbd-server restart

Paigalda modifitseeritud OpenSSH server LTSP serverisse:

add-apt-repository -y ppa:v6sa/ltsp-hacks
apt-get update
apt-get install -y openssh-server

Lisa Eesti ID-kaardi ametliku tarkvara varamu:

echo deb http://ftp.id.eesti.ee/pub/id/signed_repository/ubuntu precise main >
     /etc/apt/sources.list.d/ria-repository.list
wget https://installer.id.ee/media/install-scripts/ria-public.key -O - |
     apt-key add -
apt-get update
apt-get install -y estonianidcard

Lisa Xsession skript mis näitab uut PCSC-lite sokkli asukohta:

echo "export PCSCLITE_CSOCK_NAME=\$HOME/.pcscd.comm" > /etc/X11/Xsession.d/80-pcsclite

Loo terminali juurfailisüsteem:

MIRROR="http://fi.archive.ubuntu.com/ubuntu/" \
LANG=C \
ARCH=i386 \
ltsp-build-client

Sisene terminali juurfailisüsteemi:

chroot /opt/ltsp/i386 /bin/bash

Lisa modifitseeritud OpenSSH klient ka terminali juurfailisüsteemi:

apt-get install -y python-software-properties
add-apt-repository -y ppa:v6sa/ltsp-hacks
apt-get update
apt-get install -y openssh-client

Paigalda muud ID-kaardi jaoks tarvilikud komponendid

apt-get install -y pcscd

Uues PC-SC Lite teegis käivitatakse pcscd deemon automaatselt, see ei sobi LTSP jaoks:

sed -i "s/exit 0/#exit 0 # Reverted to 1.6.0 behaviour for LTSP/g" /etc/init.d/pcscd
touch /etc/default/pcscd

Lisa SSH kliendi seadistused, asenda 192.168.77.1 oma serveri IP-ga:

echo "Host 192.168.77.1
    RemoteForward [~/.pcscd.comm] :[/var/run/pcscd/pcscd.comm]" >> /etc/ssh/ssh_config

VIA terminalide UniChrome graafika tüürelite seis on suht halb seega ma lülitaks välja ka 3D kiirenduse:

echo "Section \"Module\"
    Disable \"glx\"
    Disable \"dri\"
EndSection" > /etc/X11/xorg.conf

Välju terminali juurikast

exit

Uuenda terminali juurfailisüsteemi SquashFS tõmmist:

ARCH=i386 ltsp-update-image

NB! Ubuntu Unity on üsna uimane LTSP peal, soovitan valida Gnome Classic (No effects) sessioni sisselogimishalduris.

No comment »

Ubuntu 10.04, LTSP ja ID-kaart

Vahepeal on mitu uut Ubuntu väljalaset olnud ning viimased ID-kaardi terminal-serveri paketid Ubuntule sai treitud 8.04 jaoks. Seekord siis Estobuntu 10.09 ehk Ubuntu 10.04 jaoks, seni olengi ainult Ubuntu Long Term Support väljalasetele neid teinud ning tihedamini vist ei hakkagi punnitama.

Serveri tarkvara paigaldus

Juhend eeldab Ubuntu Server 10.04 paigaldust. Kõigepealt paigalda LTSP paketid:

apt-get install ltsp-server-standalone python-software-properties ubuntu-desktop

Paigalda soovitud töölaud:

apt-get install ubuntu-desktop

Luba repositooriumid:

add-apt-repository ppa:lauri-vosandi/ppa
add-apt-repository ppa:esteid/ppa
apt-get update

Paigalda paketid:

apt-get install openssh-server libpcsclite1
    qdigidoc qesteidutil mozilla-esteid thunderbird-esteid

Lisa Xsession skript mis näitab uut PCSC-lite sokkli asukohta:

echo "export PCSCLITE_CSOCK_NAME=$HOME/.pcscd.comm" > /etc/X11/Xsession.d/80-pcsclite

Terminali tarkvara paigaldus

Paigalda terminali tarkvara serveri /opt/ltsp/i386 alla:

MIRROR="http://ee.archive.ubuntu.com/ubuntu/" \
EARLY_PACKAGES="ltsp-client" \
LANG=C \
ltsp-build-client --arch i386

Sisene terminali juurikasse:

chroot /opt/ltsp/i386

Uuenda pakettide nimekirju:

apt-get install python-software-properties
add-apt-repository ppa:lauri-vosandi/ppa
add-apt-repository ppa:esteid/ppa
apt-get update

Paigalda modifitseeritud paketid:

apt-get install openssh-client pcscd libccid

Lisa SSH kliendi seadistused, asenda 192.168.0.21 oma serveri IP-ga:

echo "Host 192.168.0.10
    RemoteForward [~/.pcscd.comm] :[/var/run/pcscd/pcscd.comm]" >> /etc/ssh/ssh_config

Välju terminali juurikast

exit

Uuenda võrgust laetavaid tõmmiseid

ltsp-update-image --arch i386

Comments (1) »

Firefly Media Server and Banshee

If you have more than 10k audio tracks on your NAS box, reading all the metadata is rather slow via Samba or NFS. There are various ways to access multimedia over LAN, DLNA/UPnP is good enough for videos, Digital Audio Access Protocol is better for audio. DAAP originates from Apple’s iTunes, it is based on HTTP and most of the Free Software implementations are actually reverse engineered, because Apple hasn’t exactly provided proper documentation if I am not mistaken.

There are various DAAP servers besides iTunes itself, the most used one seems to be mt-daapd. The author of mt-daapd has abandoned the project and there’s a bunch of forks on the web: Firefly Media Server, the more up-to-date forked-daapd and probably others.

DD-WRT’s Optware repository contains mt-daapd and mt-daapd-svn packages, first one seems to be pretty much obsolete version, the second one seems to carry Firefly Media Server branding. That’s also the package I got working on my router. The configuration for those of you who are interested sits in at /opt/etc/mt-daapd/mt-daapd.conf:


[general]
web_root = /opt/share/mt-daapd/admin-root
port = 3689
admin_pw = mt-daapd
db_type = sqlite3
db_parms = /mnt/disc0-part1/.mt-daapd
mp3_dir = /mnt/disc0-part1/Muusika
servername = Firefly on rt-n16
runas = nobody
extensions = .mp3,.m4a,.m4p,.flac,.ogg
logfile = /mnt/disc0-part1/.mt-daapd/mt-daapd.log
rescan_interval = 0
always_scan = 0
scan_type = 0
compress = 0

[plugins]
# Banshee fails to play transcoded FLAC stream so I disabled
# ssc-ffmpeg.so and ssc-script.so plugins by deleting them
plugin_dir = /opt/lib/mt-daapd/plugins

[scanning]
process_playlists = 0
process_itunes = 0
process_m3u = 0

Once started Firefly Media Server scans the music directory for audio files, stores meta-information and afterwards starts listening on port 3689, that’s also the standard port for DAAP. You can fire up a browser and see how it’s doing, the login in this case is admin and mt-daapd. The web interface seems to be the “right” place to shut down the media server because the process is not properly handling SIGTERM or SIGKILL, you can also reinitiate the scan from the web interface.

Now once Firefly is up and running, you can connect to it using iTunes, but being an open-source zealot, I don’t have much Apple gear lying around! On Ubuntu you can try out Rhythmbox, and it’s buggy bro Banshee. Banshee is written in C# and those guys have written some funky code that exposes it’s local cache and what not on http://localhost:8089. Note that Firefly by default transcodes FLAC and OGG to uncompressed WAV, but Banshee doesn’t play with that well.

For all the hackers out there: having a HTML5 based player interface in Firefly would be a bliss!

No comment »

Configuring fingerprint reader for Ubuntu 11.10

Here’s another hopefully useful how-to for getting Thinkpad T420 fingerprint reader running under Ubuntu 11.10:

Install required packages:

sudo apt-get install fprint-demo libpam-fprint

Add udev rule for setting the group ownership of fingerprint reader device:

echo "ATTRS{idVendor}==\"147e\", ATTRS{idProduct}==\"2016\", MODE=\"0664\", GROUP=\"fingerprint\"" \
    | sudo tee /etc/udev/rules.d/99-fingerprint.rules

Create group and add user to that group:

sudo groupadd fingerprint
sudo gpasswd -a lauri fingerprint

Reconfigure PAM and enable “Fingerprint reader”:

pam-auth-update

Reboot the machine so the udev would create the fingerprint reader device node with proper permissions. At the moment I am not familiar how to force udev to recreate the node and unplugging the fingerprint reader is not “feasible”.

Finally scan your fingerprints:

fprint_demo

Both, authentication in the login manager and sudo, should work with fingerprints now!

No comment »

Configuring Evolution for Gmail

There’s many different guides for setting up Evolution for Gmail, but I haven’t found a perfect one. So here goes yet another one:

Receiving mail

Server type: IMAP+
Server: imap.gmail.com
Port: 993
Username: first.last@gmail.com
Use secure connection: SSL encryption
Authentication type: Password

Sending mail

Server type: SMTP
Server: smtp.gmail.com
Port: 587
Server requires authentication: yes
Use secure connection: SSL encryption
Authentication type: Login
User Name: first.last@gmail.com

No comment »

Bricking Samsung Galaxy S2

Hey everyone, it has been a long time since my last post. There’s much fuss around installing custom firmware on Samsung Galaxy S2, so I wanted to figure out how it exactly works.

First of all most Android customized ROM’s, eg. CyanogenMod, VillainROM, DarkyROM aren’t exactly ROM images, they’re zipped filesystem overlays of the original stock firmware root filesystem. This means that in order for the customization to work, you first need to have properly booting stock firmware.

To install these customizations you need to have a rooted phone. Rooted phone basically meanss that you can run the classic UNIX command “su” to become the root user. There are hacked kernel images available on the XDA developers for various versions of Galaxy S2.

Utilities called Odin and Heimdall are available for directly manipulating the built-in flash storage of Samsung Galaxy phones. Odin seems to be available only for Windows so it’s out of the scope of this blogpost. Heimdall is a cross-platform command-line utility with similar purpose.

Rooting Samsung Galaxy S2 is easy as booting it into the download mode, this means turning the phone off and holding Volume down and Home buttons while powering up the phone and uploading the hacked kernel using Heimdall:

# This kernel should work with stock Android 2.3.4 firmware of Galaxy S2 sold in Europe
http://attachments.xda-developers.com/attachment.php?attachmentid=651559&d=1310388033 \
    -O CF-Root-SGS2_XX_OXA_KG1-v4.1-CWM4.zip
unzip CF-Root-SGS2_XX_OXA_KG1-v4.1-CWM4.zip
tar xvf CF-Root-SGS2_XX_OXA_KG1-v4.1-CWM4.tar
echo "3a70ced0c96d947b4cb1983dcebd1584 zImage" | md5sum -c -
sudo heimdall flash --kernel zImage

The yellow warning sign is shown while booting with the hacked kernel – it’s okay. The hacked kernel image also installs two apps: ROM Manager and Superuser. First one allows the user to (re)boot into ClockworkMod Recovery. It is also possible to directly boot into ClockworkMod Recovery, just hold Volume up and Home while powering up the phone. It is always good idea to back up the current system. Move around in the ClockworkMod Recovery menus with volume up/down buttons.

The phone’s internal flash storage is called “SD Card” in the ClockworkMod Recovery although it’s not an actual SD card plugged into the SD card socket, so this means that you don’t need an SD card to install custom ROM. While running ClockworkMod, it is possible to mount the internal flash storage to your PC, this way you can upload the ROM zip to your phone. Once having the right zip file in your phone just select “Install zip from sdcard” while running ClockworkMod Recovery.

There are many custom ROM’s for Galaxy S2, the most popular CyanogenMod seems to be built from scratch and does not have the optimizations enabled for S2, it’s also rumored that is does not have support for hardware accelerated video decoding. I haven’t tried out VillainROM yet, but DarkyROM that is based on the original Samsung firmware seems to be running just fine.

OH AND OF COURSE YOU VOID ANY WARRANTY IF YOU FLASH ANY FUNKY STUFF ON YOUR PHONE

VillainROM
Darky’s ROM
Hacked kernels with CWM and SU on XDA developers
Heimdall
Root Galaxy S2 with Heimdall on Linux
Tips at CyanogenMod
Default PIT (Partition Information Table)

No comment »

Reedeõhtune virin ketaste teemal

Alustaks siis seekord tavalistest kõvaketastest. Arvutimaailma tundvad inimesed teavad et 1 kilobait = 1024 baiti, 1 megabait = 1024 * 1024 = 1 048 576 baiti ning 1 gigabait = 1024 * 1024 * 1024 = 1 073 741 824 baiti. Kui nüüd tähti närida siis õigem oleks kasutada 1024 astmete jaoks termineid kibibyte, mebibyte, gibibyte aga IT-inimeste seas pole see vedu võtnud. Küll aga kõvakettatootjad on aga otsustanud kõvaketaste mahtuvust mõõta “õigetes” SI-ühikutes. Praktikas tähendab see seda, et 1000GB ketas ongi ligilähedal miljardile baidile:

lauri@localhost:~$ fdisk /dev/sdb
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

Tehes siit nüüd kiire arvutuse ja eeldades, et failide suurusi mõõdan ma ikka 1024 kordsetena nagu normaalne arvutikasutaja, tuleb välja et oma arust makstud 1000GB asemel saan ma kettale kirjutada 931GB andmeid ning 69GB jagu on mulle tünga tehtud! Protsentides oleks see umbkaudu 7% jagu.

Minnes edasi nüüd SSD ehk pooljuhtketaste juurde, siis asi on veel absurdsem. Ketastele peale märgitud suurused nt. 128GB väljendavad füüsiliselt kasutatavat andmemahtu, tegelikkuses on pooljuhtketaste omapäraks see, et osad plokid hapnevad kirjutustsüklite ammendumisel. Selle raviks on tarbija makstud ruumist eraldatud mingi hulk plokke, nt 8GB remap-imise jaoks. Kasutaja jaoks on seetõttu partitsioneeritav ainult 120GB:

lauri@localhost:~$ smartctl -i /dev/sda
smartctl 5.40 2010-10-16 r3189 [x86_64-redhat-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net
 
=== START OF INFORMATION SECTION ===
Device Model: ADATA SSD S599 128GB
Serial Number: 00000000000000000082
Firmware Version: 3.1.0
User Capacity: 120,034,123,776 bytes
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: ATA-8-ACS revision 6
Local Time is: Sat Apr 30 00:29:14 2011 EEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
 
lauri@localhost:~$ fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 120.0 GB, 120034123776 bytes

Maakeeli tähendab see seda et makstud 128GB asemel saan ma kasutada vähem kui 112GB. Protsentides tähendab see umbkaudu 13% tünga. Remap ala suurus sõltub tootjast, ADATA omadel rohkem, OCZ omadel vähem. OCZ pooljuhtketaste jaoks leidus ka püsivara uuendamise tarkvara Linux jaoks erinevalt ADATA-st.

Kokkuvõttes üsna ebameeldiv kuidas tarbijaid lollitatakse numbritega …

No comment »

Räniorg

Seekord siis jälle üks rääkimata lugu. Märtsi lõpp kuni aprilli algus käisime Ettevõtluse Arendamise Sihtasutusega USAs, täpsemini Silicon Valleys, Kalifornia osariigis.

Alustada võiks ehk ettevalmistustest – USAsse minekul on kaks varianti, kas biomeetriline pass või traditsiooniline viisa. Biomeetrilist passi sai teha kodakondsus- ja igratsiooni ametis, nüüdsest on KMA liidetud kokku Politsei- ja Piirivalveametiga. Maksma läheb ta umbkaudu 30€, kiirpassi varianti pole mõtet võtta, sest lubatud kuu asemel saab passi kätte paari päevaga ka tavamenetluses. Järgmine samm on ESTA (Electronic System for Travel Authorization) avalduse täitmine, mille eest küsitakse 14 USD ehk umbkaudu 10€. Veider on see et Eestil peaks olema viisavabadus USAga kuid ESTA avaldus näeb väga välja viisa moodi, ärge unustage siis “have you been involved in terrorist activites” juures märkida “no”.

Meie lend läks läbi Munichi/Münheni, Tallinnast sinna lend kestab umbkaudu 2-3 tundi. Peale seda järgnesid piinarikkad 8 tundi oodates ühenduslendu ning kogu lend kulmineerus 12 tunnise transatlantilise lennuga kus jalgu liigutada ega ka magada ei saa sest aknast paistab päike ning me lendame päikesega kaasa. Kui meil on siin hetkel 22:31 õhtul siis neil on seal päeval 12:30, mis tähendab et sinna jõudes on unetsükkel täiesti sassis ja tõenäoliselt ärkad hommikul kell 5 hommikul üles mõttega “okei mis nüüd?”. Moodsas keeles nimetatakse seda nähtust jet lagiks aga see selleks.

Esimesteks päevadeks oli planeeritud O’Reilly korraldatud Web2.0 EXPO kus oli mitmeid huvitavaid seminare ning erinevad startupid oma putkad püsti ajanud kus nad oma nänni jagasid ja maakeeli külastajaid spämmisid. Õhtustel aegadel toimusid konverentsihoones ja kõrval business networking üritused. Astusin ka mina siis korraks oma koorikust välja, networkisin ja tutvustasin Povi ning meie tegemisi. Suhtlusvõimete overclockimise jaoks oli õnneks tasuta õlut!

Peale konverentsi käisime külas Google peamajas, kus meile tegi väikese intro Chris DiBona rääkides Google edulugu avatud lähtekoodiga tarkvara kasutamisest Google infrastruktuuris. Kokkuvõttes oli jutt umbes selline et Oracle andmebaasitarkvara ka kõige soodsama pakkumise juures oleks olnud kordades kallim kui avatud lähtekoodiga tarkvara kohandamine Google vajaduste tarbeks. Teine oluline aspekt oli ka see et Google ei ehitanud oma taristut üles traditsioonilisele kallile serveririistvarale, vaid kasutas odavat PC riistvara ning lahendas kõik sellest tulenevad probleemid tarkvaras. Chris DiBona on muuseas ka üks Google Summer of Code organisaatoritest ja intervjuu temaga leiab GSoC kodulehelt. Sealses Google kontoris on tööl ka neli eestlast.

Sain läbi astutud ka Kalifornia ülikooli Berkeley osakonnast. Sellest ülikoolis on näiteks avastatud 8 keemilist elementi ning Nobeli preemia laureaatidel on tasuta parkimine. Ühiskohtumine oli Stanford ülikooli professori Keith Devliniga kes ühel slaidil tõi välja ka Stanfordi aastase 3 miljardi dollarilise ehk umbkaudu 33 miljardi kroonise eelarve, võrdluseks oli Eesti riigi eelarve aastal 2008 umbkaudu 85 miljardit krooni.

Kokku olime USAs umbkaudu 10 päeva, mille aja jooksul sai päris palju huvitavat nähtud ja kogetud. Kalifornia pole kindlasti stereotüüpne USA, mingil määral ehk sarnane Amsterdamiga kus on palju kohanenud sisserändajaid, ettevõtlus vohab ning kanepi omamine on legaalne.

No comment »