#!/bin/sh # # can take OS as first arg to overide /usr/bin/uname # current_version="3.5.01-slackware" kfree_required=65000 ##---------------------------------------------- ## Modify these parameters as needed: ## mod_casp sda 03-31-2000 ## CASP Installation Path (default="/var/httpd/casp") install_path="/var/httpd/casp" ## /var/opt path to put casp/chilisoft.ini file (default="/var/opt/casp") var_path="/var/opt/casp" ## Do you have the Apache RPM? (default=0) apache_rpm=0 ## Apache Web Server Path (default="/var/httpd") webserver_path="/var/httpd" ## Admin Port # (default=5100) admin_port=5100 ## .tar file to use (default="casp-slackware.tar") #tarfile=casp-slackware.tar.gz tarfile="casp-slackware.tar" ##----------------------------------------------- PATH=/usr/bin:/bin:/sbin # return value retval="" # # helper functions # function list_installs () { index=1 display_index=1 version_string="" for each in `grep '\[' $var_path/chili.ini 2>/dev/null`; do subindex=1 version_string="" for subeach in `grep '^version' $var_path/chili.ini 2>/dev/null`; do if [ "$index" = "$subindex" ]; then version_string=`echo $subeach|sed 's/version[ \t]*=[ \t]*\(.*\)/\1/'` fi subindex=$[$subindex+1] done name=`echo $each|sed 's/\[\([^]]*\)\]/\1/g'` if [ "x$1" = "x" ] || [ "$version_string" = "$1" ]; then echo " $display_index. $name (version $version_string)" display_index=$[$display_index+1] fi index=$[$index+1] done retval=$[$index-1] } function index2install () { index=1 installpath="" for each in `grep '\[' $var_path/chili.ini 2>/dev/null`; do if [ $1 = $index ]; then installpath=`echo $each|sed 's/\[\([^]]*\)\]/\1/g'` fi index=$[$index+1] done retval=$installpath } function install2index () { index=1 for each in `grep '\[' $var_path/chili.ini 2>/dev/null`; do installpath=`echo $each|sed 's/\[\([^]]*\)\]/\1/g'` if [ $1 = $installpath ]; then retval=$index return fi index=$[$index+1] done retval=0 } function index2version () { index=1 versionstring="" for each in `grep '^version' $var_path/chili.ini 2>/dev/null`; do if [ $1 = $index ]; then versionstring=`echo $each|sed 's/version[ \t]*=[ \t]*\(.*\)/\1/'` fi index=$[$index+1] done retval=$versionstring } function compareversion () { maj1=`echo $1|sed 's/\([0-9]\+\)\.[0-9]\+\.[0-9]\+/\1/'` min1=`echo $1|sed 's/[0-9]\+\.\([0-9]\)\+\.[0-9]\+/\1/'` rev1=`echo $1|sed 's/[0-9]\+\.[0-9]\+\.\([0-9]\)\+/\1/'` maj2=`echo $2|sed 's/\([0-9]\+\)\.[0-9]\+\.[0-9]\+/\1/'` min2=`echo $2|sed 's/[0-9]\+\.\([0-9]\)\+\.[0-9]\+/\1/'` rev2=`echo $2|sed 's/[0-9]\+\.[0-9]\+\.\([0-9]\)\+/\1/'` if [ $maj1 -eq $maj2 ]; then if [ $min1 -eq $min2 ]; then if [ $rev1 -eq $rev2 ]; then retval=0 return elif [ $rev1 -lt $rev2 ]; then retval=-1 return else retval=1 return fi elif [ $min1 -lt $min2 ]; then retval=-1 return else retval=1 return fi elif [ $maj1 -lt $maj2 ]; then retval=-1 return else retval=1 return fi retval=$rev2 } ############################################################################## ## MAIN PROGRAM ## # # make sure we have perl # perlbin="" if [ -x "/usr/bin/perl" ]; then perlbin="/usr/bin/perl" elif [ -x "/usr/local/bin/perl" ]; then perlbin="/usr/local/bin/perl" elif [ -x "/opt/perl/bin/perl" ]; then perlbin="/opt/perl/bin/perl" else perlbin=`which perl` fi if [ "x$perlbin" = "x" ]; then echo echo Setup could not find Perl on your machine. Perl must exist echo for setup to continue. echo echo Make sure the perl program is installed and is in your path. echo exit 1 fi # make sure we're root if [ -x /usr/bin/whoami ]; then user=`/usr/bin/whoami` if [ "$user" != "root" ]; then printf "ERROR must be root to install\n" exit fi fi # check what OS we're on if [ $# -gt 0 ]; then os=$1 else if [ -x /bin/uname ]; then os=`/bin/uname` else echo "Unable to determine operating system." exit fi fi ## Make sure that we have our file here. if [ ! -f $tarfile ]; then printf "ERROR tarfile $tarfile not found in current directory\n" exit fi # EULA if `tty > /dev/null` then /bin/more EULA else /bin/cat EULA fi printf "\nDo you agree to the terms? [yes/No] " read eula if [ ! "$eula" = "y" -a ! "$eula" = "yes" ]; then printf "\nCannot continue without agreeing to EULA\n" exit fi ## check if a beta is installed if grep '3.4.01' $var_path/chili.ini > /dev/null 2>&1; then clear printf "\n" printf " ------------------------------------------------------------ \n" printf "| CHILI!SOFT ASP BETA 1 (3.4.01) FOUND |\n" printf "|------------------------------------------------------------|\n" printf "| Setup cannot continue until all copies of the BETA 1 |\n" printf "| software is removed. Below is a list of all locations |\n" printf "| of BETA 1. You must completely remove the BETA 1 installs |\n" printf "| by completing ALL steps listed below. |\n" printf "| |\n" printf " ------------------------------------------------------------ \n" printf "\n" list_installs "3.4.01" printf "\n" printf "Press Enter to See BETA 1 Removal Steps " read dummy # now create BETA1_REMOVAL file echo "To remove a BETA 1 installation" > BETA1_REMOVAL echo >> BETA1_REMOVAL echo "1. STOP ALL RUNNING ASP SERVERS" >> BETA1_REMOVAL echo " From each server's directory, run ./caspctrl stopall" >> BETA1_REMOVAL echo >> BETA1_REMOVAL echo "2. DELETE INSTALL TREE" >> BETA1_REMOVAL echo " Type rm -rf [install path] to remove the install" >> BETA1_REMOVAL echo " directory and all of its sub directories." >> BETA1_REMOVAL echo >> BETA1_REMOVAL echo "3. CLEAN SERVICES FILE" >> BETA1_REMOVAL echo " Edit the /etc/services file. Remove any lines with" >> BETA1_REMOVAL echo " 'Chili!Soft' in the trailing comment line." >> BETA1_REMOVAL echo >> BETA1_REMOVAL echo "4. CLEAN LD.SO CACHE" >> BETA1_REMOVAL echo " Edit the /etc/ld.so.conf file. Remove the line that" >> BETA1_REMOVAL echo " matches the installation's lib directory." >> BETA1_REMOVAL echo " After you save the changes, run /sbin/ldconfig to" >> BETA1_REMOVAL echo " reset the cache." >> BETA1_REMOVAL echo >> BETA1_REMOVAL echo "5. CLEAN APACHE CONFIG FILE" >> BETA1_REMOVAL echo " Edit the apache server's httpd.conf file. Remove the 5 lines " >> BETA1_REMOVAL echo " immediately following, and including, the Chili!Soft comment line." >> BETA1_REMOVAL echo " Restart the web server for the change to take effect." >> BETA1_REMOVAL echo >> BETA1_REMOVAL echo "6. CLEAN CHILI DATABASE" >> BETA1_REMOVAL echo " Delete the $var_path/chili.ini file." >> BETA1_REMOVAL echo "" >> BETA1_REMOVAL echo "" >> BETA1_REMOVAL echo "Press q to quit..." >> BETA1_REMOVAL echo "" >> BETA1_REMOVAL /usr/bin/less ./BETA1_REMOVAL exit 1 fi clear printf "\n" printf " ------------------------------------------------------------ \n" printf "| WELCOME TO THE CHILI!SOFT ASP FOR SLACKWARE SETUP PROGRAM |\n" printf "|------------------------------------------------------------|\n" printf "| Setup will now install the files needed to run |\n" printf "| Chili!Soft ASP on your computer. Enter the path below |\n" printf "| where you would like setup to install its files. |\n" printf "| |\n" printf " ------------------------------------------------------------ \n" printf "\n" ## mod_casp sda 03-31-2000 #printf "Enter directory for Chili!Soft ASP install. [%s] \n: " "/opt/casp" printf "Enter directory for Chili!Soft ASP Slackware install. [%s] \n: " "$install_path" read asphome if [ "$asphome" = "" ]; then ## mod_casp sda 03-31-2000 #asphome="/opt/casp" ; asphome="$install_path" ; fi install2index $asphome index=$retval if [ $index -ne 0 ]; then index2version $index version=$retval ## we already have an install here echo echo WARNING: There is already an installation at that location. echo The version is $version. Setup will not install echo over a previous installation. echo echo -n "Would you like to uninstall the previous version (y/n)? [n] " read uninstall if [ ! "$uninstall" = "y" -a ! "$uninstall" = "yes" ]; then echo echo Setup cannot continue. echo Please run setup again and choose a different location. echo echo -n "Press Enter to Continue " read dummy exit else CURDIR=`pwd` cd $asphome ./uninstall if [ $? = 0 ]; then clear echo echo "Previous installation has been removed" echo "The current installation will now proceed" echo echo -n "Press Enter to Continue " read dummy else clear echo echo "Previous installation was NOT removed" echo "Setup cannot continue until previous installation is removed" echo exit fi cd $CURDIR fi fi startpath=`pwd` tarpath=${startpath}/${tarfile} /bin/mkdir -p $asphome /bin/mkdir -p $asphome/logs /bin/mkdir -p /etc/rc.d/init.d /bin/mkdir -p /etc/rc.d/rc0.d /bin/mkdir -p /etc/rc.d/rc1.d /bin/mkdir -p /etc/rc.d/rc2.d /bin/mkdir -p /etc/rc.d/rc3.d /bin/mkdir -p /etc/rc.d/rc4.d /bin/mkdir -p /etc/rc.d/rc5.d /bin/mkdir -p /etc/rc.d/rc6.d /bin/touch /etc/rc.d/init.d/functions # make relative path non-relative asphome=`echo $asphome|/bin/sed "s:^\([^/]\):${startpath}/\\1:"` case $os in AIX|aix ) kfree=`df -k $asphome|tail -1|awk '{print $3}'` ;; SunOS|sun*|SUN* ) kfree=`df -b $asphome|tail -1|awk '{print $2}'` ;; Linux|linux ) kfree=`df -k $asphome|tail -1|awk '{print $4}'` ;; * ) echo "$os is an unsupported operating system." exit ;; esac if [ $kfree -lt $kfree_required ]; then echo "ERROR not enough free space" echo "$kfree free, $kfree_required needed" exit fi cd $asphome if [ -f ./mainwin/mw/system/registry.bin ]; then echo Making backup copy of registry cp ./mainwin/mw/system/registry.bin ./mainwin/mw/system/registry.bin.old fi if [ -f ./odbc.ini ]; then echo Making backup copy of odbc.ini cp ./odbc.ini ./odbc.ini.old fi printf "\nExtracting files to $asphome... " ## mod_casp sda 03-31-2000 #gunzip -c $tarpath | tar -xvof - >> $asphome/logs/tar_log & tar -xvof $tarpath >> $asphome/logs/tar_log & SPINCOUNT=1 while kill -0 $! > /dev/null 2>&1 do case $SPINCOUNT in 1) SPINCHAR="|\b\c" ; SPINCOUNT=2;; 2) SPINCHAR="/\b\c" ; SPINCOUNT=3;; 3) SPINCHAR="-\b\c" ; SPINCOUNT=4;; 4) SPINCHAR="\\ \b\b\c"; SPINCOUNT=5;; 5) SPINCHAR="|\b\c" ; SPINCOUNT=6;; 6) SPINCHAR="/\b\c" ; SPINCOUNT=7;; 7) SPINCHAR="-\b\c" ; SPINCOUNT=8;; 8) SPINCHAR="\\ \b\b\c"; SPINCOUNT=1;; esac /bin/echo -e $SPINCHAR done echo "done." # copy the included license file # if [ -f "$startpath/LICENSE.LIC" ]; then cp $startpath/LICENSE.LIC $asphome fi case $os in Linux|linux ) $perlbin -I$asphome caspi2.pl "asphome=$asphome" "os=$os" \ "webserver_path=$webserver_path" "apache_rpm=$apache_rpm" "admin_port=$admin_port" ;; * ) echo "$os is an unsupported operating system." exit ;; esac cd $startpath