2009年4月27日 星期一

Fix Backspace Key with GNU Screen on Arch Linux

it happens only in my x-windows terminal.

solution:

vi ~/.screenrc
--

bindkey -d ^? stuff ^H
bindkey -d ^@ stuff ^H

2009年4月22日 星期三

Some Error Messages Keep Appearing in Samba Log on Linux

printing/pcap.c:pcap_cache_reload(178)
Unable to open printcap file /etc/printcap for read!

printing/print_cups.c:cups_connect(103)
Unable to connect to CUPS server localhost:631 - Connection refused

solution:

load printers = no
printcap name = /dev/null
printing = bsd


lib/util_sock.c:get_peer_addr_internal(1676)
getpeername failed. Error was Transport endpoint is not connected

solution:

smb ports = 139

2009年4月20日 星期一

Set up Lighttpd, PHP, PhpMyAdmin, MySQL on Arch Linux

1. install packages

pacman -S lighttpd php phpmyadmin mysql

2. this script starts mysql daemon and also take care of the basic configuration as adding system users and creating log files

/etc/rc.d/mysqld start

3. force both mysql client and server to use utf8 encoding though not all kinds of clients read the setting

vi /etc/my.cnf
--

..
[client]
default-character-set = utf8
..
[mysqld]
default-character-set = utf8
..

4. it may be necessary to add a user and group for http. this user seems to need to have permissions to write to the /var/log/lighttpd

groupadd http
adduser http
chown -R http /var/log/lighttpd

5. lighttpd handles php through fastcgi so we have to enable it in /etc/lighttpd/lighttpd.conf

server.modules = (
..
"mod_fastcgi",
..
..
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/var/run/lighttpd/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
)
)

6. for php and phpmyadmin, edit /etc/php/php.ini as follows

..
cgi.fix_pathinfo=1
..
extension=mysql.so
..

6. sample phpmyadmin configuration

vi /srv/http/phpMyAdmin/config.inc.php

--
<?php
/* Servers configuration */
$i = 0;

/* First server */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['verbose'] = 'name_of_server';

/* End of servers configuration */

?>

7. start your web server

/etc/rc.d/lighttpd start

then enter the url, http://localhost/phpMyAdmin

2009年4月15日 星期三

Garbage Code in JAVA CJK Environment on Arch Linux

1. create /opt/java/jre/lib/fonts/fallback directory

2. make symbolic link for font

ln -s /usr/share/fonts/TTF/fontfile /opt/java/jre/lib/fonts/fallback/

if Wen Quan Yi, the full path is /usr/share/fonts/wenquanyi/wqy-zenhei/wqy-zenhei.ttc

2009年4月12日 星期日

7-Zip Command Line

the linux version of 7zip is called p7zip
usage of 7za in windows is totally same to 7za in linux
the help message of command line version isn't detailed enough so here is an example

7za a -t7z -m0=lzma -mx=9 -mfb=64 -md=64m filename.7z target

a: add files to archive
e: extract files from archive (without using directory names)
-t: type of archive
-m0 : compression algorithm
-mx : compression level, 0 = no compression, 9 = ultra
-mfb : number of fast bytes for LZMA
-md : dictionary size
-ms=on : solid archive

p7zip is able to extract rar archives, but you have to use the exact command 7z, neither 7za nor 7zr because they are light-weighted commands which don't load plugins

if you use ubuntu, there is a package named p7zip-rar. on arch linux, p7zip package also installs rar plugin to /usr/lib/p7zip/Codecs/Rar29.so

7z e filenamr.rar

Cannot Copy Text in Vim While Using Putty

vim automatically sets visual mode when you click mouse buttons

solution is to stop vim from interpreting the mouse clicks

set mouse=


or add this to ~/.vimrc

2009年4月10日 星期五

Static ARP Entry and Wake on Lan on Arch Linux

1. install wol package in community repository

pacman -S wol

2. wol works only if the target machine is in the arp table. so if not, manually add an entry to the table

arp -s HOSTNAME MACADDRESS

hostname must be in /etc/hosts

3. to load permanent arp entry at boot time, create /etc/ethers then add the command into /etc/rc.local

vi /etc/ethers
--

MACADDRESS HOSTNAME


vi /etc/rc.local
--

arp -f

-f: if no filename is specified, /etc/ethers is used as default

4. wake up some machine

wol -h HOSTNAME MACADDRESS

2009年4月9日 星期四

Set up MythTV Backend on Arch Linux and Watch TV on Windows Player

1. install the mythtv package

sudo pacman -S mythtv

