USB trên Mac OS X

26 07 2008

Một lý do khác USB không mount là IOUSBMassStorageClass kext không được load trong quá trình startup. Trong terminal gõ các lệnh sau:
sudo –s gõ password (lưu ý khi gõ password nó sẽ ko hiện ký tự theo sau và bạn phải tắt chế độ gõ tiếng Việt )
kextstat | grep “USB”
Trong list hiển thị không thấy load com.apple.iokit.IOUSBMassStorageClass
Các bạn gõ lệnh sau để load:
kextload -b com.apple.iokit.IOUSBMassStorageClass
Bấy giờ kext đã được load và hoạt động.
Mặc dù kext đã được load nhưng mỗi lần bạn muốn USB làm việc phải gõ lại các lệnh trên cho mỗi lần khởi động. Để hệ thống tự động load mỗi khi khởi động các bạn nên dùng Lingon 2.1 để tự động hóa vấn đề này.
Download Lingon 2.1 tại đây

Sau khi down về copy để nó vào thư mục Application Mở Lingon -> View -> Basic mode (chuyển nó về Basicmode dạng graphic cho dễ dùng)
(hoặc góc dưới bên phải có nút chuyển sang Basic mode).
Cài đặt tự động load mỗi khi startup:
Box 1: Khung Name Gõ tên script vidu: USBstarter
Box 2: Khung how. Gõ lệnh bạn muốn thực hiện mỗi lần khởi
Trong trường hợp này là gõ dòng sau vào khung how:
kextload -b com.apple.iokit.IOUSBMassStorageClass
Box 3: Khung When bạn chọn “run it when it is loaded by the system at startup or login”
Check vào “Enable” (Góc trên bên phải)
Bấm save và gõ password hoàn thành.





wget

22 07 2008

mkdir wget_files
cd wget_files

wget –mirror –w 2 –p –html-extension –-convert-links –P /home/me/wget_files  http://www.yourdomain.com

Now, a brief explanation of the options used:

–mirror:  Specifies to mirror the site.  Wget will recursively follow all links on the site and download all necessary files.  It will also only get files that have changed since the last mirror, which is handy in that it saves download time.

-w: Tells wget to “wait” or pause between requests, in this case for 2 seconds.  This is not necessary, but is the considerate thing to do.  It reduces the frequency of requests to the server, thus keeping the load down.  If you are in a hurry to get the mirror done, you may eliminate this option.

-p: Causes wget to get all required elements for the page to load correctly.  Apparently, the mirror option does not always guarantee that all images and peripheral files will be downloaded, so I add this for good measure.

–HTML-extension:  All files with a non-HTML extension will be converted to have an HTML extension.  This will convert any CGI, ASP or PHP generated files to HTML extensions for consistency.

–convert-links:  All links are converted so they will work when you browse locally.  Otherwise, relative (or absolute) links would not necessarily load the right pages, and style sheets could break as well.

-P (prefix folder): The resulting tree will be placed in this folder.  This is handy for keeping different copies of the same site, or keeping a “browsable” copy separate from a mirrored copy.

Nguon: http://www.devarticles.com/c/a/Web-Services/Website-Mirroring-With-wget/1/





iTunes Server

13 07 2008

Hệ điều hành dùng làm iTunes Server: centOS 5

Máy sử dụng truy cập (clients): Mac 0S X on PC (x86), Windows Vista

1. Download các gói cần thiết :

mt-daapd —> http://sf.net/projects/mt-daapd/

Nếu bạn nghe các bài hát tiếng Nhật thì cần phải xử lý thêm bằng cách dùng gói patch mt-daapd-0.2.4.xxx.patch —> http://www.kzsoft.to/~kazu/mt-daapd/

2. Install

2.1 Nếu đã cài gcc thì có thể bỏ qua bước này:

#yum -y install gcc

2.2 Cài đặt các thư viện cần thiết

#yum install libid3tag libid3tag-devel zlib-devel gdbm-devel

