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