Debian Codegraph @

wtools/mkace

raw
1 #! /bin/sh
2 # mkace -- Script to make an AceDB database
3 #
4 # Arguments can be any mixture of:
5 # *.wrm files to override standard ones
6 # *.ace files to load into database
7 # *.tace, */tace (once only) tace program to use
8 # */wspec directory for default .wrm files
9 # all of which are optional,
10 # and there must be one other argument, which is the
11 # name of the database directory being created
12 #
13 # If no tace program is specified on the command line,
14 # env var TACE is tried, and if no joy, your path.
15 #
16 # .wrm files are copied from acedb/wspec in your home
17 # directory if no argument ends with wspec
18
19 WRMS=""
20 ACES=""
21 HASACE=false
22 EXAMPLE=$HOME/acedb/wspec
23
24 while [ $# -gt 0 ]
25 do
26 case $1 in
27 *.wrm) WRMS="$WRMS $1"
28 shift ;;
29 *.ace) ACES="$ACES $1"
30 HASACE=true
31 shift ;;
32 *.tace|*/tace) TACE=$1
33 shift ;;
34 */wspec) EXAMPLE=$1
35 shift ;;
36 *) TOP=$1
37 shift ;;
38 esac
39 done
40
41 echo TOP is $TOP
42 echo WRMS are $WRMS
43 echo ACES are $ACES
44
45 if [ -d "$TOP" ]
46 then
47 rm -rf $TOP
48 fi
49
50 mkdir $TOP
51 mkdir $TOP/database
52 WSPEC=$TOP/wspec
53 mkdir $WSPEC
54
55 for SPECFILE in models.wrm options.wrm passwd.wrm database.wrm
56 do
57 cp $EXAMPLE/$SPECFILE $WSPEC
58 chmod u+w $WSPEC/$SPECFILE
59 done
60
61 for SPECFILE in $WRMS
62 do
63 echo Overriding with $SPECFILE
64 cp $SPECFILE $WSPEC
65 done
66
67 if $HASACE
68 then
69 if [ "$TACE" != "" ]
70 then
71 echo will add $ACES
72 else
73 TACE=`which tace`
74 if [ "$TACE" != "" ]
75 then
76 echo will add $ACES
77 TACETEMP=/tmp/mkace$$
78 echo y > $TACETEMP
79 for ACEFILE in $ACES
80 do
81 echo parse $ACEFILE >> $TACETEMP
82 done
83 echo save >> $TACETEMP
84 echo quit >> $TACETEMP
85 $TACE $TOP < $TACETEMP
86 rm -f $TACETEMP
87 else
88 echo tace not defined -- either give as argument or define TACE in environment
89 exit 1
90 fi
91 fi
92 fi