]> mj.ucw.cz Git - libucw.git/blob - build/installer
Updated the installation script to always check for missing directories.
[libucw.git] / build / installer
1 #!/bin/sh
2 set -e
3 DEST=`eval echo $1`
4 shift
5 echo "Installing to $DEST"
6 for d in $DEST/{,cf,db,index,log,tmp} ; do
7         if [ ! -d $d ] ; then
8                 echo "Creating $d"
9                 mkdir $d
10         fi
11 done
12 echo "Installing binaries..."
13 rm -rf $DEST/{bin,lib}
14 mkdir -p $DEST/{bin,lib}
15 cp -aL run/bin/* $DEST/bin/
16 cp -aL run/lib/* $DEST/lib/
17 echo "Installing config files..."
18 for a in "$@" ; do
19         if [ -f run/cf/$a ] ; then
20                 if [ ! -f $DEST/cf/$a ] ; then
21                         echo "cf/$a: new, installed"
22                         cp run/cf/$a $DEST/cf/$a
23                 elif [ $a == catalog-rules ] ; then
24                         echo "cf/$a: will be regenerated automatically"
25                 elif diff -u $DEST/cf/$a run/cf/$a ; then
26                         echo "cf/$a: no differences"
27                 else
28                         echo -n "cf/$a differs, replace it [Yn]? "
29                         read x
30                         if [ -z "$x" -o "$x" == "y" -o "$x" == "Y" ] ; then
31                                 echo "cf/$a: replacing and keeping the old version as cf/$a.old"
32                                 mv $DEST/cf/$a $DEST/cf/$a.old
33                                 cp run/cf/$a $DEST/cf/$a
34                         else
35                                 echo "cf/$a: installing the new version as cf/$a.dist"
36                                 cp run/cf/$a $DEST/cf/$a.dist
37                         fi
38                 fi
39         fi
40 done
41 echo "Done."