204N/A#!/bin/sh
204N/A
204N/A#
204N/A# CDDL HEADER START
204N/A#
204N/A# The contents of this file are subject to the terms of the
204N/A# Common Development and Distribution License (the "License").
204N/A# You may not use this file except in compliance with the License.
204N/A#
204N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
204N/A# or http://www.opensolaris.org/os/licensing.
204N/A# See the License for the specific language governing permissions
204N/A# and limitations under the License.
204N/A#
204N/A# When distributing Covered Code, include this CDDL HEADER in each
204N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
204N/A# If applicable, add the following below this CDDL HEADER, with the
204N/A# fields enclosed by brackets "[]" replaced with your own identifying
204N/A# information: Portions Copyright [yyyy] [name of copyright owner]
204N/A#
204N/A# CDDL HEADER END
204N/A#
6278N/A# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
204N/A#
204N/A
204N/A# Unfortunately, the gnuplot demo wants run in the
204N/A# /usr/demo/gnuplot directory. While there it wants to read and
204N/A# create files. But ordinary users can't create files there. So
204N/A# we will create a temporary directory, put in symlinks to the
204N/A# gnuplot data files, and run the gnuplot command from there.
204N/A# This will allow us to run the gnuplot demo from any directory.
204N/A#
204N/A# If the environment variable $GNUPLOT_DEMO_SAVE_FILES is set to y,
204N/A# then we will save any new files that get created back to the
204N/A# current directory. This can also be accomplished by
204N/A# "rundemo -save-files".
204N/A#
204N/A# There are two font files that are not included. Set
204N/A# corresponding environment variables for sfrm1000.pfb and
204N/A# cmmi10.pfb if running the demo fontfile_latex.dem.
204N/A#
204N/A# With no arguments we will run the default demo.
204N/A# With arguments we will run gnuplot with those arguments.
204N/A# One easy way to run the gnuplot demo is "rundemo < /dev/null"
204N/A
204N/AGNUPLOT_DEMO_DIR="${GNUPLOT_DEMO_DIR:-/usr/demo/gnuplot}"
204N/AGNUPLOT_DEMO_PROGRAM="${GNUPLOT_DEMO_PROGRAM:-gnuplot}"
204N/AGNUPLOT_DEMO_DEFAULT="${GNUPLOT_DEMO_DEFAULT:-all.dem}"
204N/AGNUPLOT_DEMO_GSFONTS="${GNUPLOT_DEMO_GSFONTS:-/usr/share/ghostscript/fonts}"
204N/AGNUPLOT_DEMO_P052003L_PFB="${GNUPLOT_DEMO_P052003L_PFB:-$GNUPLOT_DEMO_GSFONTS/p052003l.pfb}"
204N/AGNUPLOT_DEMO_P052023L_PFB="${GNUPLOT_DEMO_P052023L_PFB:-$GNUPLOT_DEMO_GSFONTS/p052023l.pfb}"
204N/AGNUPLOT_DEMO_TMPDIR="/tmp/gnuplot_demo_`logname`_$$"
204N/AGNUPLOT_DEMO_LIST="$GNUPLOT_DEMO_DIR/*.bin \
204N/A $GNUPLOT_DEMO_DIR/*.cfg \
204N/A $GNUPLOT_DEMO_DIR/*.cor \
204N/A $GNUPLOT_DEMO_DIR/*.dat \
204N/A $GNUPLOT_DEMO_DIR/*.dem \
204N/A $GNUPLOT_DEMO_DIR/*.edf \
204N/A $GNUPLOT_DEMO_DIR/*.fnc \
204N/A $GNUPLOT_DEMO_DIR/*.inc \
204N/A $GNUPLOT_DEMO_DIR/*.par \
204N/A $GNUPLOT_DEMO_DIR/*.pdb \
204N/A $GNUPLOT_DEMO_DIR/*.r3d \
204N/A $GNUPLOT_DEMO_DIR/*.rgb \
204N/A $GNUPLOT_DEMO_DIR/*.rot \
204N/A $GNUPLOT_DEMO_DIR/binary[123] \
204N/A $GNUPLOT_DEMO_DIR/bldg.png \
204N/A $GNUPLOT_DEMO_DIR/gnu-valley \
6278N/A $GNUPLOT_DEMO_DIR/demo_plugin.so \
204N/A $GNUPLOT_DEMO_DIR/random-points \
204N/A $GNUPLOT_DEMO_P052003L_PFB \
204N/A $GNUPLOT_DEMO_P052023L_PFB \
204N/A $GNUPLOT_DEMO_CMMI10_PFB \
204N/A $GNUPLOT_DEMO_SFRM1000_PFB"
204N/AGNUPLOT_DEMO_SAVE_FILES=${GNUPLOT_DEMO_SAVE_FILES:-n}
204N/A
204N/Aif [ "x$1" = "x-save-files" ]
204N/Athen
204N/A GNUPLOT_DEMO_SAVE_FILES="y"
204N/A shift
204N/A
204N/Aelif [ "x$1" = "x-delete-files" ]
204N/Athen
204N/A GNUPLOT_DEMO_SAVE_FILES="n"
204N/A shift
204N/Afi
204N/A
204N/A# if we are interrupted or terminated, remove the temporary
204N/A# directory we will create.
204N/A
204N/Aif [ "$GNUPLOT_DEMO_SAVE_FILES" = "y" ]
204N/Athen
204N/A trap "find $GNUPLOT_DEMO_TMPDIR -type f -a -exec cp -p {} . \; ; rm -rf $GNUPLOT_DEMO_TMPDIR; exit 1" INT TERM
204N/Aelse
204N/A trap "rm -rf $GNUPLOT_DEMO_TMPDIR; exit 1" INT TERM
204N/Afi
204N/A
204N/A# Create a writeable temporary directory to run the demo from.
204N/A
204N/Amkdir $GNUPLOT_DEMO_TMPDIR
204N/Achmod u+rwx $GNUPLOT_DEMO_TMPDIR
204N/A
204N/A# Make symlinks in that directory to the demo sources
204N/A
204N/Afor GNUPLOT_DEMO_FILE in $GNUPLOT_DEMO_LIST
204N/Ado
204N/A ln -s $GNUPLOT_DEMO_FILE $GNUPLOT_DEMO_TMPDIR
204N/Adone
204N/A
204N/A# Run the gnuplot demo in that directory.
204N/A
204N/Aif [ "$#" -eq 0 ]
204N/Athen
204N/A (cd $GNUPLOT_DEMO_TMPDIR;
204N/A exec $GNUPLOT_DEMO_PROGRAM $GNUPLOT_DEMO_DEFAULT)
204N/Aelse
204N/A (cd $GNUPLOT_DEMO_TMPDIR;
204N/A exec $GNUPLOT_DEMO_PROGRAM $*)
204N/Afi
204N/A
204N/A# Save the gnuplot exit status
204N/A
204N/AGNUPLOT_DEMO_EXITSTATUS="$?"
204N/A
204N/A# If desired save any new files that got created in the temporary
204N/A# directory
204N/A
204N/Aif [ "$GNUPLOT_DEMO_SAVE_FILES" = "y" ]
204N/Athen
204N/A find $GNUPLOT_DEMO_TMPDIR -type f -exec cp -p {} . \;
204N/Afi
204N/A
204N/A# Remove the temporary directory
204N/A
204N/Arm -rf $GNUPLOT_DEMO_TMPDIR
204N/A
204N/A# exit with the exit status from the gnuplot command
204N/A
204N/Aexit $GNUPLOT_DEMO_EXITSTATUS