#! /bin/sh
COMNAME=smbfnconv
COMNAME2=capecho
COMNAME3=hexecho
COMNAME4=smbutfconv
ORIGDIR=.
DEF_INSTDIR=/usr/local/samba/bin/

echo -n "Where do you want to install? [$DEF_INSTDIR]"
read INSTDIR
if [ -z "$INSTDIR" ]; then
 INSTDIR=$DEF_INSTDIR   
fi

echo -n "Now start install smbcharconv tool to ${INSTDIR} sure? (y/[n])"
read YESNO
if [ "$YESNO" = "y" ]; then

  # now start install

	echo  "Install ${COMNAME} ..."
        cp  ${COMNAME} ${INSTDIR}
	chmod 755  ${INSTDIR}/${COMNAME}
	chown root ${INSTDIR}/${COMNAME}
	chgrp root ${INSTDIR}/${COMNAME}

	echo  "Install ${COMNAME2} ..."
        cp  ${COMNAME2} ${INSTDIR}
	chmod 755  ${INSTDIR}/${COMNAME2}
	chown root ${INSTDIR}/${COMNAME2}
	chgrp root ${INSTDIR}/${COMNAME2}

	echo  "Install ${COMNAME3} ..."
        cp  ${COMNAME3} ${INSTDIR}
	chmod 755  ${INSTDIR}/${COMNAME3}
	chown root ${INSTDIR}/${COMNAME3}
	chgrp root ${INSTDIR}/${COMNAME3}

	echo  "Install ${COMNAME4} ..."
        cp  ${COMNAME4} ${INSTDIR}
	chmod 755  ${INSTDIR}/${COMNAME4}
	chown root ${INSTDIR}/${COMNAME4}
	chgrp root ${INSTDIR}/${COMNAME4}

    echo -n "Do you wanto to make symlink like 'euctohex'? (y/[n])"
    read YESNO
    if [ "$YESNO" = "y" ]; then

       # make symlinks

       cd ${INSTDIR}
       for i in euc jis sjis hex cap ; do
 	 for j in euc jis sjis hex cap ; do
	    if [ -f ${i}to${j} ]; then
		break
	    fi
	    echo link ${i}to${j} to ${COMNAME}
	    ln -s ${COMNAME} ${i}to${j}
          done
       done
    fi 
else
    echo Break install action. BYE.
fi

