r14168: Fix Coverity #219. I think this is a false coverity
[Samba/bb.git] / source3 / script / installswat.sh
blob427e1773620e643dcba79ac8fed01a100850e020
1 #!/bin/sh
2 #first version March 1998, Andrew Tridgell
4 DESTDIR=$1
5 SWATDIR=`echo $2 | sed 's/\/\//\//g'`
6 SRCDIR=$3/
7 BOOKDIR="$DESTDIR/$SWATDIR/using_samba"
9 case $0 in
10 *uninstall*)
11 echo "Removing SWAT from $DESTDIR/$SWATDIR "
12 echo "Removing the Samba Web Administration Tool "
13 echo -n "Removed "
14 mode='uninstall'
17 echo "Installing SWAT in $DESTDIR/$SWATDIR "
18 echo "Installing the Samba Web Administration Tool "
19 echo -n "Installing "
20 mode='install'
22 esac
24 LANGS=". `cd $SRCDIR../swat/; /bin/echo lang/??`"
25 echo "langs are `cd $SRCDIR../swat/lang/; /bin/echo ??` "
27 if test "$mode" = 'install'; then
28 for ln in $LANGS; do
29 SWATLANGDIR="$DESTDIR/$SWATDIR/$ln"
30 for d in $SWATLANGDIR $SWATLANGDIR/help $SWATLANGDIR/images \
31 $SWATLANGDIR/include $SWATLANGDIR/js; do
32 if [ ! -d $d ]; then
33 mkdir -p $d
34 if [ ! -d $d ]; then
35 echo "Failed to make directory $d, does $USER have privileges? "
36 exit 1
39 done
40 done
43 for ln in $LANGS; do
45 # images
46 for f in $SRCDIR../swat/$ln/images/*.png; do
47 if [ ! -f $f ] ; then
48 continue
50 FNAME="$DESTDIR/$SWATDIR/$ln/images/`basename $f`"
51 echo $FNAME
52 if test "$mode" = 'install'; then
53 cp "$f" "$FNAME"
54 if test ! -f "$FNAME"; then
55 echo "Cannot install $FNAME. Does $USER have privileges? "
56 exit 1
58 chmod 0644 "$FNAME"
59 elif test "$mode" = 'uninstall'; then
60 rm -f "$FNAME"
61 if test -f "$FNAME"; then
62 echo "Cannot remove $FNAME. Does $USER have privileges? "
63 exit 1
65 else
66 echo "Unknown mode, $mode. Script called as $0 "
67 exit 1
69 done
71 # html help
72 for f in $SRCDIR../swat/$ln/help/*.html; do
73 if [ ! -f $f ] ; then
74 continue
76 FNAME="$DESTDIR/$SWATDIR/$ln/help/`basename $f`"
77 echo $FNAME
78 if test "$mode" = 'install'; then
79 if [ "x$BOOKDIR" = "x" ]; then
80 cat $f | sed 's/@BOOKDIR@.*$//' > $f.tmp
81 else
82 cat $f | sed 's/@BOOKDIR@//' > $f.tmp
84 f=$f.tmp
85 cp "$f" "$FNAME"
86 rm -f "$f"
87 if test ! -f "$FNAME"; then
88 echo "Cannot install $FNAME. Does $USER have privileges? "
89 exit 1
91 chmod 0644 "$FNAME"
92 elif test "$mode" = 'uninstall'; then
93 rm -f "$FNAME"
94 if test -f "$FNAME"; then
95 echo "Cannot remove $FNAME. Does $USER have privileges? "
96 exit 1
99 done
101 # "server-side" includes
102 for f in $SRCDIR../swat/$ln/include/*; do
103 if [ ! -f $f ] ; then
104 continue
106 FNAME="$DESTDIR/$SWATDIR/$ln/include/`basename $f`"
107 echo $FNAME
108 if test "$mode" = 'install'; then
109 cp "$f" "$FNAME"
110 if test ! -f "$FNAME"; then
111 echo "Cannot install $FNAME. Does $USER have privileges? "
112 exit 1
114 chmod 0644 $FNAME
115 elif test "$mode" = 'uninstall'; then
116 rm -f "$FNAME"
117 if test -f "$FNAME"; then
118 echo "Cannot remove $FNAME. Does $USER have privileges? "
119 exit 1
122 done
124 # javascripts
125 for f in $SRCDIR../swat/$ln/js/*.js; do
126 if [ ! -f $f ] ; then
127 continue
129 FNAME="$DESTDIR/$SWATDIR/$ln/js/`basename $f`"
130 echo $FNAME
131 if test "$mode" = 'install'; then
132 cp "$f" "$FNAME"
133 if test ! -f "$FNAME"; then
134 echo "Cannot install $FNAME. Does $USER have privileges? "
135 exit 1
137 chmod 0644 $FNAME
138 elif test "$mode" = 'uninstall'; then
139 rm -f "$FNAME"
140 if test -f "$FNAME"; then
141 echo "Cannot remove $FNAME. Does $USER have privileges? "
142 exit 1
145 done
147 done
149 # Install/ remove html documentation (if html documentation tree is here)
151 if [ -d $SRCDIR../docs/htmldocs/ ]; then
153 for dir in htmldocs/manpages htmldocs/Samba3-ByExample htmldocs/Samba3-Developers-Guide htmldocs/Samba3-HOWTO
156 if [ ! -d $SRCDIR../docs/$dir ]; then
157 continue
160 INSTALLDIR="$DESTDIR/$SWATDIR/help/`echo $dir | sed 's/htmldocs\///g'`"
161 if test ! -d "$INSTALLDIR" -a "$mode" = 'install'; then
162 mkdir "$INSTALLDIR"
163 if test ! -d "$INSTALLDIR"; then
164 echo "Failed to make directory $INSTALLDIR, does $USER have privileges? "
165 exit 1
169 for f in $SRCDIR../docs/$dir/*.html; do
170 FNAME=$INSTALLDIR/`basename $f`
171 echo $FNAME
172 if test "$mode" = 'install'; then
173 cp "$f" "$FNAME"
174 if test ! -f "$FNAME"; then
175 echo "Cannot install $FNAME. Does $USER have privileges? "
176 exit 1
178 chmod 0644 $FNAME
179 elif test "$mode" = 'uninstall'; then
180 rm -f "$FNAME"
181 if test -f "$FNAME"; then
182 echo "Cannot remove $FNAME. Does $USER have privileges? "
183 exit 1
186 done
188 if test -d "$SRCDIR../docs/$dir/images/"; then
189 if test ! -d "$INSTALLDIR/images/" -a "$mode" = 'install'; then
190 mkdir "$INSTALLDIR/images"
191 if test ! -d "$INSTALLDIR/images/"; then
192 echo "Failed to make directory $INSTALLDIR/images, does $USER have privileges? "
193 exit 1
196 for f in $SRCDIR../docs/$dir/images/*.png; do
197 FNAME=$INSTALLDIR/images/`basename $f`
198 echo $FNAME
199 if test "$mode" = 'install'; then
200 cp "$f" "$FNAME"
201 if test ! -f "$FNAME"; then
202 echo "Cannot install $FNAME. Does $USER have privileges? "
203 exit 1
205 chmod 0644 $FNAME
206 elif test "$mode" = 'uninstall'; then
207 rm -f "$FNAME"
208 if test -f "$FNAME"; then
209 echo "Cannot remove $FNAME. Does $USER have privileges? "
210 exit 1
213 done
215 done
218 # Install/ remove Using Samba book (but only if it is there)
220 if [ "x$BOOKDIR" != "x" -a -f $SRCDIR../docs/htmldocs/using_samba/toc.html ]; then
222 # Create directories
224 for d in $BOOKDIR $BOOKDIR/figs ; do
225 if test ! -d "$d" -a "$mode" = 'install'; then
226 mkdir $d
227 if test ! -d "$d"; then
228 echo "Failed to make directory $d, does $USER have privileges? "
229 exit 1
232 done
234 # HTML files
236 for f in $SRCDIR../docs/htmldocs/using_samba/*.html; do
237 FNAME=$BOOKDIR/`basename $f`
238 echo $FNAME
239 if test "$mode" = 'install'; then
240 cp "$f" "$FNAME"
241 if test ! -f "$FNAME"; then
242 echo "Cannot install $FNAME. Does $USER have privileges? "
243 exit 1
245 chmod 0644 $FNAME
246 elif test "$mode" = 'uninstall'; then
247 rm -f "$FNAME"
248 if test -f "$FNAME"; then
249 echo "Cannot remove $FNAME. Does $USER have privileges? "
250 exit 1
253 done
255 for f in $SRCDIR../docs/htmldocs/using_samba/*.gif; do
256 FNAME=$BOOKDIR/`basename $f`
257 echo $FNAME
258 if test "$mode" = 'install'; then
259 cp "$f" "$FNAME"
260 if test ! -f "$FNAME"; then
261 echo "Cannot install $FNAME. Does $USER have privileges? "
262 exit 1
264 chmod 0644 $FNAME
265 elif test "$mode" = 'uninstall'; then
266 rm -f "$FNAME"
267 if test -f "$FNAME"; then
268 echo "Cannot remove $FNAME. Does $USER have privileges? "
269 exit 1
272 done
274 # Figures
276 for f in $SRCDIR../docs/htmldocs/using_samba/figs/*.gif; do
277 FNAME=$BOOKDIR/figs/`basename $f`
278 echo $FNAME
279 if test "$mode" = 'install'; then
280 cp "$f" "$FNAME"
281 if test ! -f "$FNAME"; then
282 echo "Cannot install $FNAME. Does $USER have privileges? "
283 exit 1
285 chmod 0644 $FNAME
286 elif test "$mode" = 'uninstall'; then
287 rm -f "$FNAME"
288 if test -f "$FNAME"; then
289 echo "Cannot remove $FNAME. Does $USER have privileges? "
290 exit 1
293 done
297 if test "$mode" = 'install'; then
298 cat << EOF
299 ======================================================================
300 The SWAT files have been installed. Remember to read the documentation
301 for information on enabling and using SWAT
302 ======================================================================
304 else
305 cat << EOF
306 ======================================================================
307 The SWAT files have been removed. You may restore these files using
308 the command "make installswat" or "make install" to install binaries,
309 man pages, modules, SWAT, and shell scripts.
310 ======================================================================
314 exit 0