Initial import
[samba] / 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/help/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; 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/*.gif; 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/*.html; 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 done
73
74 # Install html documentation (if html documentation tree is here)
75
76 if [ -d $SRCDIR../docs/htmldocs/ ]; then
77
78     for dir in htmldocs/manpages htmldocs/Samba3-ByExample  htmldocs/Samba3-Developers-Guide  htmldocs/Samba3-HOWTO
79     do 
80     
81       if [ ! -d $SRCDIR../docs/$dir ]; then
82         continue
83       fi
84       
85       INSTALLDIR=$SWATDIR/help/`echo $dir | sed 's/htmldocs\///g'`
86       if [ ! -d $INSTALLDIR ]; then
87         mkdir $INSTALLDIR
88       fi
89
90       for f in $SRCDIR../docs/$dir/*.html; do
91           FNAME=$INSTALLDIR/`basename $f`
92           echo $FNAME
93           cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
94           chmod 0644 $FNAME
95       done
96
97       if [ -d $SRCDIR../docs/$dir/images/ ]; then
98           if [ ! -d $INSTALLDIR/images/ ]; then
99               mkdir $INSTALLDIR/images
100               if [ ! -d $INSTALLDIR/images/ ]; then
101                   echo Failed to make directory $SWATDIR/help/images, does $USER have privileges?
102                   exit 1
103               fi
104           fi
105           for f in $SRCDIR../docs/$dir/images/*.png; do
106               FNAME=$INSTALLDIR/images/`basename $f`
107               echo $FNAME
108               cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
109               chmod 0644 $FNAME
110           done
111       fi
112     done
113 fi
114
115 # Install Using Samba book (but only if it is there)
116
117 if [ "x$BOOKDIR" != "x" -a -f $SRCDIR../docs/htmldocs/using_samba/toc.html ]; then
118
119     # Create directories
120
121     for d in $BOOKDIR $BOOKDIR/figs ; do
122         if [ ! -d $d ]; then
123             mkdir $d
124             if [ ! -d $d ]; then
125                 echo Failed to make directory $d, does $USER have privileges?
126                 exit 1
127             fi
128         fi
129     done
130
131     # HTML files
132
133     for f in $SRCDIR../docs/htmldocs/using_samba/*.html; do
134         FNAME=$BOOKDIR/`basename $f`
135         echo $FNAME
136         cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
137         chmod 0644 $FNAME
138     done
139
140     for f in $SRCDIR../docs/htmldocs/using_samba/*.gif; do
141         FNAME=$BOOKDIR/`basename $f`
142         echo $FNAME
143         cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
144         chmod 0644 $FNAME
145     done
146
147     # Figures
148
149     for f in $SRCDIR../docs/htmldocs/using_samba/figs/*.gif; do
150         FNAME=$BOOKDIR/figs/`basename $f`
151         echo $FNAME
152         cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
153         chmod 0644 $FNAME
154     done
155
156 fi
157
158 cat << EOF
159 ======================================================================
160 The SWAT files have been installed. Remember to read the documentation
161 for information on enabling and using SWAT
162 ======================================================================
163 EOF
164
165 exit 0
166