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