[prev in list] [next in list] [prev in thread] [next in thread] 

List:       opensolaris-smf-discuss
Subject:    Re: [smf-discuss] Help with signals in a restricted menu started as
From:       Jack Schwartz <Jack.A.Schwartz () Sun ! COM>
Date:       2009-10-01 1:43:32
Message-ID: 4AC40944.7020809 () sun ! com
[Download RAW message or body]

Hi everyone.

Problem solved.

We ended up doing something similar to what was done for the old 
installer.  Changes from what I sent out yesterday are:
-  The manifest depends on milestone/single-user now, not 
system/filesystem/minimal.
- The 'need_session' propval was added to the startd property group.  
Value is 'true'
- The lib/svc/method file is now bypassed, and the manifest calls the 
menu script directly.

Another part of the puzzle was that I was running a changed file of a 
different name.  I changed the manifest to refer to the new file, but 
did not re-import the changed manifest, so the repository kept running 
the old file :(

Revised files attached.

Thanks to Tony Nguyen for his help!

    Thanks,
    Jack



On 09/29/09 16:14, Jack Schwartz wrote:
> Hi everyone.
>
> I work on the install team, and am working on an ITU-style menu the 
> user will first see when booting the text-mode CD.  This menu selects 
> the installer and Device Driver Utility among other things.  The menu 
> is a ksh93 script started as an SMF service.  The environment given to 
> it via SMF is different than a usual login environment, and signals do 
> not work.
>
> Attached are the files which I put in /lib/svc/method, 
> /var/svc/manifest/... and the menu itself which goes in /usr/sbin.
>
> The intent is for the script to mask signals (^C, abort, ^Z,^\, 
> SIGTERM) so it cannot be exited, but to allow signals to be active in 
> the commands it runs (installer, DDU, shell).  Examples: I want to be 
> able to run sleep from my script and ^C out of it;  I want the shell 
> run from my menu to see a ^C for processing.
> Using the attached files as a starting point, I tried modifying the 
> manifest file to look more like what the original install-setup 
> manifest (old installer) looked like (to depend on 
> svc:/milestone/single-user, and to add to the startd property group:
> <propval name-'need_session' type='boolean' value='true' />
>
> I also tried modifying the 'ignore_error' property, but then I checked 
> the ARC case (PSARC/2004/524) and it turns out the ignore_error deals 
> with errors requiring a restart, not what I am interested in.
>
> I looked at console-login service to see how it works and tried a 
> dependency on svc:/milestone/sysconfig as it had;  that didn't work 
> either.
>
> Any suggestions?  I'd greatly appreciate any help getting this to work.
>
>    Thanks,
>    Jack
>


["text-mode-menu.usr_sbin" (text/plain)]

#!/bin/ksh93

exec </dev/console >/dev/console 2>&1

export TERM=sun-cmd	# XXX need to find the right term type
export LOGNAME=root

# Block all signals which could terminate the menu or return to a parent process
trap "" TSTP INT TERM ABRT QUIT

# Define the menu of commands and prompts
# XXX replace with the "real" commands
menu_items=( \
(menu_str="Run installer"	cmd="/usr/bin/text-install"	) \
(menu_str="sleep"	cmd="/bin/sleep 5"	) \
(menu_str="Run ls"	cmd="/bin/ls -R /"	) \
(menu_str="Shell"	cmd="/bin/ksh93"	) \
(menu_str="Reboot"	cmd="reboot -p"		) \
)

for ((;;)) ; do

	# Display the menu.
	print "\nWelcome to the OpenSolaris `uname -v` installation menu\n"
	for i in "${!menu_items[@]}"; do
		print "$((${i} + 1))\t${menu_items[$i].menu_str}"
	done

	# Take an entry (by number).
	input=""
	dummy=""
	print -n "Please enter a number: "
	read input dummy 2>/dev/null

	# First char must be a digit.
	if [[ -z ${input} || ${input} =~ [^1-9] ]] ; then
		continue
	fi

	# Reorient to a zero base.
	input=$((${input} - 1))

	(
	trap - INT TERM ABRT QUIT
	${menu_items[$input].cmd}
	)
done

["text-mode-menu.var_svc_manifest_system" (text/xml)]

<?xml version="1.0"?>
<!--
 CDDL HEADER START

 The contents of this file are subject to the terms of the
 Common Development and Distribution License (the "License").
 You may not use this file except in compliance with the License.

 You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 or http://www.opensolaris.org/os/licensing.
 See the License for the specific language governing permissions
 and limitations under the License.

 When distributing Covered Code, include this CDDL HEADER in each
 file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 If applicable, add the following below this CDDL HEADER, with the
 fields enclosed by brackets "[]" replaced with your own identifying
 information: Portions Copyright [yyyy] [name of copyright owner]

 CDDL HEADER END

 Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 Use is subject to license terms.

 NOTE:  This service manifest is not editable; its contents will
 be overwritten by package or patch operations, including
 operating system upgrade.  Make customizations in a different
 file.
-->

<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<service_bundle type='manifest' name='SUNWtextinstall:text-mode-menu'>

<service
	name='system/install-setup'
	type='service'
	version='1'>

	<create_default_instance enabled='true' />
	<single_instance/>

	<!-- Must be able to access /tmp. -->
	<dependency
		name='single-user'
		grouping='require_all'
		restart_on='none'
		type='service'>
		<service_fmri value='svc:/milestone/single-user' />
	</dependency>

	<method_context>
		<method_credential user='root' group='root'/>
	</method_context>

	<exec_method
		type='method'
		name='start'
		exec='/usr/sbin/text-mode-menu'
		timeout_seconds='0' />

	<exec_method
		type='method'
		name='stop'
		exec=':true'
		timeout_seconds='0' />

	<property_group name='startd' type='framework'>
		<propval name='duration' type='astring' value='transient' />
		<propval name='need_session' type='boolean' value='true' />
		<propval name='ignore_error' type='astring' value='core,signal' />
	</property_group>

	<stability value='Unstable' />

	<!-- XXX play with the below later. -->
	<template>
		<common_name>
			<loctext xml:lang='C'>
				text mode menu
			</loctext>
		</common_name>
	</template>
</service>
</service_bundle>


_______________________________________________
smf-discuss mailing list
smf-discuss@opensolaris.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic