Changes between Version 17 and Version 18 of installScript

Show
Ignore:
Timestamp:
05/08/08 22:57:05 (2 years ago)
Author:
Jonathan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • installScript

    v17 v18  
     1== Updates == 
     2The script has been added to the repository, see install.sh in the rootfolder. 
     3 
    14== Install Script == 
    25The current installation procedure for iDNS isn't very straight-forward. Personally it took me quite some time to figure out how to get everything running properly. 
     
    47To eliminate the ISMROOT and CGIBIN directories would be of value, this would obviously require some code to identify where those two directories are located, as discussed with Gary. 
    58 
    6 Right now I've written a bash script which I use to build iDNS, the script takes ARGV or predefined variables in the file itself. The script also locates the default directory for cgi-bin in FreeBSD, Fedora and Ubuntu (Probably more distros as well). It also identifies where the script is executed from, this script should be located in the iDNS folder to execute correctly. 
    7  
    8 == Sample == 
    9  
    10 {{{ 
    11 #!/bin/bash 
    12  
    13 # Predefined variables for mysql username and password, and BIND host, these can be entered with ARGV as well 
    14 #cUser= 
    15 #cPass= 
    16 #cHost= 
    17  
    18 # CGIDIR is identified automatically but can be set manually here or with ARGV 
    19 #export CGIDIR= 
    20  
    21 # Default variables for files and directories, DO NOT change! 
    22 iDNSCGI="iDNS.cgi" 
    23 cNamedDir="/usr/local/openisp" 
    24 export ISMROOT=`dirname $(dirname $0)` 
    25  
    26 # Collect ARGV 
    27 declare -r ARGS="${0} ${@}" 
    28 declare -i ARGC=${#}+1 
    29 declare -a ARGV=($ARGS) 
    30  
    31 # Use ARGV to set variables 
    32 for (( i=1 ; i < $ARGC ; i++ )); do 
    33     case ${ARGV[$i]} in 
    34         '-u'|'--username') 
    35             cUser=${ARGV[$i+1]}; 
    36             ;; 
    37         '-p'|'--password') 
    38             cPass=${ARGV[$i+1]}; 
    39             ;; 
    40         '-s'|'--server') 
    41             cHost=${ARGV[$i+1]}; 
    42             ;; 
    43         '-c'|'--cgidir') 
    44             export CGIDIR=${ARGV[$i+1]}; 
    45             ;; 
    46         '-d'|'--delete') 
    47             DELETE=1 
    48             ;; 
    49         '-h'|'--help') 
    50             usage; 
    51             ;; 
    52     esac 
    53 done 
    54  
    55 # Usage print function 
    56 function usage { 
    57     echo " 
    58     Syntax: $0 -u <username> -p <password> -h <dnshost> [-c <cgidir>] [-d] 
    59  
    60     Use this script to install iDNS. 
    61  
    62     Options: 
    63     -h|--help     : Show this help text 
    64      
    65     -s|--server   : Define DNS server 
    66     -u|--username : Set database username 
    67     -p|--password : Set database password 
    68     -c|--cgidir   : Set the cgi-bin location 
    69     -d|--delete   : Delete all old data 
    70     " 
    71     exit 0; 
    72 }; 
    73  
    74 # Check that all variables is set 
    75 if [ "${cUser}" = "" ] || [ "${cPass}" = "" ] || [ "${cHost}" = "" ]; then 
    76     usage; 
    77 fi 
    78  
    79 # Try to locate default cgi-bin folder 
    80 if [ "$CGIDIR" = "" ] || [ ! -e "$CGIDIR" ]; then 
    81     if [ -r "cgi-bin" ]; then 
    82         CGIDIR=cgi-bin/ 
    83     elif [ -r "/var/www/cgi-bin" ]; then 
    84         export CGIDIR=/var/www/cgi-bin/ 
    85         DISTRO=Fedora 
    86     elif [ -r "/usr/lib/cgi-bin" ]; then 
    87         export CGIDIR=/usr/lib/cgi-bin/ 
    88         DISTRO=Ubuntu 
    89     elif [ -r "/usr/local/www/cgi-bin" ]; then 
    90         export CGIDIR=/usr/local/www/cgi-bin 
    91         DISTRO=FreeBSD 
    92     else 
    93         echo "Unable to locate your cgi-bin directory. Please define it with the -c flag." 
    94         usage; 
    95     fi 
    96 fi 
    97  
    98 # Removes all old data 
    99 if [ "$DELETE" = 1 ]; then 
    100     echo "drop database idns;" | mysql -u$cUser -p$cPass 
    101     rm -fr $CGIDIR/* 
    102     rm -fr $cNamedDir 
    103 fi 
    104  
    105 cd $ISMROOT/iDNS 
    106  
    107 # Install functions 
    108 make clean 
    109 make 
    110 make install 
    111  
    112 if [ "$DELETE" = 1 ]; then 
    113     $CGIDIR/$iDNSCGI Initialize $cPass 
    114     $CGIDIR/$iDNSCGI installbind $cHost 
    115 else 
    116     echo "You've chosen not to remove any old data, if you want to purge all old data invoke the script with the -d flag. Any updates of the database that might've been added with this release has not been applied, iDNS.cgi is the only thing that has been updated! 
    117 " 
    118 fi 
    119  
    120 exit 0; 
    121  
    122 }}} 
     9Right now I've written a bash script which I use to build iDNS, the script takes ARGV or predefined variables in the file itself. The script also locates the default directory for cgi-bin in FreeBSD, Fedora and Ubuntu (Probably more distros as well). It also identifies where the script is executed from and sets ISMROOT based out of that, this script should be located in the iDNS folder to execute correctly. 
    12310 
    12411[wiki:NewDevelopments Back]