Revert "remove tsol from xorg-server"
[unleashed-userland.git] / components / image / gnuplot / rundemo
blob52845e5e99f1edc973ca1b17221845ac94a8d707
1 #!/bin/sh
4 # CDDL HEADER START
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]
21 # CDDL HEADER END
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 # "rundemo -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 # With no arguments we will run the default demo.
43 # With arguments we will run gnuplot with those arguments.
44 # One easy way to run the gnuplot demo is "rundemo < /dev/null"
46 GNUPLOT_DEMO_DIR="${GNUPLOT_DEMO_DIR:-/usr/demo/gnuplot}"
47 GNUPLOT_DEMO_PROGRAM="${GNUPLOT_DEMO_PROGRAM:-gnuplot}"
48 GNUPLOT_DEMO_DEFAULT="${GNUPLOT_DEMO_DEFAULT:-all.dem}"
49 GNUPLOT_DEMO_GSFONTS="${GNUPLOT_DEMO_GSFONTS:-/usr/share/ghostscript/fonts}"
50 GNUPLOT_DEMO_P052003L_PFB="${GNUPLOT_DEMO_P052003L_PFB:-$GNUPLOT_DEMO_GSFONTS/p052003l.pfb}"
51 GNUPLOT_DEMO_P052023L_PFB="${GNUPLOT_DEMO_P052023L_PFB:-$GNUPLOT_DEMO_GSFONTS/p052023l.pfb}"
52 GNUPLOT_DEMO_TMPDIR="/tmp/gnuplot_demo_`logname`_$$"
53 GNUPLOT_DEMO_LIST="$GNUPLOT_DEMO_DIR/*.bin \
54 $GNUPLOT_DEMO_DIR/*.cfg \
55 $GNUPLOT_DEMO_DIR/*.cor \
56 $GNUPLOT_DEMO_DIR/*.csv \
57 $GNUPLOT_DEMO_DIR/*.dat \
58 $GNUPLOT_DEMO_DIR/*.dem \
59 $GNUPLOT_DEMO_DIR/*.edf \
60 $GNUPLOT_DEMO_DIR/*.fnc \
61 $GNUPLOT_DEMO_DIR/*.inc \
62 $GNUPLOT_DEMO_DIR/*.par \
63 $GNUPLOT_DEMO_DIR/*.pdb \
64 $GNUPLOT_DEMO_DIR/*.r3d \
65 $GNUPLOT_DEMO_DIR/*.rgb \
66 $GNUPLOT_DEMO_DIR/*.rot \
67 $GNUPLOT_DEMO_DIR/binary[123] \
68 $GNUPLOT_DEMO_DIR/bldg.png \
69 $GNUPLOT_DEMO_DIR/gnu-valley \
70 $GNUPLOT_DEMO_DIR/random-points \
71 $GNUPLOT_DEMO_P052003L_PFB \
72 $GNUPLOT_DEMO_P052023L_PFB \
73 $GNUPLOT_DEMO_CMMI10_PFB \
74 $GNUPLOT_DEMO_SFRM1000_PFB"
75 GNUPLOT_DEMO_SAVE_FILES=${GNUPLOT_DEMO_SAVE_FILES:-n}
77 if [ "x$1" = "x-save-files" ]
78 then
79 GNUPLOT_DEMO_SAVE_FILES="y"
80 shift
82 elif [ "x$1" = "x-delete-files" ]
83 then
84 GNUPLOT_DEMO_SAVE_FILES="n"
85 shift
88 # if we are interrupted or terminated, remove the temporary
89 # directory we will create.
91 if [ "$GNUPLOT_DEMO_SAVE_FILES" = "y" ]
92 then
93 trap "find $GNUPLOT_DEMO_TMPDIR -type f -a -exec cp -p {} . \; ; rm -rf $GNUPLOT_DEMO_TMPDIR; exit 1" INT TERM
94 else
95 trap "rm -rf $GNUPLOT_DEMO_TMPDIR; exit 1" INT TERM
98 # Create a writeable temporary directory to run the demo from.
100 mkdir $GNUPLOT_DEMO_TMPDIR
101 chmod u+rwx $GNUPLOT_DEMO_TMPDIR
103 # Make symlinks in that directory to the demo sources
105 for GNUPLOT_DEMO_FILE in $GNUPLOT_DEMO_LIST
107 ln -s $GNUPLOT_DEMO_FILE $GNUPLOT_DEMO_TMPDIR
108 done
110 # Run the gnuplot demo in that directory.
112 if [ "$#" -eq 0 ]
113 then
114 (cd $GNUPLOT_DEMO_TMPDIR;
115 exec $GNUPLOT_DEMO_PROGRAM $GNUPLOT_DEMO_DEFAULT)
116 else
117 (cd $GNUPLOT_DEMO_TMPDIR;
118 exec $GNUPLOT_DEMO_PROGRAM $*)
121 # Save the gnuplot exit status
123 GNUPLOT_DEMO_EXITSTATUS="$?"
125 # If desired save any new files that got created in the temporary
126 # directory
128 if [ "$GNUPLOT_DEMO_SAVE_FILES" = "y" ]
129 then
130 find $GNUPLOT_DEMO_TMPDIR -type f -exec cp -p {} . \;
133 # Remove the temporary directory
135 rm -rf $GNUPLOT_DEMO_TMPDIR
137 # exit with the exit status from the gnuplot command
139 exit $GNUPLOT_DEMO_EXITSTATUS