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