2013年1月10日 星期四

[Ubuntu][Linux] lftp 多線程下載

當連國外網站,或是下載速度很慢的時候
可使用lftp,用10條thread來下載
$ lftp -e 'pget -n 10 [download_path]'

2013年1月9日 星期三

[git] 取消已經暫存的文件

想要取消已經git add到暫存的文件
$ git reset HEAD [filename]


Extend Reading
想要刪除server的檔案
$ git rm [filename]

2013年1月8日 星期二

[Gerrit] [MySQL] 檢查Gerrit上是否尚有open change

#! /bin/bash

project_name='test'

open_change=$(echo "SELECT change_key FROM changes WHERE (dest_project_name='$project_name') and (open='Y');" | mysql -u[account] -p[password] reviewdb --silent)

if [ ! -n "${open_change}" ]; then
    echo "It dose not exits changes on Gerrit."
    exit 0
else
    echo "It exits changes on Gerrit."
    exit 1
fi

[ShellScript] 判斷變數為空


1. 變量通過" "引號引起來

如下所示:,可以得到結果為 IS NULL.
#!/bin/sh

if [ ! -n "​​$para1" ]; then
  echo "IS NULL"
else
  echo "NOT NULL"
fi



2. 直接通過變量判斷

如下所示:得到的結果為: IS NULL
#!/bin/sh

if [ ! $para1 ]; then
  echo "IS NULL"
else
  echo "NOT NULL"
fi




ref:http://blog.csdn.net/lllxy/article/details/3255554

2013年1月7日 星期一

[Ubuntu] 解決找不到ServerName的問題

解決每次重啟Apache2會有找不到ServerName的問題

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

1. 修改httpd.conf這個空文件
$ sudo vi /etc/apache2/httpd.conf

2. 將以下內容複製進去
ServerName localhost

2012年12月24日 星期一

[Gerrit] [Jenkins] 在LDAP auth之下,建立一個內部CI Server使用帳號

要使用Gerrit搭配Jenkins auto build並auto code review/verify使用
需要建立一個Jenkins使用的帳號
若在LDAP auth之下
可使用指令建立內部使用的帳號

ssh -p <port> <host> gerrit create-account \ [--group <GROUP>] \ [--full-name <FULLNAME>] \ [--email <EMAIL>] \ [--ssh-key -|<KEY>] \ <USERNAME>

1). 建立帳號jenkins,指定公鑰
$ cat ~/.ssh/id_rsa.pub  | ssh -p 29418 [Admin Account]@[ip] gerrit create-account --ssh-key - --full-name jenkins jenkins

2). 建立帳號jenkins,指定公鑰,指定名稱為jenkins
$ cat ~/.ssh/id_rsa.pub  | ssh -p 29418 [Admin Account]@[ip] gerrit create-account --ssh-key - --full-name jenkins jenkins



ref:http://gerrit.googlecode.com/svn/documentation/2.2.1/cmd-create-account.html

2012年12月19日 星期三

[git] 開發使用指令

1). 開一個開發/測試使用branch
git branch [test_branch]

2). 移到此branch
git checkout [test_branch]

3). 在開發完後,將變更commit成一筆
git add .
git commit

4). 改壞了要回覆成codebase上的
    4.1). 全部回覆到codebase
            git checkout HEAD .
    4.2). 回覆特定資料夾
            git checkout [folder_name]

5). 紀錄此筆commit id,等等要把這筆commit剪(cherry-pick)過去master branch
git log

6). 切換到master
git checkout master

7). 把剛剛那筆commit剪過來master branch
git cherry-pick [commit-id]

8). push到codebase
git push



※ref: http://blog.luzi82.com/2010/08/git-cherry-pick-rebase.html