r15890: Use correct enum type (bug #3722) from Jason Mader <jason@ncac.gwu.edu>.
[ira/wip.git] / source3 / script / installswat.sh
1 #!/bin/sh
2 #first version March 1998, Andrew Tridgell
3
4 DESTDIR=$1
5 SWATDIR=`echo $2 | sed 's/\/\//\//g'`
6 SRCDIR=$3/
7 BOOKDIR="$DESTDIR/$SWATDIR/using_samba"
8
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'
15                 ;;
16         *)
17                 echo "Installing SWAT in $DESTDIR/$SWATDIR "
18                 echo "Installing the Samba Web Administration Tool "
19                 echo -n "Installing "
20                 mode='install'
21                 ;;
22 esac
23
24 LANGS=". `cd $SRCDIR../swat/; /bin/echo lang/??`"
25 echo "langs are `cd $SRCDIR../swat/lang/; /bin/echo ??` "
26
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
37     fi
38    fi
39   done
40  done
41 fi
42
43 for ln in $LANGS; do
44
45   # images
46   for f in $SRCDIR../swat/$ln/images/*.gif; do
47     if [ ! -f $f ] ; then
48       continue
49     fi
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
57       fi
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
64       fi
65     else
66       echo "Unknown mode, $mode.  Script called as $0 "
67       exit 1
68     fi
69   done
70
71   # html help
72   for f in $SRCDIR../swat/$ln/help/*.html; do
73     if [ ! -f $f ] ; then
74       continue
75     fi
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
83       fi
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
90       fi
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
97       fi
98     fi
99   done
100
101   # "server-side" includes
102   for f in $SRCDIR../swat/$ln/include/*; do
103       if [ ! -f $f ] ; then
104         continue
105       fi
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
113         fi
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
120         fi
121       fi
122   done
123
124 done
125
126 # Install/ remove html documentation (if html documentation tree is here)
127
128 if [ -d $SRCDIR../docs/htmldocs/ ]; then
129
130     for dir in htmldocs/manpages htmldocs/Samba3-ByExample  htmldocs/Samba3-Developers-Guide  htmldocs/Samba3-HOWTO
131     do 
132     
133       if [ ! -d $SRCDIR../docs/$dir ]; then
134         continue
135       fi
136       
137       INSTALLDIR="$DESTDIR/$SWATDIR/help/`echo $dir | sed 's/htmldocs\///g'`"
138       if test ! -d "$INSTALLDIR" -a "$mode" = 'install'; then
139         mkdir "$INSTALLDIR"
140         if test ! -d "$INSTALLDIR"; then
141           echo "Failed to make directory $INSTALLDIR, does $USER have privileges? "
142           exit 1
143         fi
144       fi
145
146       for f in $SRCDIR../docs/$dir/*.html; do
147           FNAME=$INSTALLDIR/`basename $f`
148           echo $FNAME
149           if test "$mode" = 'install'; then
150             cp "$f" "$FNAME"
151             if test ! -f "$FNAME"; then
152               echo "Cannot install $FNAME. Does $USER have privileges? "
153               exit 1
154             fi
155             chmod 0644 $FNAME
156           elif test "$mode" = 'uninstall'; then
157             rm -f "$FNAME"
158             if test -f "$FNAME"; then
159               echo "Cannot remove $FNAME.  Does $USER have privileges? "
160               exit 1
161             fi
162           fi
163       done
164
165       if test -d "$SRCDIR../docs/$dir/images/"; then
166           if test ! -d "$INSTALLDIR/images/" -a "$mode" = 'install'; then
167               mkdir "$INSTALLDIR/images"
168               if test ! -d "$INSTALLDIR/images/"; then
169                   echo "Failed to make directory $INSTALLDIR/images, does $USER have privileges? "
170                   exit 1
171               fi
172           fi
173           for f in $SRCDIR../docs/$dir/images/*.png; do
174               FNAME=$INSTALLDIR/images/`basename $f`
175               echo $FNAME
176               if test "$mode" = 'install'; then
177                 cp "$f" "$FNAME"
178                 if test ! -f "$FNAME"; then
179                   echo "Cannot install $FNAME. Does $USER have privileges? "
180                   exit 1
181                 fi
182                 chmod 0644 $FNAME
183               elif test "$mode" = 'uninstall'; then
184                 rm -f "$FNAME"
185                 if test -f "$FNAME"; then
186                   echo "Cannot remove $FNAME.  Does $USER have privileges? "
187                   exit 1
188                 fi
189               fi
190           done
191       fi
192     done
193 fi
194
195 # Install/ remove Using Samba book (but only if it is there)
196
197 if [ "x$BOOKDIR" != "x" -a -f $SRCDIR../docs/htmldocs/using_samba/toc.html ]; then
198
199     # Create directories
200
201     for d in $BOOKDIR $BOOKDIR/figs ; do
202         if test ! -d "$d" -a "$mode" = 'install'; then
203             mkdir $d
204             if test ! -d "$d"; then
205                 echo "Failed to make directory $d, does $USER have privileges? "
206                 exit 1
207             fi
208         fi
209     done
210
211     # HTML files
212
213     for f in $SRCDIR../docs/htmldocs/using_samba/*.html; do
214         FNAME=$BOOKDIR/`basename $f`
215         echo $FNAME
216         if test "$mode" = 'install'; then
217           cp "$f" "$FNAME"
218           if test ! -f "$FNAME"; then
219             echo "Cannot install $FNAME. Does $USER have privileges? "
220             exit 1
221           fi
222           chmod 0644 $FNAME
223         elif test "$mode" = 'uninstall'; then
224           rm -f "$FNAME"
225           if test -f "$FNAME"; then
226             echo "Cannot remove $FNAME.  Does $USER have privileges? "
227             exit 1
228           fi
229         fi
230     done
231
232     for f in $SRCDIR../docs/htmldocs/using_samba/*.gif; do
233         FNAME=$BOOKDIR/`basename $f`
234         echo $FNAME
235         if test "$mode" = 'install'; then
236           cp "$f" "$FNAME"
237           if test ! -f "$FNAME"; then
238             echo "Cannot install $FNAME. Does $USER have privileges? "
239             exit 1
240           fi
241           chmod 0644 $FNAME
242         elif test "$mode" = 'uninstall'; then
243           rm -f "$FNAME"
244           if test -f "$FNAME"; then
245             echo "Cannot remove $FNAME.  Does $USER have privileges? "
246             exit 1
247           fi
248         fi
249     done
250
251     # Figures
252
253     for f in $SRCDIR../docs/htmldocs/using_samba/figs/*.gif; do
254         FNAME=$BOOKDIR/figs/`basename $f`
255         echo $FNAME
256         if test "$mode" = 'install'; then
257           cp "$f" "$FNAME"
258           if test ! -f "$FNAME"; then
259             echo "Cannot install $FNAME. Does $USER have privileges? "
260             exit 1
261           fi
262           chmod 0644 $FNAME
263         elif test "$mode" = 'uninstall'; then
264           rm -f "$FNAME"
265           if test -f "$FNAME"; then
266             echo "Cannot remove $FNAME.  Does $USER have privileges? "
267             exit 1
268           fi
269         fi
270     done
271
272 fi
273
274 if test "$mode" = 'install'; then
275   cat << EOF
276 ======================================================================
277 The SWAT files have been installed. Remember to read the documentation
278 for information on enabling and using SWAT
279 ======================================================================
280 EOF
281 else
282   cat << EOF
283 ======================================================================
284 The SWAT files have been removed.  You may restore these files using
285 the command "make installswat" or "make install" to install binaries, 
286 man pages, modules, SWAT, and shell scripts.
287 ======================================================================
288 EOF
289 fi
290
291 exit 0
292