Develop and Download Open Source Software

Browse CVS Repository

Contents of /h14m/namazu_for_hns/hns-index2.in

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download)
Sun Mar 10 06:35:58 2002 UTC (22 years, 1 month ago) by kenji
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +93 -56 lines
correct the return value, [hns-dev:00823]

1 #!/bin/sh
2
3 # namazu indexer for hns
4 # version 2.0.0
5 # 2002/3/10 Kenji Suzuki <kenji@h14m.org>
6
7 # Copyright (C) 1998-2002 Kenji Suzuki, HyperNikkiSystem Project
8
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 # $Id: hns-index2.in,v 1.7 2001/10/31 07:29:40 kenji Exp $
24
25 version="2.0.0(Namazu for hns 2.0-pl4+)"
26
27 diaryDir="%DIARYDIR%"
28 indexDir="$diaryDir/namazu2/index"
29 tmpindexDir="$indexDir/tmp"
30 mknmz="%PREFIX%/bin/mknmz"
31 gcnmz="%PREFIX%/bin/gcnmz"
32
33
34 # remove below if you don't use Japanese
35 LC_ALL="ja"
36 export LC_ALL
37 # remove above if you don't use Japanese
38
39
40 clean=0
41 gc=0
42
43 ### functions ###
44
45 # remove tmpindexDir #
46 remove_tmp () {
47 cd "$indexDir"
48 rm -rf "$tmpindexDir.$$"
49 exit 1
50 }
51
52 # show usage #
53 usage () {
54 cat 1>&2 << EOU
55 hns-index2 v$version
56
57 Usage: hns-index2 [OPTIONS]
58 Options
59 [none] --- append index
60 clean, -c --- making index from scratch
61 -d --- debug
62 -gc --- gabage collection of index file
63 -v --- show version
64 -h, -help --- show this help
65 EOU
66 }
67
68 ### signal handler ###
69 trap "remove_tmp" 2 3 6 10 11 15
70
71 ### purse options ###
72 while [ $# -gt 0 ] ; do
73 case $1 in
74 -h|-help)
75 usage
76 exit;;
77 -v)
78 echo "hns-index2 v$version"
79 exit;;
80 -gc)
81 gc=1;;
82 -c|clean)
83 clean=1;;
84 -d)
85 debug_arg="--debug";;
86 -cd)
87 debug_arg="--debug"
88 clean=1;;
89 *)
90 echo "$0: illegal option \"$1\"" 1>&2
91 echo "" 1>&2
92 usage
93 exit 1;;
94 esac
95 shift
96 done
97
98 # sanity check #
99 if [ $gc -ne 0 -a $clean -ne 0 ]; then
100 echo "Do not specify \"-gc\" and \"clean\" simulteniously" 1>&2
101 exit 1
102 fi
103
104
105 ### main ###
106 cd "$indexDir"
107
108 if [ $clean -ne 0 ]; then
109 mkdir "$tmpindexDir.$$" || {\
110 echo "failed to make temporary directory" 1>&2
111 exit 1
112 }
113 cd "$tmpindexDir.$$"
114 fi
115
116 if [ $gc -ne 0 ]; then
117 "$gcnmz" "$indexDir"
118 else
119 "$mknmz" --include=$diaryDir/namazu2/etc/mknmzrc \
120 ${debug_arg} \
121 --media-type=text/hnf \
122 --template-dir=$diaryDir/namazu2/template "$diaryDir"
123 fi
124
125 return_val=$?
126
127 if [ $clean -ne 0 ]; then
128 if [ "$return_val" -eq 0 ]; then
129 mv "$indexDir/NMZ.slog" "$indexDir/MNZ.slog.bk"
130 mv NMZ.* "$indexDir"
131 mv "$indexDir/MNZ.slog.bk" "$indexDir/NMZ.slog"
132 fi
133
134 remove_tmp
135 fi
136
137 exit $return_val
138

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26