diff --git a/interface/ri_inst_cli.py b/interface/ri_inst_cli.py index a13b5b5..7785290 100644 --- a/interface/ri_inst_cli.py +++ b/interface/ri_inst_cli.py @@ -16,7 +16,7 @@ # Ling Fen 2010-09-04 create # -import ri_progress,re +import ri_progress,re,os from ri_oper import language, Rate from snack import * def set_task(task_name): @@ -29,14 +29,14 @@ def set_task_scale(): ri_progress.i_percent = int(Rate.value) def set_task_over(): - f = open('/proc/cmdline', 'r') - cmdline = f.readline().strip() - f.close() - #instmode = cmdline.split(' ')[0].split('=')[1] - for i in cmdline.split(' '): - if re.match('instmode=',i): - instmode = i.split('=')[1] - break + #f = open('/proc/cmdline', 'r') + #cmdline = f.readline().strip() + #f.close() + #for i in cmdline.split(' '): + # if re.match('instmode=',i): + # instmode = i.split('=')[1] + # break + instmode = os.environ["instmode"] screen = SnackScreen() screen.drawRootText(0, 0, 'Rocky Security OS Install') screen.pushHelpLine(' ') diff --git a/main/begin-install b/main/begin-install new file mode 100755 index 0000000..d485570 --- /dev/null +++ b/main/begin-install @@ -0,0 +1,41 @@ +#! /bin/sh + +work_as_net_inst_server(){ + cp -a /net_inst_server/{exports,dhcpd.conf} /etc/ + ifconfig eth0 145.16.3.254 + /etc/init.d/portmap start + /etc/init.d/nfsserver start + /etc/init.d/tftpd-hpa start + /etc/init.d/dhcp start +} + +#instmode=`cat /proc/cmdline | sed 's/.*instmode=\([^ ]*\).*/\1/'` +source /usr/lib/new_install/text/get_instmode.sh + +if [ $instmode = 'Auto' -o $instmode = 'StateGrid' ];then + mkdir -pv /var/install/ + cp /usr/lib/new_install/xml/install.xml /var/install/ +fi + +case $instmode in + Auto) + cd /usr/lib/new_install/text + /usr/bin/python ./auto_install.py ;; + Text) + /usr/bin/setup -s ;; + StateGrid) + cd /usr/lib/new_install/text + /usr/bin/python ./state_grid.py + /usr/bin/python ./auto_install.py ;; + Gui) + /usr/bin/setup -s ;; + NetInstallServer) + work_as_net_inst_server ;; + Cancel) + clear + exit ;; + *) + echo "unknown select" ;; +esac + + diff --git a/operation/finish_install/98state_grid_custom.py b/operation/finish_install/98state_grid_custom.py index cfa7ae3..6c1a200 100755 --- a/operation/finish_install/98state_grid_custom.py +++ b/operation/finish_install/98state_grid_custom.py @@ -14,14 +14,14 @@ homedir = ri_data.StateGrid.home_dir shell = ri_data.StateGrid.shell # run state grid custom scripts -f = open('/proc/cmdline', 'r') -cmdline = f.readline().strip() -f.close() -#instmode = cmdline.split(' ')[0].split('=')[1] -for i in cmdline.split(' '): - if re.match('instmode=',i): - instmode = i.split('=')[1] - break +#f = open('/proc/cmdline', 'r') +#cmdline = f.readline().strip() +#f.close() +#for i in cmdline.split(' '): +# if re.match('instmode=',i): +# instmode = i.split('=')[1] +# break +instmode = os.environ["instmode"] if instmode == 'StateGrid': os.system("cp -r /usr/lib/StateGrid /mnt/opt/") os.system("chroot /mnt /opt/StateGrid/setup.sh %s %s %s" %(username, homedir, shell)) diff --git a/text/get_instmode.sh b/text/get_instmode.sh new file mode 100755 index 0000000..d0f2fcc --- /dev/null +++ b/text/get_instmode.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# get or set instmode's value + +tmp_file="/tmp/xrasmxioecnz" + +select_inst_mode(){ + python /usr/lib/new_install/text/select_inst_mode.py + instmode=$(cat ${tmp_file}) + rm ${tmp_file} +} + +[ -z $instmode ] && instmode=`cat /proc/cmdline | sed 's/.*instmode=\([^ ]*\).*/\1/'` + +if [ "$instmode" = "HdInstall" -o "$instmode" = "NetInstall" ];then + select_inst_mode +fi + +export instmode diff --git a/text/select_inst_mode.py b/text/select_inst_mode.py new file mode 100755 index 0000000..001db39 --- /dev/null +++ b/text/select_inst_mode.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +from snack import * + +import os + +screen = SnackScreen() + +screen.drawRootText(0, 0, 'Welcome to Rocky Security OS') + +helpline=' between elments | selects | Confirm' + +screen.pushHelpLine(helpline) + +inst_mod_items = {'Manual install text mode':'Text', 'Auto install':'Auto', 'State Grid automated install':'StateGrid'} + +inst_mod_num = len(inst_mod_items) + +inst_mod_listbox = Listbox(inst_mod_num+2, width = 40, returnExit = 0) + +#for i in range(inst_mod_num): +for i in inst_mod_items.keys(): + inst_mod_listbox.append(i,inst_mod_items[i]) + +tex = TextboxReflowed(40, "Please choose one install mode from the list blow \nand press 'F12' to confirm.") + +g = GridForm(screen, "Install Mode Select", 1, 3) + +g.add(tex, 0, 0) +g.add(Label(""), 0, 1) +g.add(inst_mod_listbox, 0, 2) + +g.runOnce() + +screen.popWindow() + +screen.finish() + +instmode = str(inst_mod_listbox.current()) + +os.system('echo %s >/tmp/xrasmxioecnz' %(instmode))