1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
#!/bin/sh
#
# installations script
#
# global variables
SuSEbinpath=/usr/bin
localbinpath=/usr/local/bin
SourceDirectory=
DestDirectory=/usr/local/bin
HylafaxSpoolDir=/var/spool/hylafax
StandAloneInst=0
Update=0
Uninstall=0
CopyFiles=1
ImpConf=1
ChangeDevCapi=0
ConfigFileName=config.faxCAPI
#functions
function SearchForLib {
if [ -e /lib/$1 ] || [ -e /usr/lib/$1 ] || [ -e /usr/local/lib/$1 ] ; then
return 0
fi
echo "Can't find library $1!"
return 1
}
function TestAndCopyFile {
sourcefile=$2
if [ -n "$5" ] && [ -e $5/$sourcefile ] ; then
sourcefile=$5/$sourcefile
elif [ -e $sourcefile ] ; then
:
elif [ -e src/$3/$sourcefile ] ; then
sourcefile=src/$3/$sourcefile
elif [ -e bin/$sourcefile ] ; then
sourcefile=bin/$sourcefile
elif [ -e $localbinpath/$sourcefile ] ; then
sourcefile=$localbinpath/$sourcefile
elif [ -e $SuSEbinpath/$sourcefile ] ; then
sourcefile=$SuSEbinpath/$sourcefile
else
echo "Can't find $2."
if [ $1 -ep 1 ] ; then
exit 1
fi
fi
if [ ! -d $4 ] ; then
mkdir -p $4
if [ $? -gt 0 ] ; then
if [ $1 -eq 1 ] ; then
exit 1
else
return $?
fi
fi
fi
echo "Copying $sourcefile to $4/$2."
cp -f $sourcefile $4/$2
if [ $? -gt 0 ] && [ $1 -eq 1 ] ; then
exit 1
fi
}
function SetConfigLine {
if [ -z "$3" ] ; then
grep -v "$2.*:.*/c2fax" $1 > $1.new
else
gawk 'BEGIN {repl = 0} END {if (repl == 0) {print SEARCHIT":"REPLACEIT}}
{if ($1 != SEARCHIT) {print $0} else {repl = 1; print $1":"REPLACEIT}}
' FS=':' IGNORECASE=1 SEARCHIT="$2" REPLACEIT="$3" $1 > $1.new
fi
if [ "$4" != "no" ] ; then
mv $1 $1.c2fax
fi
mv $1.new $1
}
# test command line
while [ $# -gt 0 ] ; do
case $1
in
-s)
StandAloneInst=1
ImpConf=0
;;
-p)
if [ -n "$2" ] ; then
HylafaxSpoolDir=$2
shift
fi
;;
-b)
if [ -n "$2" ] ; then
SourceDirectory=$2
shift
fi
;;
-d)
if [ -n "$2" ] ; then
DestDirectory=$2
shift
fi
;;
-c)
if [ -e /dev/capi20 ] ; then
chmod 0666 /dev/capi20
if [ $? -eq 0 ] ; then
ChangeDevCapi=1
fi
else
echo "Can't find /dev/capi20."
exit 1
fi
;;
-U)
Update=1
;;
-u)
Uninstall=1
;;
-n)
CopyFiles=0
;;
*)
echo "usage: `basename $0` [-n] [-s] [-c] [-u] [-p PATH] [-b PATH] [-d PATH]"
echo -e "\t-n\tNot copying files only changing configs and inittab"
echo -e "\t-s\tInstall stand alone, without checking for Hylafax"
echo -e "\t-c\tChange mode of /dev/capi20 to 0666 during installation"
echo -e "\t-U\tUpdate. Copy Files but don't change the config files"
echo -e "\t-u\tUninstall. Remove files and changed lines from the config files"
echo -e "\t-p\tSpecify path to Hylafax spool directory (default: /var/spool/fax)"
echo -e "\t-b\tSpecify source path for the fax binaries"
echo -e "\t-d\tSpecify destination path for the fax binaries"
exit 1
;;
esac
shift
done
# Uninstallation
if [ $Uninstall -gt 0 ] ; then
if [ $CopyFiles -gt 0 ] ; then
rm $DestDirectory/c2faxsend
rm $DestDirectory/c2faxrecv
fi
rm $HylafaxSpoolDir/etc/$ConfigFileName
if [ $StandAloneInst -eq 0 ] && [ -e $HylafaxSpoolDir/etc/config ] ; then
SetConfigLine $HylafaxSpoolDir/etc/config SendFaxCmd
SetConfigLine /etc/inittab fr
fi
exit 0
fi
# search for c2faxsend
c2faxsendfile=c2faxsend
if [ -n "$SourceDirectory" ] && [ -e $SourceDirectory/$c2faxsendfile ] ; then
c2faxsendfile=$SourceDirectory/$c2faxsendfile
elif [ -e $c2faxsendfile ] ; then
:
elif [ -e src/faxsend/$c2faxsendfile ] ; then
c2faxsendfile=src/faxsend/$c2faxsendfile
elif [ -e bin/$c2faxsendfile ] ; then
c2faxsendfile=bin/$c2faxsendfile
elif [ -e $localbinpath/$c2faxsendfile ] ; then
c2faxsendfile=$localbinpath/$c2faxsendfile
elif [ -e $SuSEbinpath/$c2faxsendfile ] ; then
c2faxsendfile=$SuSEbinpath/$c2faxsendfile
else
echo "Can't find $c2faxsendfile."
exit 1
fi
# test the existing of the needed librarys
foundError=0
libsnotfound=`ldd $c2faxsendfile | grep "not found" | cut -f2 | cut -d " " -f1`
if [ -n "$libsnotfound" ] ; then
for name in $libsnotfound
do
echo "Can't find library $name!"
done
foundError=1
fi
# search for hylafax config file
if [ $StandAloneInst -eq 0 ] && [ ! -e $HylafaxSpoolDir/etc/config ] ; then
if [ -e /var/spool/hylafax/etc/config ] ; then
HylafaxSpoolDir=/var/spool/hylafax
elif [ -e /var/spool/fax/etc/config ] ; then
HylafaxSpoolDir=/var/spool/fax
else
echo ""
echo "Can't find Hylafax's config file: $HylafaxSpoolDir/etc/config."
echo "Please adjust the Hylafax spool directory with -p [dir]"
echo "or install CAPI4Hylafax stand alone with -s."
foundError=1
fi
fi
if [ $foundError -gt 0 ] ; then
exit 2
fi
# copy files
if [ $CopyFiles -gt 0 ] ; then
TestAndCopyFile 1 c2faxrecv faxrecv "$DestDirectory" "$SourceDirectory"
TestAndCopyFile 1 c2faxsend faxsend "$DestDirectory" "$SourceDirectory"
if [ $Update -eq 0 ] ; then
if [ -e "/etc/$ConfigFileName" ] ; then
echo "Backup /etc/$ConfigFileName to /etc/$ConfigFileName.c2fax"
cp "/etc/$ConfigFileName" "/etc/$ConfigFileName.c2fax"
fi
TestAndCopyFile $ImpConf $ConfigFileName scripts "/etc" "$SourceDirectory"
if [ $? -gt 0 ] ; then
echo "Can't copy config file to /etc. This file isn't mandatory if you are working stand alone."
else
ConfigFileName="/etc/$ConfigFileName"
SetConfigLine "$ConfigFileName" SpoolDir "\t\t$HylafaxSpoolDir" no
SetConfigLine "$ConfigFileName" FaxRcvdCmd "\t\t$HylafaxSpoolDir/bin/faxrcvd" no
fi
else
TestAndCopyFile $ImpConf "${ConfigFileName}.update" scripts "/etc" "$SourceDirectory"
fi
else
ConfigFileName="/etc/$ConfigFileName"
if [ -e "$ConfigFileName" ] ; then
SetConfigLine "$ConfigFileName" SpoolDir "\t\t$HylafaxSpoolDir" no
SetConfigLine "$ConfigFileName" FaxRcvdCmd "\t\t$HylafaxSpoolDir/bin/faxrcvd" no
else
echo "Can't find config file \"$ConfigFileName\"! => Nothing to do."
exit 1
fi
fi
# adjust hylafax config file and inittab
if [ $StandAloneInst -eq 0 -a $Update -eq 0 ] ; then
echo "Change $HylafaxSpoolDir/etc/config and /etc/inittab."
SetConfigLine $HylafaxSpoolDir/etc/config SendFaxCmd "\t\t$DestDirectory/c2faxsend"
SetConfigLine /etc/inittab fr "2345:once:$DestDirectory/c2faxrecv -q \"$HylafaxSpoolDir\""
# patch faxrcvd
if [ -e "$HylafaxSpoolDir/bin/faxrcvd" ] ; then
cp "$HylafaxSpoolDir/bin/faxrcvd" "$HylafaxSpoolDir/bin/faxrcvd.c2fax"
sed "/\[ *\$# *!= *[1-9] *\]/s/!=/-lt/" "$HylafaxSpoolDir/bin/faxrcvd.c2fax" > "$HylafaxSpoolDir/bin/faxrcvd"
echo -e "\nfaxrcvd patched for the use of newer C4H or HylaFAX versions."
echo "!- NOTE -!: Please take a look in your faxrcvd script if it handles"
echo " the MSN (destination) as Parameter \"\$7\" correctly!"
fi
# change names of old Hylafax C4H config files
for i in ${HylafaxSpoolDir}/etc/config.faxCAPI* ; do
mv "$i" "$HylafaxSpoolDir/etc/old_`basename \"$i\"`"
done
fi
# start dialog script to configure config.faxCAPI
. ./setupconffile "$HylafaxSpoolDir"
main_config_dialog "$ConfigFileName"
# that was it
echo -e "\nInstall was successfully!\n\n"
echo -e "!! Attention !! - The path of the config file has changed to /etc/config.faxCAPI !!\n\n"
if [ -n "`file \`which file\` | grep 64-bit`" -a -f "${DestDirectory}/c2faxrecv" -a \
-n "`file \"${DestDirectory}/c2faxrecv\" | grep 32-bit`" ] ; then
echo "The installed CAPI4Hylafax binaries are 32bit."
echo -e "For 64bit binaries you have to compile the C4H sources.\n"
fi
if [ $StandAloneInst -eq 0 ] ; then
echo "The Fax Receive Daemon c2faxrecv was added to /etc/inittab and will be started"
echo -e "automatically. You could start it manually now to provide a restart.\n"
fi
if [ $ChangeDevCapi -eq 0 ] ; then
echo "Don't forget to change mode of /dev/capi20 so that the binaries which are"
echo -e "normally running from user \"fax\" have access rights to it.\n"
fi
echo ""
exit 0
|