6 # The contents of this file are subject to the terms of the
7 # Common Development and Distribution License (the "License").
8 # You may not use this file except in compliance with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
26 # Unfortunately, the gnuplot demo wants run in the
27 # /usr/demo/gnuplot directory. While there it wants to read and
28 # create files. But ordinary users can't create files there. So
29 # we will create a temporary directory, put in symlinks to the
30 # gnuplot data files, and run the gnuplot command from there.
31 # This will allow us to run the gnuplot demo from any directory.
33 # If the environment variable $GNUPLOT_DEMO_SAVE_FILES is set to y,
34 # then we will save any new files that get created back to the
35 # current directory. This can also be accomplished by
36 # "runtcldemo -save-files".
38 # There are two font files that are not included. Set
39 # corresponding environment variables for sfrm1000.pfb and
40 # cmmi10.pfb if running the demo fontfile_latex.dem.
42 # One easy way to run the gnuplot demo is "runtcldemo"
44 GNUPLOT_DEMO_DIR
="${GNUPLOT_DEMO_DIR:-/usr/demo/gnuplot}"
45 GNUPLOT_DEMO_PROGRAM
="${GNUPLOT_DEMO_PROGRAM:-./gpdemos.tcl}"
46 GNUPLOT_DEMO_GSFONTS
="${GNUPLOT_DEMO_GSFONTS:-/usr/share/ghostscript/fonts}"
47 GNUPLOT_DEMO_P052003L_PFB
="${GNUPLOT_DEMO_P052003L_PFB:-$GNUPLOT_DEMO_GSFONTS/p052003l.pfb}"
48 GNUPLOT_DEMO_P052023L_PFB
="${GNUPLOT_DEMO_P052023L_PFB:-$GNUPLOT_DEMO_GSFONTS/p052023l.pfb}"
49 GNUPLOT_DEMO_TMPDIR
="/tmp/gnuplot_demo_`logname`_$$"
50 GNUPLOT_DEMO_LIST
="$GNUPLOT_DEMO_DIR/*.bin \
51 $GNUPLOT_DEMO_DIR/*.cfg \
52 $GNUPLOT_DEMO_DIR/*.cor \
53 $GNUPLOT_DEMO_DIR/*.csv \
54 $GNUPLOT_DEMO_DIR/*.dat \
55 $GNUPLOT_DEMO_DIR/*.dem \
56 $GNUPLOT_DEMO_DIR/*.edf \
57 $GNUPLOT_DEMO_DIR/*.fnc \
58 $GNUPLOT_DEMO_DIR/*.inc \
59 $GNUPLOT_DEMO_DIR/*.par \
60 $GNUPLOT_DEMO_DIR/*.pdb \
61 $GNUPLOT_DEMO_DIR/*.r3d \
62 $GNUPLOT_DEMO_DIR/*.rgb \
63 $GNUPLOT_DEMO_DIR/*.rot \
64 $GNUPLOT_DEMO_DIR/binary[123] \
65 $GNUPLOT_DEMO_DIR/bldg.png \
66 $GNUPLOT_DEMO_DIR/gnu-valley \
67 $GNUPLOT_DEMO_DIR/random-points \
68 $GNUPLOT_DEMO_DIR/gpdemos.tcl \
69 $GNUPLOT_DEMO_P052003L_PFB \
70 $GNUPLOT_DEMO_P052023L_PFB \
71 $GNUPLOT_DEMO_CMMI10_PFB \
72 $GNUPLOT_DEMO_SFRM1000_PFB"
73 GNUPLOT_DEMO_SAVE_FILES
=${GNUPLOT_DEMO_SAVE_FILES:-n}
75 if [ "x$1" = "x-save-files" ]
77 GNUPLOT_DEMO_SAVE_FILES
="y"
80 elif [ "x$1" = "x-delete-files" ]
82 GNUPLOT_DEMO_SAVE_FILES
="n"
86 # if we are interrupted or terminated, remove the temporary
87 # directory we will create.
89 if [ "$GNUPLOT_DEMO_SAVE_FILES" = "y" ]
91 trap "find $GNUPLOT_DEMO_TMPDIR -type f -a -exec cp -p {} . \; ; rm -rf $GNUPLOT_DEMO_TMPDIR; exit 1" INT TERM
93 trap "rm -rf $GNUPLOT_DEMO_TMPDIR; exit 1" INT TERM
96 # Create a writeable temporary directory to run the demo from.
98 mkdir
$GNUPLOT_DEMO_TMPDIR
99 chmod u
+rwx
$GNUPLOT_DEMO_TMPDIR
101 # Make symlinks in that directory to the demo sources
103 for GNUPLOT_DEMO_FILE
in $GNUPLOT_DEMO_LIST
105 ln -s $GNUPLOT_DEMO_FILE $GNUPLOT_DEMO_TMPDIR
108 # Run the gnuplot demo in that directory.
110 (cd $GNUPLOT_DEMO_TMPDIR;
111 exec $GNUPLOT_DEMO_PROGRAM $
*)
113 # Save the gnuplot exit status
115 GNUPLOT_DEMO_EXITSTATUS
="$?"
117 # If desired save any new files that got created in the temporary
120 if [ "$GNUPLOT_DEMO_SAVE_FILES" = "y" ]
122 find $GNUPLOT_DEMO_TMPDIR -type f
-exec cp -p {} . \
;
125 # Remove the temporary directory
127 rm -rf $GNUPLOT_DEMO_TMPDIR
129 # exit with the exit status from the gnuplot command
131 exit $GNUPLOT_DEMO_EXITSTATUS