Enable to select install mode when net-install and hd-install

modified:   interface/ri_inst_cli.py
	new file:   main/begin-install
	modified:   operation/finish_install/98state_grid_custom.py
	new file:   text/get_instmode.sh
	new file:   text/select_inst_mode.py
This commit is contained in:
Peng Zhihui
2014-04-22 16:16:47 +08:00
parent 9c1fbe799e
commit b3e847c59c
5 changed files with 117 additions and 17 deletions

View File

@@ -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(' ')

41
main/begin-install Executable file
View File

@@ -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

View File

@@ -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))

18
text/get_instmode.sh Executable file
View File

@@ -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

41
text/select_inst_mode.py Executable file
View File

@@ -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='<Arrows> between elments | <Space> selects | <F12> 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))