19931N/A#!/usr/bin/ksh -p
19931N/A#
19931N/A# CDDL HEADER START
19931N/A#
19931N/A# The contents of this file are subject to the terms of the
19931N/A# Common Development and Distribution License (the "License").
19931N/A# You may not use this file except in compliance with the License.
19931N/A#
19931N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
19931N/A# or http://www.opensolaris.org/os/licensing.
19931N/A# See the License for the specific language governing permissions
19931N/A# and limitations under the License.
19931N/A#
19931N/A# When distributing Covered Code, include this CDDL HEADER in each
19931N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19931N/A# If applicable, add the following below this CDDL HEADER, with the
19931N/A# fields enclosed by brackets "[]" replaced with your own identifying
19931N/A# information: Portions Copyright [yyyy] [name of copyright owner]
19931N/A#
19931N/A# CDDL HEADER END
19931N/A#
20777N/A# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
19931N/A# Use is subject to license terms.
19931N/A
19931N/A# Load SMF constants and functions
19931N/A. /lib/svc/share/smf_include.sh
19931N/A
20777N/AGCONF_DEFAULTS_VALUES="/usr/share/multi-user-desktop/gconf-defaults-optimizations.xml"
20777N/AGCONF_MANDATORY_VALUES="/usr/share/multi-user-desktop/gconf-mandatory-optimizations.xml"
20777N/AGCONF_DEFAULTS_DIR="/etc/gconf/gconf.xml.multi.user.desktop.defaults"
20777N/AGCONF_MANDATORY_DIR="/etc/gconf/gconf.xml.multi.user.desktop.mandatory"
20777N/A
20777N/A# The version of the GConf settings is installed by the GCONF_MANDATORY_VALUES schema
20777N/A# in the GConf path: /desktop/gnome/multi-user-desktop/version
20777N/A# When updating package associated with this script the version from the previously
20777N/A# installed GConf path may differ from this script, then the settings are removed and
20777N/A# re-applied.
20777N/AMULTI_USER_VERSION=1
20777N/A
20777N/AGCONF_TOOL="/usr/bin/gconftool-2"
20777N/AGCONF_MULTI_USER_VERSION="/desktop/gnome/multi-user-desktop/version"
20777N/A
19931N/A
19931N/Aif [[ -z "$SMF_FMRI" ]]; then
19931N/A print "This script can only be invoked by smf(5)"
19931N/A exit $SMF_EXIT_ERR_NOSMF
19931N/Afi
19931N/A
20777N/A# NAME
20777N/A# is_folder_empty
20777N/A#
20777N/A# ARGUMENTS
20777N/A# arg1 - path to the folder
20777N/A#
20777N/A# DESCRIPTION
20777N/A# Checks if folder is empty.
20777N/A#
20777N/A# Returns 0 if folder is empty, doesn't exists
20777N/A# or there is no permissions to access it.
20777N/A# 1 if it's not empty.
20777N/A#
20777N/Ais_folder_empty ()
20777N/A{
20777N/A if [ "$(/usr/bin/ls -A "$1" 2>/dev/null)" ]; then
20777N/A return 1
20777N/A else
20777N/A return 0
20777N/A fi
20777N/A}
20777N/A
20777N/A# NAME
20777N/A# are_multiuser_gconf_settings_uptodate
20777N/A#
20777N/A# ARGUMENTS
20777N/A# NONE
20777N/A#
20777N/A# DESCRIPTION
20777N/A# Checks if the GConf settings installed in the GCONF_DEFAULTS_DIR
20777N/A# and GCONF_MANDATORY_DIR are up to date.
20777N/A#
20777N/A# Returns 0 if the GConf settings are up to date, 1 otherwise.
20777N/A#
20777N/Aare_multiuser_gconf_settings_uptodate ()
20777N/A{
20777N/A RETVAL=1
20777N/A multi_user_version_gconf="$($GCONF_TOOL --get $GCONF_MULTI_USER_VERSION 2>/dev/null)"
20777N/A if [[ $multi_user_version_gconf -eq $MULTI_USER_VERSION ]]; then
20777N/A RETVAL=0
20777N/A fi
20777N/A return $RETVAL
20777N/A
20777N/A}
20777N/A
20777N/A# NAME
20777N/A# clean_up_multiuser_gconf_settings
20777N/A#
20777N/A# ARGUMENTS
20777N/A# NONE
20777N/A#
20777N/A# DESCRIPTION
20777N/A# Removes previous Multi User Desktop GConf settings
20777N/A# if necessary.
20777N/A#
20777N/Aclean_up_multiuser_gconf_settings ()
20777N/A{
20777N/A if ! are_multiuser_gconf_settings_uptodate; then
20777N/A if ! is_folder_empty "$GCONF_DEFAULTS_DIR"; then
20777N/A print "Removing old multi user desktop default settings."
20777N/A rm -rf "${GCONF_DEFAULTS_DIR}/*"
20777N/A fi
20777N/A if ! is_folder_empty "$GCONF_MANDATORY_DIR"; then
20777N/A print "Removing old multi user desktop mandatory settings."
20777N/A rm -rf "${GCONF_MANDATORY_DIR}/*"
20777N/A fi
20777N/A fi
20777N/A}
20777N/A
19931N/Acase "$1" in
19931N/A'start')
20777N/A clean_up_multiuser_gconf_settings
19931N/A
20777N/A if is_folder_empty "$GCONF_DEFAULTS_DIR"; then
20777N/A cmd_load="$GCONF_TOOL --direct --config-source xml:readwrite:${GCONF_DEFAULTS_DIR} --load=${GCONF_DEFAULTS_VALUES}"
20777N/A # Print the command so that the log contains the command used
20777N/A print $cmd_load
20777N/A $cmd_load
20777N/A if [[ $? -ne 0 ]]; then
20777N/A print "failed to invoke: \"${cmd_load}\" for service: $SMF_FMRI"
20777N/A exit $SMF_EXIT_ERR_CONFIG
20777N/A fi
20777N/A fi
19931N/A
20777N/A if is_folder_empty "$GCONF_MANDATORY_DIR"; then
20777N/A cmd_load="$GCONF_TOOL --direct --config-source xml:readwrite:${GCONF_MANDATORY_DIR} --load=${GCONF_MANDATORY_VALUES}"
20777N/A print $cmd_load
20777N/A exec $cmd_load
20777N/A if [[ $? -ne 0 ]]; then
20777N/A print "failed to invoke: \"${cmd_load}\" for service: $SMF_FMRI"
20777N/A exit $SMF_EXIT_ERR_CONFIG
20777N/A fi
19931N/A fi
19931N/A
19931N/A ;;
19931N/A
19931N/A'stop')
20777N/A clean_up_multiuser_gconf_settings
19931N/A
20777N/A if ! is_folder_empty "$GCONF_DEFAULTS_DIR"; then
20777N/A cmd_unload="$GCONF_TOOL --direct --config-source xml:readwrite:${GCONF_DEFAULTS_DIR} --unload=${GCONF_DEFAULTS_VALUES}"
20777N/A print $cmd_unload
20777N/A $cmd_unload
20777N/A if [[ $? -ne 0 ]]; then
20777N/A print "failed to invoke: \"${cmd_unload}\" for service: $SMF_FMRI"
20777N/A exit $SMF_EXIT_ERR_CONFIG
20777N/A fi
20777N/A fi
20777N/A
20777N/A if ! is_folder_empty "$GCONF_MANDATORY_DIR"; then
20777N/A cmd_unload="$GCONF_TOOL --direct --config-source xml:readwrite:${GCONF_MANDATORY_DIR} --unload=${GCONF_MANDATORY_VALUES}"
20777N/A print $cmd_unload
20777N/A exec $cmd_unload
20777N/A if [[ $? -ne 0 ]]; then
20777N/A print "failed to invoke: \"${cmd_unload}\" for service: $SMF_FMRI"
20777N/A exit $SMF_EXIT_ERR_CONFIG
20777N/A fi
19931N/A fi
19931N/A
19931N/A ;;
19931N/A
19931N/A*)
19931N/A print "Usage: $0 { start | stop }"
19931N/A exit $SMF_EXIT_ERR_CONFIG
19931N/A ;;
19931N/A
19931N/Aesac
19931N/Aexit $SMF_EXIT_OK