From add7f327eaae3e6d27464a1a99c862b1a55dae9a Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 14 Jan 2011 14:33:32 -0500 Subject: [PATCH] sync with git version --- pp | 221 ++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 154 insertions(+), 67 deletions(-) diff --git a/pp b/pp index 206d0b1e1..6d622d4e1 100755 --- a/pp +++ b/pp @@ -1,6 +1,6 @@ #!/bin/sh -# (c) 2010 Quest Software, Inc. All rights reserved -pp_revision="300" +# (c) 2011 Quest Software, Inc. All rights reserved +pp_revision="301" # Copyright 2010 Quest Software, Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -3056,19 +3056,11 @@ pp_backend_solaris () { test -n "$pp_services" && for _svc in $pp_services; do pp_load_service_vars $_svc + pp_solaris_smf $_svc pp_solaris_make_service $_svc pp_solaris_install_service $_svc | pp_prepend $pp_wrkdir/postinstall - pp_prepend $pp_wrkdir/preremove <<-. - /etc/init.d/$_svc stop >/dev/null 2>/dev/null - # 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 -. + pp_solaris_remove_service $_svc | pp_prepend $pp_wrkdir/preremove + unset pp_svc_xml_file done test -n "$pp_service_groups" && @@ -3320,12 +3312,12 @@ pp_backend_solaris_function() { } 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_init_svc () { - smf_category=${pp_solaris_smf_category:-application} smf_version=1 smf_type=service solaris_user= @@ -3343,40 +3335,116 @@ pp_solaris_init_svc () { } pp_solaris_smf () { - typeset f - f=/var/svc/manifest/$smf_category/$1 + typeset f _pp_solaris_service_script svc _pp_solaris_manpage + + 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"\ + " \n\n"\ + "Example:\n"\ + " \$pp_solaris_service_script=/etc/init.d/pp\n\n"\ + " \n\n"\ + "Example:\n"\ + " \$smf_method_envvar_name=PP_SMF_SERVICE\n\n"\ + " \n"\ + " \n"\ + " \n" + + return 1 + fi + return 0 + fi + + f=$pp_svc_xml_file pp_add_file_if_missing $f || return 0 - cat <<-. >$pp_destdir$f - - - - - - - - - - - - - - - - - - + _pp_solaris_smf_dependencies=" + + + + + + + +" + _pp_solaris_smf_dependencies=${pp_solaris_smf_dependencies:-$_pp_solaris_smf_dependencies} + cat <<-. >$pp_destdir$f + + + + + + + + + + + + $_pp_solaris_smf_dependencies + + $pp_solaris_smf_additional_dependencies + + + + + + + + + + + + + + + + . } @@ -3447,15 +3515,13 @@ pp_solaris_make_service_group () { . } - pp_solaris_make_service () { typeset file out _cmd svc - svc="$1" - file="/etc/init.d/$svc" + svc="${pp_solaris_smf_service_name:-$1}" + file=${pp_solaris_service_script:-"/etc/init.d/${pp_solaris_service_script_name:-$svc}"} out="$pp_destdir$file" - #-- return if we don't need to create the init script pp_add_file_if_missing "$file" run 755 || return 0 @@ -3466,12 +3532,12 @@ pp_solaris_make_service () { #-- Start SMF integration. if [ -n "$pp_svc_xml_file" ] ; then 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 start) echo "starting $svc" - /usr/sbin/svcadm clear svc:/quest/$svc:default >/dev/null 2>&1 - /usr/sbin/svcadm enable -s quest/$svc + /usr/sbin/svcadm clear svc:/$_smf_category/$svc:default >/dev/null 2>&1 + /usr/sbin/svcadm enable -s $_smf_category/$svc RESULT=\$? if [ "\$RESULT" -ne 0 ] ; then echo "Error \$RESULT starting $svc" @@ -3479,20 +3545,20 @@ if [ -x /usr/sbin/svcadm ] && [ "x\$1" != "xstatus" ] && [ "t\$QUEST_SMF_SERVICE ;; stop) echo "stopping $svc" - /usr/sbin/svcadm disable -ts quest/$svc + /usr/sbin/svcadm disable -ts $_smf_category/$svc ;; restart) echo "restarting $svc" - /usr/sbin/svcadm disable -ts quest/$svc - /usr/sbin/svcadm clear svc:/quest/$svc:default >/dev/null 2>&1 - /usr/sbin/svcadm enable -s quest/$svc + /usr/sbin/svcadm disable -ts $_smf_category/$svc + /usr/sbin/svcadm clear svc:/$_smf_category/$svc:default >/dev/null 2>&1 + /usr/sbin/svcadm enable -s $_smf_category/$svc RESULT=\$? if [ "\$RESULT" -ne 0 ] ; then echo "Error \$RESULT starting $svc" fi ;; *) - echo "Usage: /etc/init.d/$svc {start|stop|restart|status}" + echo "Usage: $file {start|stop|restart|status}" exit 1 esac 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 () { - typeset s k l - s="${solaris_sysv_init_start}$1" - k="${solaris_sysv_init_kill}$1" + typeset s k l file svc + + 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 ' 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 l="/etc/rc$state.d/$s" 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 done test -n "${solaris_sysv_init_kill_states}" && for state in ${solaris_sysv_init_kill_states}; do l="/etc/rc$state.d/$k" 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 done echo ' fi else if [ -x /usr/sbin/svcadm ]; then - echo "Registering '$1' with SMF" - /usr/sbin/svcadm disable -s '$1' 2>/dev/null - /usr/sbin/svccfg delete '$1' 2>/dev/null - /usr/sbin/svccfg import '$pp_svc_xml_file' 2>/dev/null + echo "Registering '$svc' with SMF" + /usr/sbin/svcadm disable -s '$svc' 2>/dev/null + /usr/sbin/svccfg delete '$svc' 2>/dev/null + /usr/sbin/svccfg import '$pp_svc_xml_file' else' test -n "${solaris_sysv_init_start_states}" && for state in ${solaris_sysv_init_start_states}; do l="/etc/rc$state.d/$s" 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 done test -n "${solaris_sysv_init_kill_states}" && for state in ${solaris_sysv_init_kill_states}; do l="/etc/rc$state.d/$k" 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 done echo ' -- 2.40.0