2.3 Giải nén và patch

$tar xzvf mt-daapd-0.2.4.xxx.tar.gz

$cd mt-daapd-0.2.4.xxx

$patch -p1 -F 3 < ../mt-daapd-0.2.4.xxx.patch

2.4 Cài đặt

$./configure

$make

#make install

3. Tạo thư mục để nhạc

#mkdir /var/mt-daapd (tên thư mục tùy thích)

#cp contrib/mt-daapd.conf /etc  (nhớ là các bước này bạn vẫn đang ở trong thư mục mt-daapd-0.2.4.xxx)

4. Biên tập file setting

#vi /etc/mt-daapd.conf

sửa các chỗ sau:

web_root    /usr/local/share/mt-daapd/admin-root

mp3_dir     /var/mt-daapd

servername   iTunes Server

extensions   .mp3, .m4a, .m4p, .m4v

5. Copy scripts khởi động

#cp contrib/mt-daapd /etc/rc.d/init.d

#vi /etc/rc.d/init.d/mt-daapd

sửa đoạn sau:

daemon /usr/local/sbin/mt-daapd

6. Mở firewall

Mở cổng 3689

#/sbin/iptables -I RH-Firewall-1-INPUT -p tcp -m tcp –dport 3689 -j ACCEPT

#/etc/rc.d/init.d/iptables save

7. Khởi động server

#/etc/rc.d/init.d/mt-daapd start

#chkconfig mt-daapd on

Chú ý: khi bạn khởi động server và bị báo lỗi sau:

/usr/local/sbin/mt-daapd: error while loading shared libraries: libid3tag.so.0: cannot open shared object file: No such file or directory

Bạn mở file /etc/ld.so.conf mà thêm vào dòng /usr/local/lib và thực thi lệnh ldconfig là ok.

Làm như sau:

#vi /etc/ld.so.conf

thêm dòng: /usr/local/lib

#ldconfig

Tham khảo thêm:

http://speedmania.jp/blog/linux/2006/10/

http://egt.tpot.tk/a/2007_05.html





QUOTA設定

12 07 2008

quotaパッケージのインストール

* # yum -y install quota

/etc/fstabの設定(/home以下をユーザ毎に制限する場合)

* # vi /etc/fstab
/dev/sda5 /home ext3 defaults 0 0 2(変更前)
/dev/sda5 /home ext3 defaults,usrquota 0 2(変更後)

ファイルシステムのリマウント

* # mount -o remount /dev/sda5

マウント状況を確認

* # mount
/dev/sda5 on /home type ext3 (rw,usrquota)

quotaファイルの作成

* # touch /home/aquota.user
* # chmod 600 /home/aquota.user

quotaファイルの初期化

* # quotacheck -muv /home
* # quotaon -auv

使用可能なディスク容量の設定(100MBの場合)

* # edquota somebody
Disk quotas for user somebody (uid 10000):
Filesystem blocks soft hard inodes soft hard
/dev/hdb1 3332 0 1024000 51 0 0





SSH

12 07 2008

1. Cài đặt SSH
2. Khởi động
#service sshd start
#chkconfig sshd on

3. Giới hạn access
#vi /etc/hosts.allow
thêm vào
sshd: ALL

4. Đăng ký User
$ssh -l username host
Nhập password cho SSH (không nhất thiết phải giống với pass của user)

$ssh-keygen -t rsa
Nhập pass vừa đăng ký ở trên

Xác nhận key được tạo ra:
$ls -l .ssh/
$ssh-keygen -l -f .ssh/id_rsa.pub

5. Thêm username@host vào trong file id_rsa.pub
$scp ~/.ssh/id_rsa.pub username@host:

6. Tạo file key của client
$cat id_rsa.pub >> ~/.ssh/authorized_keys
$chmod 700 ~/.ssh
$chmod 600 ~/.ssh/authorized_keys

7. Test
Từ máy client thử truy cập server
$ssh -l username host