home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Web / Utilities / wwwcount-2.3 / Count-install < prev    next >
Encoding:
Text File  |  1996-05-02  |  8.7 KB  |  394 lines

  1. #!/bin/sh
  2. ##
  3. # $Revision: 2.3 $
  4. # $Date: 1996/05/03 02:20:22 $
  5. #
  6. # creates the directories related to Count 2.1 and install the binary
  7. # Count.cgi to the cgi-bin directory, copy the digit directories to 
  8. # the digit directory
  9. # this program uses the variable template created by the Count_config
  10. # program
  11. #
  12. # muquit@semcor.com
  13. # Nov 24, 1995
  14. ##
  15. ver=`cat ./VERSION`
  16. Basedir="wwwcount$ver"
  17. INSTALL_PROG="./install-sh"
  18. Tmpl="./Config.tmpl"
  19. Binary="./Count.cgi"
  20. DigitA="./wcount/digits/A"
  21. DigitB="./wcount/digits/B"
  22. DigitC="./wcount/digits/C"
  23. DigitD="./wcount/digits/D"
  24. DigitE="./wcount/digits/E"
  25. Rgbfile="./wcount/rgb.txt"
  26. SAMPLE_DAT="./wcount/data/sample.dat"
  27. UserId="nobody"
  28. userid_flag=0
  29. GroupId="nobody"
  30. groupid_flag=0
  31. Digits="zero.gif one.gif two.gif three.gif four.gif five.gif\
  32.  six.gif seven.gif eight.gif nine.gif"
  33.  
  34.  
  35. Pwd=`pwd`
  36. checkbd=`basename $Pwd`
  37.  
  38. ###
  39. # check if we'r inside wwwcount2.2 directory
  40.     if [ $checkbd != $Basedir ]
  41.     then
  42. cat << EOR2
  43.    
  44. ************************************************************************
  45.     You must be at the base directory of the counter source distribution
  46.     in order to install Count.cgi
  47.     Wrong directory: $checkbd
  48. ************************************************************************
  49.     
  50. EOR2
  51.     exit 2
  52.     fi
  53.  
  54. if [ ! -f $Tmpl ]
  55. then
  56. cat<<EOT
  57.     
  58.     The varaible template file "$Tmpl" does not exist! This file
  59.     is created in the configuration procedure. Apparently your 
  60.     configuration procedure did not succeed!
  61.  
  62.     Aborting installation!
  63.  
  64. EOT
  65.     exit 1
  66. fi
  67.  
  68. if [ ! -f $Binary ]
  69. then
  70. cat<<EOB
  71.     
  72.     Counter binary "$Binary" does not exist!
  73.     Apparently your compilation did not succeed or you did not compile
  74.     the program!
  75.  
  76.     Aborting installation!
  77. EOB
  78.     exit 1
  79. fi
  80.  
  81. if [ ! -d $DigitA  -o ! -d $DigitB -o ! -d $DigitC -o ! -d $DigitD ]
  82. then
  83. cat<<EOD
  84.  
  85.     Suppiled digit directories not found in ./digits direcory!
  86.  
  87.     Aborting installation!
  88.  
  89. EOD
  90. exit 1
  91. fi
  92.  
  93. if [ ! -f $Rgbfile ]
  94. then
  95. cat<<EOB
  96.     
  97.     Rgb file "$Rgbfile" does not exist!
  98.     Apparently your removed it mistakenly!
  99.  
  100.     Aborting installation!
  101. EOB
  102.     exit 1
  103. fi
  104.  
  105. ##
  106. # get the vars
  107. ##
  108.  
  109. . $Tmpl
  110.  
  111. if [ ! -f ./$CONFIG_FILE ]
  112. then
  113.  
  114. cat <<EOC
  115.  
  116.     The configuration file $CONFIG_FILR is not created!
  117.     please create it first by running the script ./Gen-conf
  118.  
  119.     Aborting installation!
  120. EOC
  121.  
  122.     exit 1
  123. fi
  124.  
  125. # check if root
  126. uidfile="/tmp/Count$$"
  127. touch $uidfile
  128. user=`ls -al $uidfile | awk '{print $3}'`
  129.  
  130. if [ "$user" != "root" ]
  131. then
  132. cat << EOR
  133.  
  134.     WARNING: You are not root! To install the package in the system,
  135.     you will need root access!
  136.  
  137. EOR
  138. else
  139. cat <<EOJ
  140.     
  141.     *** You are installing Counter as root ***
  142.  
  143. EOJ
  144. rm -f $uidfile
  145.  
  146. fi
  147. #   if [ "`whoami`x" != "root"x ]; then
  148. #cat << EOR
  149.  
  150. #    WARNING: You are not root! To install the package in the system,
  151. #    you will need root access!
  152.  
  153. #EOR
  154. #    else
  155. #cat <<EOJ
  156.     
  157. #    *** You are installing Counter as root ***
  158.  
  159. #EOJ
  160. #    fi
  161.  
  162. (echo "hi there\c" ; echo " ") >./.echotest
  163. if grep c ./.echotest >/dev/null 2>&1 ; then
  164. n='-n'
  165. c=''
  166. else
  167. n=''
  168. c='\c'
  169. fi
  170. rm -f ./.echotest >/dev/null 2>&1
  171.  
  172.  
  173. # debug
  174. cat<<DUM
  175.  
  176. ===================
  177. Your configuration:
  178.  
  179. cgi-bin directory= $CGIBIN_DIR
  180. conf directory= $CONFIG_DIR
  181. conf file= $CONFIG_FILE
  182. digit directory=$DIGIT_DIR
  183. data directory=$DATA_DIR
  184. log directory=$LOG_DIR
  185. log file=$LOG_FILE
  186. rgb file= $RGB_FILE
  187. ===================
  188.  
  189. DUM
  190.  
  191. echo $n "Continue [y|n]$c? "
  192. read answer
  193.  
  194. if [ .$answer = . ]
  195. then
  196.     answer=x
  197. fi
  198.     until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  199.     do
  200.         echo $n "Continue [y|n]$c? " 
  201.         read answer
  202.             if [ .$answer = . ]
  203.             then
  204.                 answer=x
  205.             fi
  206.     done
  207.  
  208.     case $answer in
  209.         y|Y)
  210.             echo "proceeding..."
  211.         ;;
  212.         n|N)
  213.             echo "Exiting..Better luck next time!"
  214.             exit 1
  215.         ;;
  216.  
  217.         *)
  218.             echo ""
  219.             echo "Illegal choice"
  220.      esac
  221.  
  222.  
  223. cat <<EOU
  224.     
  225.     Now if you know what user and group id child processes of http
  226.     server use, I can change the ownership and access permission
  227.     accordigly. If you do not know, they are usually defined in the
  228.     file httpd.conf with User and Group. I suggest create a unique
  229.     user and group say httpd and set the User and Group to httpd.
  230.  
  231. EOU
  232. echo $n "*Do you know the user and group id of httpd' child process[y|n]:$c? "
  233.    read answer
  234.    if [ .$answer = . ]
  235.    then
  236.         answer=x
  237.    fi   
  238.    until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  239.    do
  240. echo $n "*Do you know the user and group id of httpd' child process[y|n]:$c? "
  241.    read answer
  242.    if [ .$answer = . ]
  243.    then
  244.         answer=x
  245.    fi   
  246.    done
  247.  
  248.    case $answer in
  249.         y|Y)
  250.             userid_flag=1
  251.             groupid_flag=1
  252. ###
  253. # enter user id -starts
  254. ###
  255.    echo $n "*Enter user id of httpd's child process [no default]:$c? "
  256.    read answer
  257.    if [ .$answer = . ]
  258.    then 
  259.         answer=x
  260.    fi
  261.    until [ $answer != "x" ]
  262.    do
  263.    echo $n "*Enter user id of httpd's child process [no default]:$c? "
  264.    read answer
  265.    if [ .$answer = . ]
  266.    then
  267.         answer=x
  268.    fi
  269.    done
  270.  
  271.     UserId=$answer
  272. ###
  273. # enter user id -ends
  274. ###
  275.  
  276. ##
  277. # enter groud id -starts
  278. ##
  279.    echo $n "*Enter group id of httpd's child process [no default]:$c? "
  280.    read answer
  281.    if [ .$answer = . ]
  282.    then 
  283.         answer=x
  284.    fi
  285.    until [ $answer != "x" ]
  286.    do
  287.    echo $n "*Enter group id of httpd's child process [no default]:$c? "
  288.    read answer
  289.    if [ .$answer = . ]
  290.    then
  291.         answer=x
  292.    fi
  293.    done
  294.  
  295.     GroupId=$answer
  296.  
  297. ##
  298. # enter groud id -ends
  299. ##
  300. echo "installing Count.cgi->$CGIBIN_DIR"
  301. $INSTALL_PROG -c -o $UserId -g $GroupId -m 755 ./Count.cgi $CGIBIN_DIR/Count.cgi
  302. echo "installing $CONFIG_FILE->$CONFIG_DIR"
  303. $INSTALL_PROG -c -o $UserId -g $GroupId -m 664 $CONFIG_FILE $CONFIG_DIR/$CONFIG_FILE
  304. echo "installing sample datafile $SAMPLE_DAT->$DATA_DIR"
  305. $INSTALL_PROG -c -o $UserId -g $GroupId -m 664 $SAMPLE_DAT $DATA_DIR/sample.dat
  306. chmod 775 $DATA_DIR
  307.  
  308. echo "installing rgb.txt->$BASE_DIR"
  309. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $Rgbfile $BASE_DIR/rgb.txt
  310.  
  311. echo "creating Log directory $LOG_DIR"
  312. ./mkdirhier $LOG_DIR
  313. chown $UserId $LOG_DIR
  314. chgrp $GroupId $LOG_DIR
  315. chmod 775 $LOG_DIR
  316.  
  317. echo "installing image strip for digit style A->$DIGIT_DIR/A"
  318. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitA/strip.gif\
  319.     $DIGIT_DIR/A/strip.gif
  320.  
  321. echo "installing image strip for digit style B->$DIGIT_DIR/B"
  322. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitB/strip.gif\
  323.     $DIGIT_DIR/B/strip.gif
  324.  
  325. echo "installing strip image for digit style C->$DIGIT_DIR/C"
  326. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitC/strip.gif\
  327.     $DIGIT_DIR/C/strip.gif
  328.  
  329. echo "installing strip image for digit style D->$DIGIT_DIR/D"
  330. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitD/strip.gif\
  331.     $DIGIT_DIR/D/strip.gif
  332.  
  333. echo "installing sample image lenna.gif->$DIGIT_DIR/D"
  334. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitD/lenna.gif\
  335.     $DIGIT_DIR/D/lenna.gif
  336.  
  337. echo "installing strip image for digit style E->$DIGIT_DIR/E"
  338. $INSTALL_PROG -c -o $UserId -g $GroupId -m 644 $DigitE/strip.gif\
  339.     $DIGIT_DIR/E/strip.gif
  340. ##
  341. # change ownership
  342. # -R is not portable, reported by Geoff Scully <gws@dis.on.ca> and suggested
  343. # the alternative (01/15/96)
  344. #chown -R $UserId.$GroupId $BASE_DIR
  345. find $BASE_DIR -exec chown $UserId {} \;
  346. find $BASE_DIR -exec chgrp $GroupId {} \;
  347. #            echo "UserId=$UserId"
  348. #            echo "GroupId=$GroupId"
  349.         ;;
  350.         n|N)
  351. cat <<EOM
  352.     
  353.     I am not changing any ownership or access permissions.
  354.     You are on your own. If the counter program can not access digit
  355.     images or can not write to datafile, you have to set permisson 
  356.     manually.
  357.     good luck!
  358.  
  359. EOM
  360. echo "installing Count.cgi->$CGIBIN_DIR"
  361. $INSTALL_PROG -c -m 755 ./Count.cgi $CGIBIN_DIR/Count.cgi
  362. echo "installing $CONFIG_FILE->$CONFIG_DIR"
  363. $INSTALL_PROG -c $CONFIG_FILE $CONFIG_DIR/$CONFIG_FILE
  364. echo "installing sample datafile $SAMPLE_DAT->$DATA_DIR"
  365. $INSTALL_PROG -c $SAMPLE_DAT $DATA_DIR/sample.dat
  366.  
  367. echo "installing rgb.txt->$BASE_DIR"
  368. $INSTALL_PROG -c $Rgbfile $BASE_DIR/rgb.txt
  369.  
  370. echo "creating Log directory $LOG_DIR"
  371. ./mkdirhier $LOG_DIR
  372.  
  373. echo "installing image strip for digit style A->$DIGIT_DIR/A"
  374. $INSTALL_PROG -c $DigitA/strip.gif $DIGIT_DIR/A/strip.gif
  375.  
  376. echo "installing image strip for digit style B->$DIGIT_DIR/B"
  377. $INSTALL_PROG -c $DigitB/strip.gif $DIGIT_DIR/B/strip.gif
  378.  
  379. echo "installing image strip for digit style C->$DIGIT_DIR/C"
  380. $INSTALL_PROG -c $DigitC/strip.gif $DIGIT_DIR/C/strip.gif
  381.  
  382. echo "installing image strip for digit style D->$DIGIT_DIR/D"
  383. $INSTALL_PROG -c $DigitD/strip.gif $DIGIT_DIR/D/strip.gif
  384.  
  385. echo "installing sample image lenna.gif->$DIGIT_DIR/D"
  386. $INSTALL_PROG -c $DigitD/lenna.gif $DIGIT_DIR/D/lenna.gif
  387.  
  388. echo "installing image strip for digit style E->$DIGIT_DIR/E"
  389. $INSTALL_PROG -c $DigitE/strip.gif $DIGIT_DIR/E/strip.gif
  390.     ;;
  391.         *)
  392.    esac
  393.  
  394.