#!/usr/sbin/sh # # Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. # . /lib/svc/share/smf_include.sh # Trusted Extensions non-global zones need special handling case "$1" in 'start') rm $SMF_SYSVOL_FS/name_service_door >/dev/null 2>&1 if (smf_is_system_labeled); then if (smf_is_nonglobalzone); then if [ ! -f /var/tsol/doors/nscd_per_label ]; then # Create a door to the global zone daemon. ln -s /var/tsol/doors/name_service_door \ $SMF_SYSVOL_FS || exit $SMF_EXIT_ERR_FATAL # If current service duration is not "transient", # create a dummy background process to preserve # contract lifetime. duration="" if /bin/svcprop -q -c -p startd/duration $SMF_FMRI then duration=`/bin/svcprop -c -p startd/duration \ $SMF_FMRI` fi if [ "$duration" != "transient" ]; then ( while true ; do sleep 3600 ; done ) & fi # The real daemon is not started in non-global zones, # so exit now. exit $SMF_EXIT_OK fi else rm /var/tsol/doors/name_service_door >/dev/null 2>&1 fi fi if is_self_assembly_boot; then # Only import on first boot after install/upgrade /usr/sbin/nscfg import -q $SMF_FMRI err=$? if [ $err -eq 1 ] ; then exec >& 2 echo "WARNING: $SMF_FMRI configuration import error." exit $SMF_EXIT_ERR_CONFIG elif [ $err -eq 3 ] ; then echo "WARNING: $SMF_FMRI no configuration." >& 2 exit $SMF_EXIT_ERR_CONFIG fi fi # Only export if allowed if [[ -w /etc ]]; then /usr/sbin/nscfg export $SMF_FMRI err=$? if [ $err -eq 1 ] ; then exec >& 2 echo "WARNING: $SMF_FMRI configuration export error." exit $SMF_EXIT_ERR_CONFIG fi fi if [ -f /etc/nscd.conf -a -f /usr/sbin/nscd ]; then /usr/sbin/nscd < /dev/null > /dev/msglog 2>&1 & else echo "No /etc/nscd.conf or no /usr/sbin/nscd" exit $SMF_EXIT_ERR_CONFIG fi ;; 'refresh') # When we can't write the configuration file, we want an error. /usr/sbin/nscfg export $SMF_FMRI err=$? if [ $err -eq 2 ] ; then exit $SMF_EXIT_OK elif [ $err -ne 0 ] ; then echo "Unable to create /etc/nscd.conf" exit $SMF_EXIT_ERR_CONFIG fi /usr/bin/pgrep -z `smf_zonename` nscd && \ /usr/bin/pkill -HUP -z `smf_zonename` nscd exit $SMF_EXIT_OK ;; 'unconfigure') # Unroll any admin customization svccfg -s svc:/system/name-service/cache delcust if [ $? -ne 0 ]; then echo "Failed to unroll administrative customizations for $SMF_FMRI" exit $SMF_EXIT_ERR_FATAL fi # Revert legacy config to original state if [[ -w /etc ]]; then /usr/sbin/nscfg export $SMF_FMRI fi exit $SMF_EXIT_OK ;; *) echo "Usage: $0 { start | refresh | unconfigure }" exit 1 ;; esac