2014年8月28日 星期四

dnsmasq with gpxe can not get the filename

Recently I used dnsmasq for pxeboot my virtual machine.
The virtual machine was boot with gPXE.
And it can fetch the IP address, but can't fetch the filename.
Then I captured the network package.
The server did send the filename operation to client.
But the client did not use it.
I can't figure out what happened.
After I added the option "dhcp-no-override" and everything just fine.

kickstart include file

Recently I have to setup multiple server.
Most of them have the same content.
So I tried to separate the same part into a file
And include them if I need it.

install
skipx
text
#cmdline

## install source
url --url=http://{{server}}/distro/centos/6.5/x86_64

## include common install setting
%include http://{{server}}/kickstart/install.ks

## disk operation
zerombr yes
bootloader --location=mbr --append="rhgb quiet"
clearpart --all --initlabel
autopart


%packages
## include common package list
%include http://{{server}}/kickstart/packages.ks


%post
## include commom post script
%include http://{{server}}/kickstart/post.ks

## include some category post script
%include http://{{server}}/kickstart/post-some-category.ks

## write your special script here
echo "done!!"

%end


pxelinux boot menu with include file

The default configuration
default menu.c32
timeout 100
totaltimeout 600
ontimeout LOCAL_BOOT
prompt 0

menu title PXE menu

label LOCAL_BOOT
    menu default
    menu label ^Local Boot
    localboot 0

menu include pxelinux.cfg/basic.menu


The "basic.menu" content
label BASIC_SERVER
    menu label Basic CentOS 6.5 ^Server
    kernel centos/6.5/x86_64/isolinux/vmlinuz
    append initrd=centos/6.5/x86_64/isolinux/initrd.img ksdevice=bootif ks=http://server.ip/centos_6_5_kickstart_server
    ipappend 2

label BASIC_DESKTOP
    menu label Basic CentOS 6.5 ^Desktop
    kernel centos/6.5/x86_64/isolinux/vmlinuz
    append initrd=centos/6.5/x86_64/isolinux/initrd.img ksdevice=bootif ks=http://server.ip/centos_6_5_kickstart_desktop
    ipappend 2

Disable vncserver authentication

Add the option "-SecurityTypes none" to the VNC command
Suggest to listen on localhost connection if you do not want to have any authentication.
To listen on localhost connection only, add the option "-localhost" to the VNC command

Remove KVM default nat network

Execute command at the KVM server

virsh net-destroy default
virsh net-undefine default

Detail command please reference to the command
virsh help

2014年1月19日 星期日

Making a debian package

**需要用到的軟體dh_make, fakeroot, build-essential**

首先要決定的是套件名稱及版本
本範例使用的套件名稱為hello-kuntelin。版本為1.0.1
要注意的是套件名稱皆為小寫。分隔字元為"-"


首次debian化
環境變數
DEBEMAIL=套件管理者的電子信箱
DEBFULLNAME=套件管理者的名稱
設定檔時部份檔案會使用到這二個變數

先建立套件的目錄
切換到該目錄後執行 dh_make --native --single --copyright bsd --packagenae ${套件名稱}_${套件版本}
--native 這是個自己編寫的程式
--single 這是個Single binary的套件
--copyright bsd 本套件使用BSD授權
對參數有與趣的可以man dh_make使用其他的參數
要注意的是如果使用非自己編寫的程式。需先將原始來源打包於上一層目錄。並命名為 ${套件名稱}_${套件版本}.orig.tar.gz

檢查目錄下是否多出個debian的目錄。目錄存在代表成功


編輯主要檔案
debian下必要的檔案為control, copyright, changelog, rules

control 詳細內容請參照這裡
範例
Source: hello-kuntelin                                                                                                                                                   
Section: misc                                                                                                                                                            
Priority: extra                                                                                                                                                          
Maintainer: example                                                                                                                                 
Build-Depends: debhelper (>= 8.0.0)                                                                                                                                      
Standards-Version: 3.9.2                                                                                                                                                 
                                                                                                                                                                         
Package: hello-kuntelin                                                                                                                                                  
Architecture: all                                                                                                                                                        
Depends:                                                                                                                                                                 
Description: This is first line description                                                                                                                              
 This is second line description                                                                                                                                         
 This is third line description          

copyright 版權宣告
Files: *                                                                                                                                                                 
Copyright: 2014 example                                                                                                                             
License: BSD-3-Clause                                                                                                                                                    
                                                                                                                                                                         
Files: debian/*                                                                                                                                                          
Copyright: 2014 example                                                                                                                             
License: BSD-3-Clause                                                                                                                                                    
                                                                                                                                                                         
License: BSD-3-Clause                                                                                                                                                    
 Redistribution and use in source and binary forms, with or without                                                                                                      
 modification, are permitted provided that the following conditions                                                                                                      
 are met:                                                                                                                                                                
 1. Redistributions of source code must retain the above copyright                                                                                                       
    notice, this list of conditions and the following disclaimer.                                                                                                        
 2. Redistributions in binary form must reproduce the above copyright                                                                                                    
    notice, this list of conditions and the following disclaimer in the                                                                                                  
    documentation and/or other materials provided with the distribution.                                                                                                 
 3. Neither the name of the University nor the names of its contributors                                                                                                 
    may be used to endorse or promote products derived from this software                                                                                                
    without specific prior written permission.                                                                                                                           
 .                                                                                                                                                                       
 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND                                                                                                 
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE                                                                                                   
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE                                                                                              
 ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE                                                                                                
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL                                                                                              
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS                                                                                                 
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)                                                                                                   
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT                                                                                              
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY                                                                                               
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF                                                                                                  
 SUCH DAMAGE.                                                                                                                                                            

changelog 詳細內容請參照這裡
hello-kuntelin (1.0.1) unstable; urgency=low                                                                                                                             
                                                                                                                                                                         
  * Initial Release.                                                                                                                                                     
                                                                                                                                                                         
 -- example   Mon, 20 Jan 2014 11:31:19 +0800       

rules 其實是另一個Makefile用來安裝本例使用預設
#!/usr/bin/make -f                                                                                                                                                       
# -*- makefile -*-                                                                                                                                                       
# Sample debian/rules that uses debhelper.                                                                                                                               
# This file was originally written by Joey Hess and Craig Small.                                                                                                         
# As a special exception, when this file is copied by dh-make into a                                                                                                     
# dh-make output file, you may use that output file without restriction.                                                                                                 
# This special exception was added by Craig Small in version 0.37 of dh-make.                                                                                            
                                                                                                                                                                         
# Uncomment this to turn on verbose mode.                                                                                                                                
#export DH_VERBOSE=1                                                                                                                                                     
                                                                                                                                                                         
%:                                                                                                                                                                       
    dh $@            


其他檔案
debian/install 安裝時一併裝到系統的檔案(不在make install安裝的檔案),詳細的用法請看這裡
debian/dirs 安裝時一併建立的目錄(不在make install建立的目錄),詳細的用法請看這裡


打包套件
dpkg-buildpackage -b -uc -rfakeroot
打包完成後會在上層的目錄

參考來源:
Debian 新維護人員手冊