SUNWgnome-panel-gnome-about.ksh revision 9479
10139N/A#!/bin/ksh -ph
10139N/A##
10139N/A## This script wraps GNOME About, which is called by GNOME Session the first
20904N/A## time that a user logs in, and does some other iniital login tasks:
10139N/A## - Creates a launcher on the user's Desktop to open the Solaris Developer
10139N/A## Guide start page
10139N/A## - Launchs Firefox with the start page.
17835N/A## - For first logon by root launches users-admin tool
17835N/A##
10139N/A##
17178N/A#
18603N/A# CDDL HEADER START
17178N/A#
10139N/A# The contents of this file are subject to the terms of the
11195N/A# Common Development and Distribution License, Version 1.0 only
10139N/A# (the "License"). You may not use this file except in compliance
10139N/A# with the License.
20904N/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.
18615N/A# See the License for the specific language governing permissions
10139N/A# and limitations under the License.
20904N/A#
10142N/A# When distributing Covered Code, include this CDDL HEADER in each
17332N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
12570N/A# If applicable, add the following below this CDDL HEADER, with the
17332N/A# fields enclosed by brackets "[]" replaced with your own identifying
12773N/A# information: Portions Copyright [yyyy] [name of copyright owner]
12773N/A#
12773N/A# CDDL HEADER END
19082N/A#
19082N/A#
10139N/A# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
15601N/A# Use is subject to license terms.
17332N/A#
12570N/A
17476N/A##
17332N/A## Figure out the base installdir
13551N/A##
17476N/ABASEDIR="${0%%/bin*}"
15355N/Aif [ -z "$BASEDIR" ]; then
17476N/A # /bin tends to be a symbolic link, so follow it and do calc basedir off
16972N/A # that.
17476N/A DIRNAME=`dirname $0`
17005N/A BASEDIR=`cd "$DIRNAME"; sh -c pwd`
17476N/A BASEDIR="${BASEDIR%%/bin*}"
17026N/Afi
17476N/A
20152N/A##
20152N/A## Create variables
20261N/A##
20261N/AGNOME_ABOUT_BIN="${BASEDIR}/lib/gnome-about"
20371N/AGCONFTOOL="${BASEDIR}/bin/gconftool-2"
20371N/AFIREFOX="${BASEDIR}/bin/firefox"
20784N/AUSERS_ADMIN="${BASEDIR}/bin/users-admin"
20904N/AXPG4_ID="/usr/xpg4/bin/id"
20904N/AID="/usr/xpg4/bin/id"
20904N/A
20904N/AGCONF_DEVGUIDE_PROMPT_KEY="/apps/gnome-session/options/sun_extensions/viewed_dev_guide_jds_solaris"
20904N/ASOLDEVEX_ROOT="${BASEDIR}/share/doc/soldevex/html"
10139N/ASOLDEVEX_FILE="developer_guide.html"
10139N/AXDG_APPLICATIONS_DIR="${BASEDIR}/share/applications"
10139N/ASOLDEVEX_DESKTOP_FILE="devguide.desktop"
10139N/AUSER_DESKTOP_DIR="${HOME}/Desktop"
10139N/A
10139N/A##
10139N/A## Define some utility functions
10139N/A##
10139N/A
10139N/A#
10139N/A# Checks if it's the first time the user is running gnome-about
10139N/A#
10139N/AisFirstTime() {
10139N/A typeset value=""
10139N/A if [ -x "${GCONFTOOL}" ]; then
10139N/A value=`${GCONFTOOL} -g "${GCONF_DEVGUIDE_PROMPT_KEY}" 2>/dev/null`
10139N/A fi
10139N/A test "${value}" != "true"
10139N/A return $?
10139N/A}
10139N/A
10139N/AmarkFirstRunDone() {
10139N/A if [ -x "${GCONFTOOL}" ]; then
10139N/A ${GCONFTOOL} -s -t bool "${GCONF_DEVGUIDE_PROMPT_KEY}" true 2>/dev/null
10139N/A return 0
10139N/A fi
10139N/A return 1
10139N/A}
10139N/A
10139N/A#
10139N/A# Looks for the developer guide HTML file.
10139N/A#
10139N/A# NOTE: First checks if a localised version exists, otherwise picks the
10139N/A# default version.
10139N/A#
10139N/AlocateHTMLFile() {
10139N/A typeset LANG_FILE="${SOLDEVEX_ROOT}/${LANG}/${SOLDEVEX_FILE}"
10139N/A typeset DEFAULT_FILE="${SOLDEVEX_ROOT}/${SOLDEVEX_FILE}"
10139N/A if [ -r "${LANG_FILE}" ]; then
10139N/A echo "${LANG_FILE}"
10139N/A elif [ -r "${DEFAULT_FILE}" ]; then
10139N/A echo "${DEFAULT_FILE}"
10139N/A else
10139N/A echo ""
10139N/A return 1
10139N/A fi
10139N/A return 0
10139N/A}
10139N/A
10139N/A#
10139N/A# Attempts to create an launcher on the user's desktop for a pointer to the
10139N/A# Developer Guide.
10139N/A#
20784N/AcopyDesktopFile() {
20784N/A typeset XDG_DESKTOP_FILE="${XDG_APPLICATIONS_DIR}/${SOLDEVEX_DESKTOP_FILE}"
20784N/A typeset USER_DESKTOP_FILE="${USER_DESKTOP_DIR}/${SOLDEVEX_DESKTOP_FILE}"
20784N/A
20784N/A if [ -r "${XDG_DESKTOP_FILE}" ]; then
10139N/A if [ ! -w "${USER_DESKTOP_DIR}" ]; then
10142N/A mkdir "${USER_DESKTOP_DIR}" || return 1 # If fails return
10139N/A fi
10139N/A if [ ! -e "${USER_DESKTOP_FILE}" ]; then
20784N/A cp "${XDG_DESKTOP_FILE}" "${USER_DESKTOP_FILE}" || return 1 # If fails return
20784N/A fi
20784N/A else
20784N/A return 1
20784N/A fi
20784N/A return 0
20784N/A}
20784N/A
20784N/A#
20784N/A# Launch firefox for the given HTML File
20784N/A#
20784N/AlaunchFirefox() {
20784N/A if [ -x "${FIREFOX}" -a -n "${1}" ]; then
20784N/A ${FIREFOX} "${1}" & # Needs to be run in the background
20784N/A fi
20904N/A}
10139N/A
10139N/A#
10139N/A# Launch UsersAdmin
10139N/A#
10139N/AlaunchUsersAdmin() {
10139N/A if [ -x "${USERS_ADMIN}" ]; then
10139N/A ${USERS_ADMIN} & # Needs to be run in the background
10139N/A fi
10139N/A}
10139N/A
10139N/A#
10139N/A# Check if the user is NOT root.
10139N/A#
10139N/AisNotRootUser() {
10139N/A typeset USER_ID
10139N/A if [ -x "$XPG4_ID" ]; then
20845N/A USER_ID=`${XPG4_ID} -u`
20845N/A else
20845N/A # Needs a little more work to get the UID.
20845N/A USER_ID=`${ID}`
20845N/A USER_ID=`expr "${USER_ID}" : "uid=\([0-9]*\)(.*" 2>/dev/null`
20845N/A fi
10139N/A if [ -n "${USER_ID}" -a "${USER_ID}" -ne 0 ]; then
10139N/A return 0
10139N/A else
10139N/A return 1
10139N/A fi
12773N/A}
12773N/A
12773N/A##
12773N/A## Main
12773N/A##
20904N/A
10139N/Aif isFirstTime; then
20904N/A
10139N/A # See if we have the Solaris Developers Guide somewhere.
10139N/A HTML_FILE=`locateHTMLFile`
11271N/A if [ $? -eq 0 ]; then
10139N/A # Try copy the Desktop entry over to users Desktop dir.
10139N/A copyDesktopFile
10139N/A
10139N/A # Now try to launch Firefox with Dev Guide, but not for root
10139N/A if isNotRootUser; then
20784N/A launchFirefox "${HTML_FILE}"
10139N/A else
10139N/A launchUsersAdmin
10139N/A fi
10139N/A fi
10139N/A
10139N/A # Now that we've finished, don't forget to remember this.
10139N/A markFirstRunDone
10139N/Afi
10139N/A
10139N/A# Finally, just run the GNOME About application, with params, if any.
10139N/Aexec ${GNOME_ABOUT_BIN} ${1+"$@"}
10139N/A