sync with git version

This commit is contained in:
Todd C. Miller
2011-01-14 14:33:32 -05:00
parent 0726c8fe24
commit add7f327ea

211
pp
View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# (c) 2010 Quest Software, Inc. All rights reserved # (c) 2011 Quest Software, Inc. All rights reserved
pp_revision="300" pp_revision="301"
# Copyright 2010 Quest Software, Inc. All rights reserved. # Copyright 2010 Quest Software, Inc. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@@ -3056,19 +3056,11 @@ pp_backend_solaris () {
test -n "$pp_services" && test -n "$pp_services" &&
for _svc in $pp_services; do for _svc in $pp_services; do
pp_load_service_vars $_svc pp_load_service_vars $_svc
pp_solaris_smf $_svc
pp_solaris_make_service $_svc pp_solaris_make_service $_svc
pp_solaris_install_service $_svc | pp_prepend $pp_wrkdir/postinstall pp_solaris_install_service $_svc | pp_prepend $pp_wrkdir/postinstall
pp_prepend $pp_wrkdir/preremove <<-. pp_solaris_remove_service $_svc | pp_prepend $pp_wrkdir/preremove
/etc/init.d/$_svc stop >/dev/null 2>/dev/null unset pp_svc_xml_file
# Remove the service from SMF if present
if [ "x${PKG_INSTALL_ROOT}" = 'x' ]; then
if [ -x /usr/sbin/svcadm ] ; then
# Likely un-needed, but just in case.
/usr/sbin/svcadm disable -s $_svc 2>/dev/null
/usr/sbin/svccfg delete $_svc 2>/dev/null
fi
fi
.
done done
test -n "$pp_service_groups" && test -n "$pp_service_groups" &&
@@ -3320,12 +3312,12 @@ pp_backend_solaris_function() {
} }
pp_backend_solaris_init_svc_vars () { pp_backend_solaris_init_svc_vars () {
pp_solaris_smf_category= _smf_category=${pp_solaris_smf_category:-application}
_smf_method_envvar_name=${smf_method_envvar_name:-"PP_SMF_SERVICE"}
pp_solaris_service_shell=/sbin/sh pp_solaris_service_shell=/sbin/sh
} }
pp_solaris_init_svc () { pp_solaris_init_svc () {
smf_category=${pp_solaris_smf_category:-application}
smf_version=1 smf_version=1
smf_type=service smf_type=service
solaris_user= solaris_user=
@@ -3343,40 +3335,116 @@ pp_solaris_init_svc () {
} }
pp_solaris_smf () { pp_solaris_smf () {
typeset f typeset f _pp_solaris_service_script svc _pp_solaris_manpage
f=/var/svc/manifest/$smf_category/$1
pp_solaris_name=${pp_solaris_name:-$name}
pp_solaris_manpath=${pp_solaris_manpath:-"/usr/share/man"}
smf_start_timeout=${smf_start_timeout:-60}
smf_stop_timeout=${smf_stop_timeout:-60}
smf_restart_timeout=${smf_restart_timeout:-60}
svc=${pp_solaris_smf_service_name:-$1}
_pp_solaris_service_script=${pp_solaris_service_script:-"/etc/init.d/${pp_solaris_service_script_name:-$svc}"}
_pp_solaris_manpage=${pp_solaris_manpage:-$pp_solaris_smf_service_name}
if [ -z $pp_svc_xml_file ]; then
pp_svc_xml_file="/var/svc/manifest/$_smf_category/$svc.xml"
echo "## Generating the smf service manifest file for $pp_svc_xml_file"
else
echo "## SMF service manifest file already defined at $pp_svc_xml_file"
if [ -z $pp_solaris_smf_service_name ] || [ -z $pp_solaris_smf_category ] || [ -z $pp_solaris_service_script ] || [ -z $smf_method_envvar_name ]; then
pp_error "All required variables are not set.\n"\
"When using a custom manifest file all of the following variables must be set:\n"\
"pp_solaris_smf_service_name, pp_solaris_smf_category, pp_solaris_service_script and smf_method_envvar_name.\n\n"\
"Example:\n"\
" \$pp_solaris_smf_category=application\n"\
" \$pp_solaris_smf_service_name=pp\n\n"\
" <service name='application/pp' type='service' version='1'>\n\n"\
"Example:\n"\
" \$pp_solaris_service_script=/etc/init.d/pp\n\n"\
" <exec_method type='method' name='start' exec='/etc/init.d/pp' />\n\n"\
"Example:\n"\
" \$smf_method_envvar_name=PP_SMF_SERVICE\n\n"\
" <method_environment>\n"\
" <envvar name='PP_SMF_SERVICE' value='1'/>\n"\
" </method_environment>\n"
return 1
fi
return 0
fi
f=$pp_svc_xml_file
pp_add_file_if_missing $f || pp_add_file_if_missing $f ||
return 0 return 0
_pp_solaris_smf_dependencies="
<dependency name='pp_local_filesystems'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<dependency name='pp_single-user'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/milestone/single-user' />
</dependency>
"
_pp_solaris_smf_dependencies=${pp_solaris_smf_dependencies:-$_pp_solaris_smf_dependencies}
cat <<-. >$pp_destdir$f cat <<-. >$pp_destdir$f
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
$copyright <!--
Generated by PolyPackage $pp_version $copyright
--> Generated by PolyPackage $pp_version
-->
<service name='$smf_category/$1' <service_bundle type='manifest' name='${pp_solaris_name}:${svc}' >
type='$smf_type' <service name='$_smf_category/$svc'
version='$smf_version'> type='$smf_type'
version='$smf_version'>
<single_instance /> <create_default_instance enabled='false'/>
<exec_method type='method' name='start' <single_instance />
exec=''
timeout_seconds='60'>
<method_context>
<method_credential user='${solaris_user:-$user}' />
</method_context>
</exec>
<exec_method type='method' name='stop' $_pp_solaris_smf_dependencies
exec=':kill -${solaris_stop_signal:-$stop_signal}'>
<method_context>
<method_credential user='${solaris_user:-$user}' />
</method_context>
</exec>
$pp_solaris_smf_additional_dependencies
<method_context>
<method_credential user='${solaris_user:-$user}' />
<method_environment>
<envvar name='$_smf_method_envvar_name' value='1'/>
</method_environment>
</method_context>
<exec_method type='method' name='start'
exec='$_pp_solaris_service_script start'
timeout_seconds='$smf_start_timeout' />
<exec_method type='method' name='stop'
exec='$_pp_solaris_service_script stop'
timeout_seconds='$smf_stop_timeout' />
<exec_method type='method' name='restart'
exec='$_pp_solaris_service_script restart'
timeout_seconds='$smf_restart_timeout' />
<template>
<common_name>
<loctext xml:lang='C'>$description</loctext>
</common_name>
<documentation>
<manpage title='$pp_solaris_manpage' section='1' manpath='$pp_solaris_manpath'/>
</documentation>
</template>
</service> </service>
</service_bundle>
. .
} }
@@ -3447,15 +3515,13 @@ pp_solaris_make_service_group () {
. .
} }
pp_solaris_make_service () { pp_solaris_make_service () {
typeset file out _cmd svc typeset file out _cmd svc
svc="$1" svc="${pp_solaris_smf_service_name:-$1}"
file="/etc/init.d/$svc" file=${pp_solaris_service_script:-"/etc/init.d/${pp_solaris_service_script_name:-$svc}"}
out="$pp_destdir$file" out="$pp_destdir$file"
#-- return if we don't need to create the init script #-- return if we don't need to create the init script
pp_add_file_if_missing "$file" run 755 || pp_add_file_if_missing "$file" run 755 ||
return 0 return 0
@@ -3466,12 +3532,12 @@ pp_solaris_make_service () {
#-- Start SMF integration. #-- Start SMF integration.
if [ -n "$pp_svc_xml_file" ] ; then if [ -n "$pp_svc_xml_file" ] ; then
cat <<_EOF >>$out cat <<_EOF >>$out
if [ -x /usr/sbin/svcadm ] && [ "x\$1" != "xstatus" ] && [ "t\$QUEST_SMF_SERVICE" = "t" ] ; then if [ -x /usr/sbin/svcadm ] && [ "x\$1" != "xstatus" ] && [ "t\$$_smf_method_envvar_name" = "t" ] ; then
case "\$1" in case "\$1" in
start) start)
echo "starting $svc" echo "starting $svc"
/usr/sbin/svcadm clear svc:/quest/$svc:default >/dev/null 2>&1 /usr/sbin/svcadm clear svc:/$_smf_category/$svc:default >/dev/null 2>&1
/usr/sbin/svcadm enable -s quest/$svc /usr/sbin/svcadm enable -s $_smf_category/$svc
RESULT=\$? RESULT=\$?
if [ "\$RESULT" -ne 0 ] ; then if [ "\$RESULT" -ne 0 ] ; then
echo "Error \$RESULT starting $svc" echo "Error \$RESULT starting $svc"
@@ -3479,20 +3545,20 @@ if [ -x /usr/sbin/svcadm ] && [ "x\$1" != "xstatus" ] && [ "t\$QUEST_SMF_SERVICE
;; ;;
stop) stop)
echo "stopping $svc" echo "stopping $svc"
/usr/sbin/svcadm disable -ts quest/$svc /usr/sbin/svcadm disable -ts $_smf_category/$svc
;; ;;
restart) restart)
echo "restarting $svc" echo "restarting $svc"
/usr/sbin/svcadm disable -ts quest/$svc /usr/sbin/svcadm disable -ts $_smf_category/$svc
/usr/sbin/svcadm clear svc:/quest/$svc:default >/dev/null 2>&1 /usr/sbin/svcadm clear svc:/$_smf_category/$svc:default >/dev/null 2>&1
/usr/sbin/svcadm enable -s quest/$svc /usr/sbin/svcadm enable -s $_smf_category/$svc
RESULT=\$? RESULT=\$?
if [ "\$RESULT" -ne 0 ] ; then if [ "\$RESULT" -ne 0 ] ; then
echo "Error \$RESULT starting $svc" echo "Error \$RESULT starting $svc"
fi fi
;; ;;
*) *)
echo "Usage: /etc/init.d/$svc {start|stop|restart|status}" echo "Usage: $file {start|stop|restart|status}"
exit 1 exit 1
esac esac
exit 0 exit 0
@@ -3601,11 +3667,32 @@ _EOF
. .
} }
pp_solaris_remove_service () {
typeset file svc
svc="${pp_solaris_smf_service_name:-$1}"
file=${pp_solaris_service_script:-"/etc/init.d/${pp_solaris_service_script_name:-$svc}"}
echo '
'$file' stop >/dev/null 2>/dev/null
if [ "x${PKG_INSTALL_ROOT}" = 'x' ]; then
if [ -x /usr/sbin/svcadm ] ; then
# Likely un-needed, but just in case.
/usr/sbin/svcadm disable -s '$svc' 2>/dev/null
/usr/sbin/svccfg delete '$svc' 2>/dev/null
fi
fi
'
}
pp_solaris_install_service () { pp_solaris_install_service () {
typeset s k l typeset s k l file svc
s="${solaris_sysv_init_start}$1"
k="${solaris_sysv_init_kill}$1" svc="${pp_solaris_smf_service_name:-$1}"
file=${pp_solaris_service_script:-"/etc/init.d/${pp_solaris_service_script_name:-$svc}"}
s="${solaris_sysv_init_start}$svc"
k="${solaris_sysv_init_kill}$svc"
echo ' echo '
if [ "x${PKG_INSTALL_ROOT}" != "x" ]; then if [ "x${PKG_INSTALL_ROOT}" != "x" ]; then
@@ -3616,37 +3703,37 @@ if [ "x${PKG_INSTALL_ROOT}" != "x" ]; then
for state in ${solaris_sysv_init_start_states}; do for state in ${solaris_sysv_init_start_states}; do
l="/etc/rc$state.d/$s" l="/etc/rc$state.d/$s"
echo "echo '$l'" echo "echo '$l'"
echo "installf -c run \$PKGINST \$PKG_INSTALL_ROOT$l=../init.d/$1 s" echo "installf -c run \$PKGINST \$PKG_INSTALL_ROOT$l=$file s"
pp_solaris_space /etc/rc$state.d 0 1 pp_solaris_space /etc/rc$state.d 0 1
done done
test -n "${solaris_sysv_init_kill_states}" && test -n "${solaris_sysv_init_kill_states}" &&
for state in ${solaris_sysv_init_kill_states}; do for state in ${solaris_sysv_init_kill_states}; do
l="/etc/rc$state.d/$k" l="/etc/rc$state.d/$k"
echo "echo '$l'" echo "echo '$l'"
echo "installf -c run \$PKGINST \$PKG_INSTALL_ROOT$l=../init.d/$1 s" echo "installf -c run \$PKGINST \$PKG_INSTALL_ROOT$l=$file s"
pp_solaris_space /etc/rc$state.d 0 1 pp_solaris_space /etc/rc$state.d 0 1
done done
echo ' echo '
fi fi
else else
if [ -x /usr/sbin/svcadm ]; then if [ -x /usr/sbin/svcadm ]; then
echo "Registering '$1' with SMF" echo "Registering '$svc' with SMF"
/usr/sbin/svcadm disable -s '$1' 2>/dev/null /usr/sbin/svcadm disable -s '$svc' 2>/dev/null
/usr/sbin/svccfg delete '$1' 2>/dev/null /usr/sbin/svccfg delete '$svc' 2>/dev/null
/usr/sbin/svccfg import '$pp_svc_xml_file' 2>/dev/null /usr/sbin/svccfg import '$pp_svc_xml_file'
else' else'
test -n "${solaris_sysv_init_start_states}" && test -n "${solaris_sysv_init_start_states}" &&
for state in ${solaris_sysv_init_start_states}; do for state in ${solaris_sysv_init_start_states}; do
l="/etc/rc$state.d/$s" l="/etc/rc$state.d/$s"
echo "echo '$l'" echo "echo '$l'"
echo "installf -c run \$PKGINST \$PKG_INSTALL_ROOT$l=../init.d/$1 s" echo "installf -c run \$PKGINST \$PKG_INSTALL_ROOT$l=$file s"
pp_solaris_space /etc/rc$state.d 0 1 pp_solaris_space /etc/rc$state.d 0 1
done done
test -n "${solaris_sysv_init_kill_states}" && test -n "${solaris_sysv_init_kill_states}" &&
for state in ${solaris_sysv_init_kill_states}; do for state in ${solaris_sysv_init_kill_states}; do
l="/etc/rc$state.d/$k" l="/etc/rc$state.d/$k"
echo "echo '$l'" echo "echo '$l'"
echo "installf -c run \$PKGINST \$PKG_INSTALL_ROOT$l=../init.d/$1 s" echo "installf -c run \$PKGINST \$PKG_INSTALL_ROOT$l=$file s"
pp_solaris_space /etc/rc$state.d 0 1 pp_solaris_space /etc/rc$state.d 0 1
done done
echo ' echo '