2011年12月21日 星期三

解決yum update perl conflict問題

若yum update perl發生
conflicts with file from package perl.x.x.x
用rpm -e移除perl.i386 (若妳的CentOS是x64)
rpm -e perl.i386
在執行yum update perl應該就不會發生conflicts了

參考資料:
http://slash4.de/tutorials/CentOS_5.4_perl_update_problem

2011年11月30日 星期三

vsftpd ipv6 setup

讓vsftpd service 可用ipv6 address連線 (環境: CentOS 5.X)

1. 編輯 /etc/vsftpd/vsftpd.conf
listen=NO #關掉ipv4-only sockets
listen_ipv6=YES #打開ipv4 ipv6相容的模式

2. restart vsftpd
# service vsftpd restart

2011年11月2日 星期三

linux bash getopt


getopt 是 shell 裡抓參數的好工具
例: getopt abc:d: 容許參數 -a -b -c -d, -c and -d 後面要接參數

#!/bin/sh
set - `getopt abc:d: $*`
while true; do
  case $1 in
    -a) echo option -a
      shift ;; 
    -b) echo option -b
      shift ;; 
    -c) echo option -c=$2
      shift 2 ;; 
    -d) echo option -d=$2
      shift 2 ;; 
    --) shift
      break ;; 
    *) echo "error!"
      exit 1 ;; 
  esac
done

執行結果 
# ./go -a
option a
# ./go -c jack
option -c=jack
# ./go -b -c jack
option -b
option -c=jack
# ./go -b -c test -d
getopt: option requires an argument -- d
option -b
option -c=test
(使用後面要加參數的 option 會提示)
# ./go -b -c test -f
getopt: invalid option -- f
option -b
option -c=test
(使用未支援的參數會提示)

 http://pank.org/blog/2004/05/getopt-example.html

python join

把string的list join成一個string

tmp = ["a", "b", "c", "d"]
" ".join(tmp)
a b c d

http://stackoverflow.com/questions/3627270/python-how-exactly-can-you-take-a-string-split-it-reverse-it-and-join-it-back

set - 的用法

#set - -a a -b b c d e f g
#echo $1
-a
#echo $*
-a a -b b c d e f g
#echo $0
bash
link

2011年9月16日 星期五

gitosis

Install gitosis (server side)
>git clone git://eagain.net/gitosis.git
>cd gitosis >sudo python setup.py install

add user 'git' (server side)
>sudo adduser git
>sudo passwd git

generate a admin public key (from client side) and put on server side
the key is put on /home/git/id_rsa.pub

Initialize gitosis (server side)
>su git
>cd /home/git
>gitosis-init < id_rsa.pub
>rm id_rsa.pub


Now we must set some directory and file permissions to let sshd see the new authorized_keys file.

>chmod 755 /home/git
>chmod 700 /home/git/.ssh
>chmod 644 /home/git/.ssh/authorized_keys


Make sure post-update is executeable
Cole on November 19, 2009 03:53 PM
I was still getting the ERROR:gitosis.serve.main:Repository read access denied problem after rechecking everything that was said here. I finally found the answer on stackoverflow. Make sure your repositories/gitosis-admin.git/hooks/post-update is executable. Enjoy

prevent "ERROR:gitosis.serve.main:Repository read access denied"

clone gitosis from server (client side)
>git clone git@server.com:gitosis-admin.git

edit gitosis.conf
>cd gitosis-admin
>vim gitosis.conf
(refer following link to modify conf file)

http://nfocipher.com/index.php?op=ViewArticle&articleId=12&blogId=1
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
http://theswarmintelligence.blogspot.com/2009/11/creating-gitosis-repository-and-adding.html

Ready to git hosting on remote!