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
|
#!/bin/sh
#
# installations script
#
# global variables
SuSEbinpath=bin
SourceDirectory=
DestDirectory=/usr/local/bin
HylafaxSpoolDir=/var/spool/hylafax
StandAloneInst=0
Uninstall=0
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 $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)
Uninstall=1
;;
*)
echo "usage: `basename $0` [-s] [-c] [-u] [-p PATH] [-b PATH] [-d PATH]"
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\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 binarys"
echo -e "\t-d\tSpecify destination path for the fax binarys"
exit 1
;;
esac
shift
done
# Uninstallation
if [ $Uninstall -gt 0 ] ; then
rm $DestDirectory/c2faxsend
rm $DestDirectory/c2faxrecv
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 $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
TestAndCopyFile 1 c2faxrecv faxrecv "$DestDirectory" "$SourceDirectory"
TestAndCopyFile 1 c2faxsend faxsend "$DestDirectory" "$SourceDirectory"
if [ -e "$HylafaxSpoolDir/etc/$ConfigFileName" ] ; then
echo "Backup $HylafaxSpoolDir/etc/$ConfigFileName to $HylafaxSpoolDir/etc/$ConfigFileName.c2fax"
cp "$HylafaxSpoolDir/etc/$ConfigFileName" "$HylafaxSpoolDir/etc/$ConfigFileName.c2fax"
fi
TestAndCopyFile $ImpConf $ConfigFileName scripts "$HylafaxSpoolDir/etc" "$SourceDirectory"
if [ $? -gt 0 ] ; then
echo "Can't copy config file. This file isn't mandatory if you are working stand alone."
else
ConfigFileName="$HylafaxSpoolDir/etc/$ConfigFileName"
SetConfigLine "$ConfigFileName" SpoolDir "\t\t$HylafaxSpoolDir" no
SetConfigLine "$ConfigFileName" FaxRcvdCmd "\t\t$HylafaxSpoolDir/bin/faxrcvd" no
fi
# adjust hylafax config file and inittab
if [ $StandAloneInst -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
fi
# start dialog script to configure config.faxCAPI
. src/scripts/setupconffile $HylafaxSpoolDir
main_config_dialog "$ConfigFileName"
# that was it
echo -e "\nInstall was successfully!\n"
if [ $StandAloneInst -eq 0 ] ; then
echo "The Fax Receive Daemon c2faxrecv was added to /etc/inittab and will be started"
echo "automatically. You could start it manually now to provide a restart."
fi
if [ $ChangeDevCapi -eq 0 ] ; then
echo -e "\nDon't forget to change mode of /dev/capi20 so that the binaries which are"
echo "normally running from user UUCP have access rights to it."
fi
echo ""
exit 0
|