From 4db9f7c1dd8a19e4ce379898498fe4ca0e529ce7 Mon Sep 17 00:00:00 2001 From: hugang Date: Fri, 15 Oct 2010 16:06:50 +0800 Subject: [PATCH] For the recored,the error correction --- interface/check_oldconf.py | 31 ++++++++++++++++--------------- interface/ri_data.py | 3 ++- interface/ri_tk_cmd.py | 6 +++--- interface/test.py | 4 ++-- main/conf_sshd | 38 +++++++++++++++++++++++++++++++------- main/setup | 30 +++++++++++++++++------------- xml/interface.xml | 26 ++++++++++---------------- 7 files changed, 81 insertions(+), 57 deletions(-) diff --git a/interface/check_oldconf.py b/interface/check_oldconf.py index eb0765c..ccff4c9 100644 --- a/interface/check_oldconf.py +++ b/interface/check_oldconf.py @@ -9,7 +9,7 @@ import sys import subprocess import getopt -ins_xml = './install.xml' +ins_xml = '/var/install/install.xml' lang = 'english' message = {} message['english'] = 'The system detects the presence of the last\n \ @@ -21,10 +21,10 @@ def print_usages(): print 'language [english|chinese]' print 'default language is english' -def ok(): +def yes(): root.destroy() -def cancel(): +def no(): ''' remove system left install.xml file''' cmd='rm -rf ' + ins_xml subprocess.Popen(cmd,shell=True) @@ -34,15 +34,13 @@ def init(language): ''' implement Widget''' global root root = Tkinter.Tk() - root.geometry("%sx%s+%d+%d" % (root.winfo_screenwidth()/2,\ - root.winfo_screenheight()/2,\ - root.winfo_screenwidth()/4, - root.winfo_screenheight()/4)) + root.geometry("%sx%s+0+0" % (root.winfo_screenwidth(), + root.winfo_screenheight())) txt = message[language] lab = Tkinter.Label(root,text=txt) lab.grid(row=1,column=1) - btn1 = Tkinter.Button(root,text='OK',command=sys.modules[__name__].ok) - btn2 = Tkinter.Button(root,text='Cancle',command=sys.modules[__name__].cancel) + btn1 = Tkinter.Button(root,text='Yes',command=sys.modules[__name__].yes) + btn2 = Tkinter.Button(root,text='No',command=sys.modules[__name__].no) btn1.grid(row=2,column=0,padx=40,pady=100,ipadx=20) btn2.grid(row=2,column=2,padx=20,pady=100,ipadx=15) root.rowconfigure(1,weight=2) @@ -51,18 +49,21 @@ def init(language): root.mainloop() try: - opts,args = getopt.getopt(sys.argv[1:],"l:",["language="]) + opts,args = getopt.getopt(sys.argv[1:],"l:",["language="]) except getopt.GetoptError: - print_usages() - sys.exit(1) + print_usages() + sys.exit(1) for opt,arg in opts: if opt in ('-l','--language'): lang = arg + if opt in ('-h','--help'): + print_usages() + sys.exit(0) if lang in ('english','chinese'): - init(lang) + init(lang) else: - print_usages() - sys.exit(1) + print_usages() + sys.exit(1) diff --git a/interface/ri_data.py b/interface/ri_data.py index ee64be3..5209b46 100644 --- a/interface/ri_data.py +++ b/interface/ri_data.py @@ -629,7 +629,8 @@ p_node - xml node (parent node)''' srvs.appendChild(srv) p_node.appendChild(srvs) -def install_information(): +def prepar_installation(): + '''create file called 'intall.xml',which contains the information about the installation''' to_xml() xmldoc = minidom.parse(install_xml) root = xmldoc.firstChild diff --git a/interface/ri_tk_cmd.py b/interface/ri_tk_cmd.py index 7914c86..774cea0 100644 --- a/interface/ri_tk_cmd.py +++ b/interface/ri_tk_cmd.py @@ -400,9 +400,9 @@ def raid_device_list_detail(*args): raid_raw_initialized = False -def install_information_init(): +def prepar_installation_init(): '''install information initialize''' - ins_info = ri_data.install_information() - t= ri_widget.Widget.dict['install_information.list'].tk_widget + ins_info = ri_data.prepar_installation() + t= ri_widget.Widget.dict['prepar_installation.text'].tk_widget t.insert(1.0,ins_info) diff --git a/interface/test.py b/interface/test.py index a5a22da..6b5323e 100644 --- a/interface/test.py +++ b/interface/test.py @@ -27,10 +27,10 @@ for opt, arg in opts: if len(args) == 0: itf_xml = "../xml/interface.xml" - ins_xml = "../xml/install.xml" + ins_xml = "/var/install/install.xml" elif len(args) == 1: itf_xml = args[0] - ins_xml = "../xml/install.xml" + ins_xml = "/var/install/install.xml" else: itf_xml = args[0] ins_xml = args[1] diff --git a/main/conf_sshd b/main/conf_sshd index 7bf4aa1..b3dd235 100755 --- a/main/conf_sshd +++ b/main/conf_sshd @@ -4,9 +4,9 @@ # # Copyright Beijing Linx Technology Co., Ltd. 2010年09月21日 # -# Filename: conf_sshd.sh +# Filename: conf_sshd # -# USAGE: ./conf_sshd.sh +# USAGE: conf_sshd [interface] # # Description: configure sshd,to achieve remote installation # @@ -19,21 +19,35 @@ # #=================================================================================== # + +#=================================================================================== +#Set variables +#=================================================================================== +interface= +filepath=/etc/sysconfig/network-devices #=================================================================================== #Performance function #=================================================================================== + +usage(){ + echo "$0 [interface]" + echo "The name of the interface. This is usually a driver name followed " + echo "by a unit number, for example eth0 for the first Ethernet interface." + echo "default interface is eth0" +} + startnetwork(){ - local networkfile='/etc/sysconfig/network-devices/ifcfg-eth0' + cp ${filepath}/{ifcfg.template,ifcfg-${interface}} echo 'enter your IP:' read ip echo 'enter your netmask:' read netmask echo 'enter your gateway:' read gateway - sed -i "s%IPADDR=.*%IPADDR=${ip}%g" $networkfile - sed -i "s%NETMASK=.*%NETMASK=${netmask}%g" $networkfile - sed -i "s%GATEWAY=.*%GATEWAY=${gateway}%g" $networkfile - ifup eth0 + sed -i "s%IPADDR=.*%IPADDR=${ip}%g" ${filepath}/ifcfg-${interface} + sed -i "s%NETMASK=.*%NETMASK=${netmask}%g" ${filepath}/ifcfg-${interface} + sed -i "s%GATEWAY=.*%GATEWAY=${gateway}%g" ${filepath}/ifcfg-${interface} + ifup ${interface} } startsshd(){ @@ -47,6 +61,16 @@ startsshd(){ #=================================================================================== #Execution #=================================================================================== + # the interface between the eth0 to eth9 +if [ $# -eq 0 ]; then + interface=eth0 +elif [[ V$1 == Veth[0-9] ]]; then + interface="$1" +else + usage + exit 1 +fi + startnetwork startsshd diff --git a/main/setup b/main/setup index dca7f87..a651363 100755 --- a/main/setup +++ b/main/setup @@ -25,16 +25,15 @@ #=================================================================================== workdir='/usr/lib/new_install/interface' exec_file='xinitrc_setup' -work_write_dir='/var/lib/install' +work_write_dir='/var/install' #=================================================================================== #Performance function #=================================================================================== usage(){ - echo "usage: $0 [-s|--style style] [-l|--language language][-x|--Xserver select][-h|--help]" + echo "usage: $0 [-s|--style style] [-l|--language language][-n|--noXserver][-h|--help]" echo "style [text|graph]" echo "language [english|chinese]" - echo "select [yes|no]" - exit 0 + echo "default Xserver start" } config_execfile(){ @@ -49,17 +48,22 @@ config_execfile(){ main(){ local style='graph' local language='english' - local Xserver='yes' + local xstart='yes' + + tmp=$(getopt -o s:l:nh --long style:,language:,noXserver,help -- "$@") + eval set -- "$tmp" mkdir -p $work_write_dir - while [ "$1" ];do - case $1 in - '-s'|'--style') type="$2" ;shift ;; - '-l'|'--language') language="$2" ;shift ;; - '-x'|'--Xserver') Xserver="$2" ;shift ;; - *) usage ;; + + while true;do + case "$1" in + '-s'|'--style') type="$2" ;shift 2;; + '-l'|'--language') language="$2" ;shift 2;; + '-n'|'--noXserver') xstart='no' ;shift ;; + '-h'|'--help') usage ; exit 0 ;; + '--') shift; break ;; + *) usage ; exit 1 ;; esac - shift done if [ $style = 'graph' ]; then @@ -69,7 +73,7 @@ main(){ # text install fi - if [ $Xserver = 'yes' ]; then + if [ $xstart = 'yes' ]; then X -configure startx ${work_write_dir}/${exec_file} -- -config ~/xorg.conf.new else diff --git a/xml/interface.xml b/xml/interface.xml index dc03a81..e493cc1 100644 --- a/xml/interface.xml +++ b/xml/interface.xml @@ -722,7 +722,6 @@ row 4 | | - @@ -832,25 +831,25 @@ row 4 | | --> - + - - + + - + - + - + - + @@ -875,7 +874,7 @@ row 4 | | 您已到达第一步。 - + Installation information recorded the process which the users choose operations during installation. Including: record the operation of the physical hard disk, choose the software packages which use to install and server to start system. @@ -1031,11 +1030,6 @@ row 4 | | installation Configuration is completed, press the OK button to start the installation 安装配置完成,按确定键开始安装 - - - The system detects the presence of the last installation to retain the configuration file, whether to use - 系统检测到存在上次安装保留的配置文件,是否使用它 - Active @@ -1108,7 +1102,7 @@ row 4 | | - install_information + prepar_installation 安装信息 @@ -1256,6 +1250,6 @@ row 4 | | - +