r13316: Let the carnage begin....
[kai/samba.git] / source / script / installswat.sh
1 #!/bin/sh
2 #first version March 1998, Andrew Tridgell
3
4 SWATDIR=`echo $1 | sed 's/\/\//\//g'`
5 SRCDIR=$2/
6 BOOKDIR=$SWATDIR/using_samba
7
8 echo Installing SWAT in $SWATDIR
9 echo Installing the Samba Web Administration Tool
10
11 LANGS=". `cd $SRCDIR../swat/; /bin/echo lang/??`"
12 echo Installing langs are `cd $SRCDIR../swat/lang/; /bin/echo ??`
13
14 for ln in $LANGS; do 
15  SWATLANGDIR=$SWATDIR/$ln
16  for d in $SWATLANGDIR $SWATLANGDIR/help $SWATLANGDIR/images \
17         $SWATLANGDIR/include $SWATLANGDIR/js; do
18     if [ ! -d $d ]; then
19         mkdir -p $d
20         if [ ! -d $d ]; then
21             echo Failed to make directory $d, does $USER have privileges?
22             exit 1
23         fi
24     fi
25  done
26 done
27
28 # Install images
29 for ln in $LANGS; do
30
31   for f in $SRCDIR../swat/$ln/images/*.png; do
32       if [ ! -f $f ] ; then
33         continue
34       fi
35       FNAME=$SWATDIR/$ln/images/`basename $f`
36       echo $FNAME
37       cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
38       chmod 0644 $FNAME
39   done
40
41   # Install html help
42
43   for f in $SRCDIR../swat/$ln/help/*.html; do
44       if [ ! -f $f ] ; then
45         continue
46       fi
47       FNAME=$SWATDIR/$ln/help/`basename $f`
48       echo $FNAME
49       if [ "x$BOOKDIR" = "x" ]; then
50         cat $f | sed 's/@BOOKDIR@.*$//' > $f.tmp
51       else
52         cat $f | sed 's/@BOOKDIR@//' > $f.tmp
53       fi
54       f=$f.tmp
55       cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
56       rm -f $f
57       chmod 0644 $FNAME
58   done
59
60   # Install "server-side" includes
61
62   for f in $SRCDIR../swat/$ln/include/*; do
63       if [ ! -f $f ] ; then
64         continue
65       fi
66       FNAME=$SWATDIR/$ln/include/`basename $f`
67       echo $FNAME
68       cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
69       chmod 0644 $FNAME
70   done
71
72   # Install javascripts
73
74   for f in $SRCDIR../swat/$ln/js/*.js; do
75       if [ ! -f $f ] ; then
76         continue
77       fi
78       FNAME=$SWATDIR/$ln/js/`basename $f`
79       echo $FNAME
80       cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
81       chmod 0644 $FNAME
82   done
83
84 done
85
86 # Install html documentation (if html documentation tree is here)
87
88 if [ -d $SRCDIR../docs/htmldocs/ ]; then
89
90     for dir in htmldocs/manpages htmldocs/Samba3-ByExample  htmldocs/Samba3-Developers-Guide  htmldocs/Samba3-HOWTO
91     do 
92     
93       if [ ! -d $SRCDIR../docs/$dir ]; then
94         continue
95       fi
96       
97       INSTALLDIR=$SWATDIR/help/`echo $dir | sed 's/htmldocs\///g'`
98       if [ ! -d $INSTALLDIR ]; then
99         mkdir $INSTALLDIR
100       fi
101
102       for f in $SRCDIR../docs/$dir/*.html; do
103           FNAME=$INSTALLDIR/`basename $f`
104           echo $FNAME
105           cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
106           chmod 0644 $FNAME
107       done
108
109       if [ -d $SRCDIR../docs/$dir/images/ ]; then
110           if [ ! -d $INSTALLDIR/images/ ]; then
111               mkdir $INSTALLDIR/images
112               if [ ! -d $INSTALLDIR/images/ ]; then
113                   echo Failed to make directory $SWATDIR/help/images, does $USER have privileges?
114                   exit 1
115               fi
116           fi
117           for f in $SRCDIR../docs/$dir/images/*.png; do
118               FNAME=$INSTALLDIR/images/`basename $f`
119               echo $FNAME
120               cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
121               chmod 0644 $FNAME
122           done
123       fi
124     done
125 fi
126
127 # Install Using Samba book (but only if it is there)
128
129 if [ "x$BOOKDIR" != "x" -a -f $SRCDIR../docs/htmldocs/using_samba/toc.html ]; then
130
131     # Create directories
132
133     for d in $BOOKDIR $BOOKDIR/figs ; do
134         if [ ! -d $d ]; then
135             mkdir $d
136             if [ ! -d $d ]; then
137                 echo Failed to make directory $d, does $USER have privileges?
138                 exit 1
139             fi
140         fi
141     done
142
143     # HTML files
144
145     for f in $SRCDIR../docs/htmldocs/using_samba/*.html; do
146         FNAME=$BOOKDIR/`basename $f`
147         echo $FNAME
148         cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
149         chmod 0644 $FNAME
150     done
151
152     for f in $SRCDIR../docs/htmldocs/using_samba/*.gif; do
153         FNAME=$BOOKDIR/`basename $f`
154         echo $FNAME
155         cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
156         chmod 0644 $FNAME
157     done
158
159     # Figures
160
161     for f in $SRCDIR../docs/htmldocs/using_samba/figs/*.gif; do
162         FNAME=$BOOKDIR/figs/`basename $f`
163         echo $FNAME
164         cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
165         chmod 0644 $FNAME
166     done
167
168 fi
169
170 cat << EOF
171 ======================================================================
172 The SWAT files have been installed. Remember to read the documentation
173 for information on enabling and using SWAT
174 ======================================================================
175 EOF
176
177 exit 0
178