2. import the database structure of mythtv to mysql

mysql -u root -p < /usr/share/mythtv/mc.sql

3. run setup as root or you'd get the message "Couldn't open /dev/v4l/video0 to probe its inputs."

sudo mythtv-setup

4. first time when you run mythtv-setup, it may ask you if upgrade the database schema, press yes, backup would be /tmp

5. General (the below setting is for taiwan)
TV format: NTSC
Channel frequency table: us-cable

6. Capture card (get these device number from dmesg, lspci, and lsusb)
Card type: Analog V4L capture card
Video device: /dev/videoX
VBI device: /dev/vbi0
Audio device: /dev/dspX
Default input: Television

7. Video sources
Listings grabber: No grabber
Channel frequency table: default

8. Input connections
Scan for channels: Video source must be pick first
Starting channel: remember to type a valid number

9. Storage Directories, at least one recording directory has to be added to the Default Storage Group or it will not be possible to watch/record anything. personally i set /tmp. to remove a storage group from the list, highlight it and press the 'D' key

10. user plans to watch analog tv only doesn't need to run mythfilldatabase?

11. start mythtv backend server

sudo /etc/rc.d/mythbackend start


12. go to mythtv front-end

mythfrontend

Utilities / Setup -> Setup -> TV Settings -> Recording Profiles -> Software Encoders (v4l based) -> LiveTV
change all of codecs from RTjpeg to MPEG-4

13. download MythTV Player which is the only one player for windows that allows you to play recordings and LiveTV directly from a MythTv backend.
http://www.sudu.dk/mythtvplayer/index.php

14. mythtv player accept protocol versions 15-31 originally. if your server speak newer or older than it, edit config.xml just change 0 to 1

<AcceptNewerProtocols>1</AcceptNewerProtocols>
<AcceptOlderProtocols>0</AcceptOlderProtocols>


i got some problems, frequent disconnect at the very first minutes, cannot continue playing after disconnect, suitable setting or bitrate for stream to internet.. to be continued

2009年4月8日 星期三

Install VirtualBox on Arch Linux

1. virtuabox needs fakeroot installed and its gui needs sdl

sudo pacman -S fakeroot sdl

2. install virtualbox personal use binary edition from aur

http://aur.archlinux.org/packages.php?ID=9753

3. add user to the vboxusers group

gpasswd -a USERNAME vboxusers

4. add vboxdrv, vboxnetflt( for host interface networking ), vboxnetadp( for host-only networking ) to the Modules array in /etc/rc.conf

5. add the following line to /etc/fstab if you want the vboxusers to have permission to emulate USB devices

none /proc/bus/usb usbfs auto,busgid=108,busmode=0775,devgid=108,devmode=0664 0 0

6. run "vbox_build_module" as root every time your kernel is upgraded

sudo /usr/bin/vbox_build_module

Autostart Applications in LXDE and Gnome

1. the desktop entry of program which you need run on session startup should be put in ~/.config/autostart

mkdir -p .config/autostart

2. create *.desktop or copy from what application you need from /usr/share/applications

[Desktop Entry]
Type=Application
Exec=command

2009年4月7日 星期二

Set up Xorg on Arch Linux

1. install xorg and your graphic card driver

sudo pacman -S xorg xf86-video-intel

2. auto-generate xorg.conf from detected result

Xorg -configure

3. DO NOT run test before hal or your keyboard and mouse will be freezed

Xorg -config filename

4. move the generated file to /etc/X11

sudo mv xorg.conf.new /etc/X11/xorg.conf

5. add the following setting to xorg.conf

vi /etc/X11/xorg.conf
--

..
Section "Module"
Load "glx"
..
..
Section "Monitor"
DisplaySize 336 210
..
..
Section "Screen"
SubSection "Display"
Modes "1280x800" "1024x768"
..

module glx is for 3d acceleration

in order to get correct sizing for fonts, the display size must be set for your desired dpi.
display size = (x|y)pixels * 25.4 / dpi
i'm running xorg with a resolution of 1280x800 and want a dpi of 96 so i use 1280 x 25.4 / 96 and 800 x 25.4 / 96

if you wish to use a lower resolution than your monitor is capable of, manually specify modes which you need only

6. edit /etc/rc.conf to load hal on boot

vi /etc/rc.conf
--

DAEMONS=(syslog-ng network netfs crond hal)

2009年4月6日 星期一

Unify Encoding of MySQL Clients on Ubuntu

it solves encoding of phpmyadmin and mysql cli aren't same.

sudo vi /etc/mysql/my.cnf
--

[client]
default-character-set = utf8