Fix bug 1987:
添加安装完成后的动作(重启/关机/待机)
修改: interface/ri_data.py
修改: interface/ri_inst_cli.py
修改: interface/ri_install.py
修改: main/setup
修改: text/ri_main.py
修改: text/ri_newt.py
Signed-off-by: sysadmin <zhihuipeng@linx-info.com>
This commit is contained in:
@@ -735,6 +735,8 @@ def init_from_xml():
|
||||
Service.init_from_xml(n)
|
||||
elif n.nodeName == 'stategrid':
|
||||
StateGrid.init_from_xml(n)
|
||||
elif n.nodeName == 'finishstate':
|
||||
FinishState.init_from_xml(n)
|
||||
|
||||
def init_from_xml_and_os():
|
||||
''' init all classes in this module from file and os '''
|
||||
@@ -767,6 +769,7 @@ def to_xml():
|
||||
Network.to_xml(xmldoc, root)
|
||||
Group.to_xml(xmldoc, root)
|
||||
Service.to_xml(xmldoc, root)
|
||||
FinishState.to_xml(xmldoc, root)
|
||||
|
||||
PrettyPrint(xmldoc, f)
|
||||
f.close()
|
||||
@@ -794,3 +797,25 @@ p_node - xml node (parent node)'''
|
||||
|
||||
p_node.appendChild(stgd)
|
||||
|
||||
class FinishState():
|
||||
''' decide reboot or shutdown or keep current status when finishing
|
||||
OS install, flag include three value: reboot, shutdown, nothing'''
|
||||
flag = ''
|
||||
|
||||
@staticmethod
|
||||
def init_from_xml(node):
|
||||
''' init finish state flag from xml node '''
|
||||
#FinishState.flag = node.firstChild.data.encode('ascii')
|
||||
for k in node.attributes.keys():
|
||||
setattr(FinishState, k, node.attributes[k].value.encode('ascii'))
|
||||
|
||||
@staticmethod
|
||||
def to_xml(doc, p_node):
|
||||
''' write reboot or not flag into xml
|
||||
doc - xml document instance
|
||||
p_node - xml node (parent node)'''
|
||||
std = doc.createElement('finishstate')
|
||||
for ft in ('flag',):
|
||||
to_xml_attr(doc, std, FinishState, ft)
|
||||
|
||||
p_node.appendChild(std)
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
import ri_progress,re,os
|
||||
from ri_oper import language, Rate
|
||||
from snack import *
|
||||
import ri_data
|
||||
|
||||
def set_task(task_name):
|
||||
ri_progress.i_operation = task_name
|
||||
|
||||
@@ -36,36 +38,47 @@ def set_task_over():
|
||||
# if re.match('instmode=',i):
|
||||
# instmode = i.split('=')[1]
|
||||
# break
|
||||
try:
|
||||
instmode = os.environ["instmode"]
|
||||
except:
|
||||
instmode = 'Text'
|
||||
#try:
|
||||
# instmode = os.environ["instmode"]
|
||||
#except:
|
||||
# instmode = 'Text'
|
||||
screen = SnackScreen()
|
||||
screen.drawRootText(0, 0, 'Rocky Security OS Install')
|
||||
screen.pushHelpLine(' ')
|
||||
g = GridForm(screen, 'Rocky Install', 1, 3)
|
||||
txt1 = Label('Automated Install Rocky OS successfully, and the OS will reboot in 10 seconds ......')
|
||||
txt2 = Label('Install Rocky OS successfully, do you want to reboot ?')
|
||||
txt2 = Label('Automated Install Rocky OS successfully, and the OS will shutdown in 10 seconds ......')
|
||||
txt3 = Label('Install Rocky OS successfully, do you want to reboot ?')
|
||||
elabel = Label('')
|
||||
bb = ButtonBar(screen, (('Ok','ok'),('Cancel','cancel')))
|
||||
g.add(elabel, 0, 1)
|
||||
if instmode == 'Auto' or instmode == 'StateGrid':
|
||||
#if instmode == 'Auto' or instmode == 'StateGrid':
|
||||
if ri_data.FinishState.flag.strip() == 'reboot':
|
||||
g.add(txt1, 0, 1)
|
||||
g.setTimer(10000)
|
||||
g.runOnce()
|
||||
screen.finish()
|
||||
return True
|
||||
else:
|
||||
g.add(txt2, 0, 0)
|
||||
#return True
|
||||
return 'reboot'
|
||||
elif ri_data.FinishState.flag.strip() == 'shutdown':
|
||||
g.add(txt2, 0, 1)
|
||||
g.setTimer(10000)
|
||||
g.runOnce()
|
||||
screen.finish()
|
||||
#return True
|
||||
return 'shutdown'
|
||||
elif ri_data.FinishState.flag.strip() == 'nothing':
|
||||
g.add(txt3, 0, 0)
|
||||
g.add(bb, 0, 2)
|
||||
res = g.run()
|
||||
screen.refresh()
|
||||
if bb.buttonPressed(res) == 'ok':
|
||||
screen.finish()
|
||||
return True
|
||||
#return True
|
||||
return 'reboot'
|
||||
else:
|
||||
screen.finish()
|
||||
return False
|
||||
return 'nothing'
|
||||
|
||||
def root_destroy():
|
||||
pass
|
||||
|
||||
@@ -34,10 +34,16 @@ import partition_data as p_d
|
||||
|
||||
def install_over(ret):
|
||||
if ri_oper.Rate.value == 100 and ret == 0:
|
||||
if display.set_task_over():
|
||||
ret_set_task_over = display.set_task_over()
|
||||
if ret_set_task_over == 'reboot':
|
||||
print "reboot ..."
|
||||
os.system("reboot")
|
||||
else:
|
||||
elif ret_set_task_over == 'shutdown':
|
||||
print "shutdown ..."
|
||||
#os.system("shutdown -h now")
|
||||
os.system("eject")
|
||||
os.system("echo b >/proc/sysrq-trigger")
|
||||
elif ret_set_task_over == 'nothing':
|
||||
display.root_destroy()
|
||||
|
||||
def show_progress():
|
||||
|
||||
@@ -58,9 +58,9 @@ config_execfile(){
|
||||
|
||||
if test "$skip_partition" == "yes"
|
||||
then
|
||||
echo "list = ['welcome','mountpoint','serialnumber','network','group','service','information']" >> ${work_write_dir}/${install_step_list_file}
|
||||
echo "list = ['welcome','mountpoint','serialnumber','network','group','service','finishstate','information']" >> ${work_write_dir}/${install_step_list_file}
|
||||
else
|
||||
echo "list = ['welcome','partition','raid','mountpoint','serialnumber','network','group','service','information']" >> ${work_write_dir}/${install_step_list_file}
|
||||
echo "list = ['welcome','partition','raid','mountpoint','serialnumber','network','group','service','finishstate','information']" >> ${work_write_dir}/${install_step_list_file}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ while True :
|
||||
ri_newt.Group()
|
||||
elif list[count] == 'service':
|
||||
ri_newt.Service()
|
||||
elif list[count] == 'finishstate':
|
||||
ri_newt.FinishState()
|
||||
elif list[count] == 'information':
|
||||
ri_newt.Prepar_installation()
|
||||
s = ri_newt.Screen.dict[list[count]].set_data()
|
||||
|
||||
@@ -781,10 +781,43 @@ class Service(Screen):
|
||||
service.start = 'yes'
|
||||
else:
|
||||
service.start = 'no'
|
||||
ri_data.to_xml()
|
||||
#ri_data.to_xml()
|
||||
|
||||
return s
|
||||
|
||||
class FinishState(Screen):
|
||||
def __init__(self):
|
||||
Screen.__init__(self, name='finishstate')
|
||||
|
||||
self.text = 'After finishing installed Rocky OS system, do you want to reboot, shutdown or just do nothing ?'
|
||||
Screen.widget_textboxreflowed(50, self.text)
|
||||
Screen.widget_buttonbar(Screen.buttonlist1)
|
||||
|
||||
reboot_value = 0
|
||||
shutdown_value = 0
|
||||
nothing_value = 0
|
||||
default_value = getattr(ri_data.FinishState, 'flag')
|
||||
|
||||
if default_value == 'reboot':
|
||||
reboot_value = 1
|
||||
elif default_value == 'shutdown':
|
||||
shutdown_value = 1
|
||||
else:
|
||||
nothing_value = 1
|
||||
self.rb = RadioBar(Screen,(('Reboot', 'reboot', reboot_value), ('Shutdown', \
|
||||
'shutdown', shutdown_value), ('Nothing', 'nothing', nothing_value)))
|
||||
|
||||
Screen.container_grid(1,1,self.rb)
|
||||
|
||||
def set_data(self):
|
||||
#Screen.widget_entry(20, text=getattr(ri_data.FinishState,'flag'))
|
||||
s = Screen.yesno('finishstate', 1, 5, 'TextboxReflowed', 'eLable', 'Grid', 'eLabel', 'ButtonBar')
|
||||
if s == 0:
|
||||
ri_data.FinishState.flag = self.rb.getSelection()
|
||||
|
||||
ri_data.to_xml()
|
||||
return s
|
||||
|
||||
class Prepar_installation(Screen):
|
||||
def __init__(self):
|
||||
Screen.__init__(self, name='information')
|
||||
|
||||
Reference in New Issue
Block a user