diff --git a/interface/check_oldconf.py b/interface/check_oldconf.py index 886fa7b..eb0765c 100644 --- a/interface/check_oldconf.py +++ b/interface/check_oldconf.py @@ -1,26 +1,37 @@ #!/usr/bin/python #! coding: utf-8 -ins_xml = './install.xml' +''' file check_oldconf.py +Decide whether to delete the install.xml file''' + import Tkinter import sys import subprocess +import getopt +ins_xml = './install.xml' +lang = 'english' message = {} message['english'] = 'The system detects the presence of the last\n \ installation to retain the configuration file, whether to use' message['chinese'] = '系统检测到存在上次安装保留的配置文件,是否使用它' +def print_usages(): + print 'Usage: %s [-l|--language language] [-h|--help]' % sys.argv[0] + print 'language [english|chinese]' + print 'default language is english' def ok(): root.destroy() def cancel(): + ''' remove system left install.xml file''' cmd='rm -rf ' + ins_xml subprocess.Popen(cmd,shell=True) root.destroy() def init(language): + ''' implement Widget''' global root root = Tkinter.Tk() root.geometry("%sx%s+%d+%d" % (root.winfo_screenwidth()/2,\ @@ -39,5 +50,19 @@ def init(language): root.rowconfigure(2,weight=1) root.mainloop() -init(sys.argv[1]) +try: + opts,args = getopt.getopt(sys.argv[1:],"l:",["language="]) +except getopt.GetoptError: + print_usages() + sys.exit(1) + +for opt,arg in opts: + if opt in ('-l','--language'): + lang = arg + +if lang in ('english','chinese'): + init(lang) +else: + print_usages() + sys.exit(1) diff --git a/main/conf_sshd b/main/conf_sshd new file mode 100755 index 0000000..7bf4aa1 --- /dev/null +++ b/main/conf_sshd @@ -0,0 +1,52 @@ +#!/bin/bash - +# +#=================================================================================== +# +# Copyright Beijing Linx Technology Co., Ltd. 2010年09月21日 +# +# Filename: conf_sshd.sh +# +# USAGE: ./conf_sshd.sh +# +# Description: configure sshd,to achieve remote installation +# +# Version: 0.1 +# Created: 2010年09月21日 +# +# Author: Hu Gang +# +# ChangeLog: 1. 2010年09月21日 Create. +# +#=================================================================================== +# +#=================================================================================== +#Performance function +#=================================================================================== +startnetwork(){ + local networkfile='/etc/sysconfig/network-devices/ifcfg-eth0' + 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 +} + +startsshd(){ + sed -i "s%^#shm%shm%g" /etc/fstab + mount -a + mkdir -p /var/empty + openssh-keygen + /usr/sbin/sshd -o X11Forwarding=yes +} + +#=================================================================================== +#Execution +#=================================================================================== +startnetwork +startsshd + diff --git a/main/setup b/main/setup new file mode 100755 index 0000000..dca7f87 --- /dev/null +++ b/main/setup @@ -0,0 +1,84 @@ +#!/bin/bash - +# +#=================================================================================== +# +# Copyright Beijing Linx Technology Co., Ltd. 2010年09月13日 +# +# Filename: setup +# +# USAGE: ./setup +# +# Description: Setup startup script +# +# Version: 0.1 +# Created: 2010年09月13日 +# +# Author: Hu Gang +# +# ChangeLog: 1. 2010年09月13日 Create. +# +#=================================================================================== +# + +#=================================================================================== +#Set variables +#=================================================================================== +workdir='/usr/lib/new_install/interface' +exec_file='xinitrc_setup' +work_write_dir='/var/lib/install' +#=================================================================================== +#Performance function +#=================================================================================== +usage(){ + echo "usage: $0 [-s|--style style] [-l|--language language][-x|--Xserver select][-h|--help]" + echo "style [text|graph]" + echo "language [english|chinese]" + echo "select [yes|no]" + exit 0 +} + +config_execfile(){ + echo "#!/bin/bash" > ${work_write_dir}/${exec_file} + echo "cd ${workdir}" >> ${work_write_dir}/${exec_file} + if [ -f ${work_write_dir}/install.xml ]; then + echo "python check_oldconf.py -l $1 " >> ${work_write_dir}/${exec_file} + fi + echo "python test.py -l $1" >> ${work_write_dir}/${exec_file} +} + +main(){ + local style='graph' + local language='english' + local Xserver='yes' + + 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 ;; + esac + shift + done + + if [ $style = 'graph' ]; then + config_execfile "$language" + else + : + # text install + fi + + if [ $Xserver = 'yes' ]; then + X -configure + startx ${work_write_dir}/${exec_file} -- -config ~/xorg.conf.new + else + bash ${work_write_dir}/${exec_file} + fi +} + +#=================================================================================== +#Execution +#=================================================================================== +main "$@" +