"Fossies" - the Fresh Open Source Software Archive

Member "fogproject-1.5.9/bin/installfog.sh" (13 Sep 2020, 25524 Bytes) of package /linux/misc/fogproject-1.5.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "installfog.sh": 1.5.8_vs_1.5.9.

    1 #!/bin/bash
    2 #
    3 #  FOG is a computer imaging solution.
    4 #  Copyright (C) 2007  Chuck Syperski & Jian Zhang
    5 #
    6 #   This program is free software: you can redistribute it and/or modify
    7 #   it under the terms of the GNU General Public License as published by
    8 #   the Free Software Foundation, either version 3 of the License, or
    9 #    any later version.
   10 #
   11 #   This program is distributed in the hope that it will be useful,
   12 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 #   GNU General Public License for more details.
   15 #
   16 #   You should have received a copy of the GNU General Public License
   17 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   18 #
   19 bindir=$(dirname $(readlink -f "$BASH_SOURCE") )
   20 cd $bindir
   21 workingdir=$(pwd)
   22 if [[ ! $EUID -eq 0 ]]; then
   23     echo "FOG Installation must be run as root user"
   24     exit 1
   25 fi
   26 which useradd >/dev/null 2>&1
   27 if [[ $? -eq 1 || $(echo $PATH | grep -o "sbin" | wc -l) -lt 2 ]]; then
   28     echo "Please switch to a proper root environment to run the installer!"
   29     echo "Use 'sudo -i' or 'su -' (skip the ' and note the hyphen at the end"
   30     echo "of the su command as it is important to load root's environment)."
   31     exit 1
   32 fi
   33 timestamp=$(date +%s)
   34 backupconfig=""
   35 . ../lib/common/functions.sh
   36 help() {
   37     echo -e "Usage: $0 [-h?dEUuHSCKYXTFA] [-f <filename>] [-N <databasename>]"
   38     echo -e "\t\t[-D </directory/to/document/root/>] [-c <ssl-path>]"
   39     echo -e "\t\t[-W <webroot/to/fog/after/docroot/>] [-B </backup/path/>]"
   40     echo -e "\t\t[-s <192.168.1.10>] [-e <192.168.1.254>] [-b <undionly.kpxe>]"
   41     echo -e "\t-h -? --help\t\t\tDisplay this info"
   42     echo -e "\t-o    --oldcopy\t\t\tCopy back old data"
   43     echo -e "\t-d    --no-defaults\t\tDon't guess defaults"
   44     echo -e "\t-U    --no-upgrade\t\tDon't attempt to upgrade"
   45     echo -e "\t-H    --no-htmldoc\t\tNo htmldoc, means no PDFs"
   46     echo -e "\t-S    --force-https\t\tForce HTTPS for all comunication"
   47     echo -e "\t-C    --recreate-CA\t\tRecreate the CA Keys"
   48     echo -e "\t-K    --recreate-keys\t\tRecreate the SSL Keys"
   49     echo -e "\t-Y -y --autoaccept\t\tAuto accept defaults and install"
   50     echo -e "\t-f    --file\t\t\tUse different update file"
   51     echo -e "\t-c    --ssl-path\t\tSpecify the ssl path"
   52     echo -e "\t               \t\t\t\tdefaults to /opt/fog/snapins/ssl"
   53     echo -e "\t-D    --docroot\t\t\tSpecify the Apache Docroot for fog"
   54     echo -e "\t               \t\t\t\tdefaults to OS DocumentRoot"
   55     echo -e "\t-W    --webroot\t\t\tSpecify the web root url want fog to use"
   56     echo -e "\t            \t\t\t\t(E.G. http://127.0.0.1/fog,"
   57     echo -e "\t            \t\t\t\t      http://127.0.0.1/)"
   58     echo -e "\t            \t\t\t\tDefaults to /fog/"
   59     echo -e "\t-B    --backuppath\t\tSpecify the backup path"
   60     echo -e "\t      --uninstall\t\tUninstall FOG"
   61     echo -e "\t-s    --startrange\t\tDHCP Start range"
   62     echo -e "\t-e    --endrange\t\tDHCP End range"
   63     echo -e "\t-b    --bootfile\t\tDHCP Boot file"
   64     echo -e "\t-E    --no-exportbuild\t\tSkip building nfs file"
   65     echo -e "\t-X    --exitFail\t\tDo not exit if item fails"
   66     echo -e "\t-T    --no-tftpbuild\t\tDo not rebuild the tftpd config file"
   67     echo -e "\t-F    --no-vhost\t\tDo not overwrite vhost file"
   68     echo -e "\t-A    --arm-support\t\tInstall kernel and initrd for ARM platforms"
   69     exit 0
   70 }
   71 optspec="h?odEUHSCKYyXxTPFAf:c:-:W:D:B:s:e:b:N:"
   72 while getopts "$optspec" o; do
   73     case $o in
   74         -)
   75             case $OPTARG in
   76                 help)
   77                     help
   78                     exit 0
   79                     ;;
   80                 uninstall)
   81                     exit 0
   82                     ;;
   83                 ssl-path)
   84                     ssslpath="${OPTARG}"
   85                     ssslpath="${ssslpath#'/'}"
   86                     ssslpath="${ssslpath%'/'}"
   87                     ssslpath="/${ssslpath}/"
   88                     ;;
   89                 no-vhost)
   90                     novhost="y"
   91                     ;;
   92                 no-defaults)
   93                     guessdefaults=0
   94                     ;;
   95                 no-upgrade)
   96                     doupdate=0
   97                     ;;
   98                 no-htmldoc)
   99                     signorehtmldoc=1
  100                     ;;
  101                 force-https)
  102                     shttpproto="https"
  103                     ;;
  104                 recreate-keys)
  105                     srecreateKeys="yes"
  106                     ;;
  107                 recreate-[Cc][Aa])
  108                     srecreateCA="yes"
  109                     ;;
  110                 autoaccept)
  111                     autoaccept="yes"
  112                     dbupdate="yes"
  113                     ;;
  114                 docroot)
  115                     sdocroot="${OPTARG}"
  116                     sdocroot="${docroot#'/'}"
  117                     sdocroot="${docroot%'/'}"
  118                     sdocroot="/${docroot}/"
  119                     ;;
  120                 oldcopy)
  121                     scopybackold=1
  122                     ;;
  123                 webroot)
  124                     if [[ $OPTARG != *('/')* ]]; then
  125                         echo -e "-$OPTARG needs a url path for access either / or /fog for example.\n\n\t\tfor example if you access fog using http://127.0.0.1/ without any trail\n\t\tset the path to /"
  126                         help
  127                         exit 2
  128                     fi
  129                     swebroot="${OPTARG}"
  130                     swebroot="${webroot#'/'}"
  131                     swebroot="${webroot%'/'}"
  132                     ;;
  133                 file)
  134                     if [[ -f $OPTARG ]]; then
  135                         fogpriorconfig=$OPTARG
  136                     else
  137                         echo "--$OPTARG requires file after"
  138                         help
  139                         exit 3
  140                     fi
  141                     ;;
  142                 backuppath)
  143                     if [[ ! -d $OPTARG ]]; then
  144                         echo "Path must be an existing directory"
  145                         help
  146                         exit 4
  147                     fi
  148                     sbackupPath=$OPTARG
  149                     ;;
  150                 startrange)
  151                     if [[ $(validip $OPTARG) != 0 ]]; then
  152                         echo "Invalid ip passed"
  153                         help
  154                         exit 5
  155                     fi
  156                     sstartrange=$OPTARG
  157                     dodhcp="Y"
  158                     bldhcp=1
  159                     ;;
  160                 endrange)
  161                     if [[ $(validip $OPTARG) != 0 ]]; then
  162                         echo "Invalid ip passed"
  163                         help
  164                         exit 6
  165                     fi
  166                     sendrange=$OPTARG
  167                     dodhcp="Y"
  168                     bldhcp=1
  169                     ;;
  170                 bootfile)
  171                     sbootfilename=$OPTARG
  172                     ;;
  173                 no-exportbuild)
  174                     sblexports=0
  175                     ;;
  176                 exitFail)
  177                     sexitFail=1
  178                     ;;
  179                 no-tftpbuild)
  180                     snoTftpBuild="true"
  181                     ;;
  182                 arm-support)
  183                     sarmsupport=1
  184                     ;;
  185                 *)
  186                     if [[ $OPTERR == 1 && ${optspec:0:1} != : ]]; then
  187                         echo "Unknown option: --${OPTARG}"
  188                         help
  189                         exit 7
  190                     fi
  191                     ;;
  192             esac
  193             ;;
  194         h|'?')
  195             help
  196             exit 0
  197             ;;
  198         o)
  199             scopybackold=1
  200             ;;
  201         c)
  202             ssslpath="${OPTARG}"
  203             ssslpath="${ssslpath#'/'}"
  204             ssslpath="${ssslpath%'/'}"
  205             ssslpath="/${ssslpath}/"
  206             ;;
  207         d)
  208             guessdefaults=0
  209             ;;
  210         U)
  211             doupdate=0
  212             ;;
  213         H)
  214             signorehtmldoc=1
  215             ;;
  216         S)
  217             shttpproto="https"
  218             ;;
  219         K)
  220             srecreateKeys="yes"
  221             ;;
  222         C)
  223             srecreateCA="yes"
  224             ;;
  225         [yY])
  226             autoaccept="yes"
  227             dbupdate="yes"
  228             ;;
  229         F)
  230             novhost="y"
  231             ;;
  232         D)
  233             sdocroot=$OPTARG
  234             sdocroot=${docroot#'/'}
  235             sdocroot=${docroot%'/'}
  236             sdocroot=/${docroot}/
  237             ;;
  238         W)
  239             if [[ $OPTARG != *('/')* ]]; then
  240                 echo -e "-$OPTARG needs a url path for access either / or /fog for example.\n\n\t\tfor example if you access fog using http://127.0.0.1/ without any trail\n\t\tset the path to /"
  241                 help
  242                 exit 2
  243             fi
  244             swebroot=$OPTARG
  245             swebroot=${webroot#'/'}
  246             swebroot=${webroot%'/'}
  247             ;;
  248         f)
  249             if [[ ! -f $OPTARG ]]; then
  250                 echo "-$OPTARG requires a file to follow"
  251                 help
  252                 exit 3
  253             fi
  254             fogpriorconfig=$OPTARG
  255             ;;
  256         B)
  257             if [[ ! -d $OPTARG ]]; then
  258                 echo "Path must be an existing directory"
  259                 help
  260                 exit 4
  261             fi
  262             sbackupPath=$OPTARG
  263             ;;
  264         s)
  265             if [[ $(validip $OPTARG) != 0 ]]; then
  266                 echo "Invalid ip passed"
  267                 help
  268                 exit 5
  269             fi
  270             sstartrange=$OPTARG
  271             dodhcp="Y"
  272             bldhcp=1
  273             ;;
  274         e)
  275             if [[ $(validip $OPTARG) != 0 ]]; then
  276                 echo "Invalid ip passed"
  277                 help
  278                 exit 6
  279             fi
  280             sendrange=$OPTARG
  281             dodhcp="Y"
  282             bldhcp=1
  283             ;;
  284         b)
  285             sbootfilename=$OPTARG
  286             ;;
  287         E)
  288             sblexports=0
  289             ;;
  290         X)
  291             exitFail=1
  292             ;;
  293         T)
  294             snoTftpBuild="true"
  295             ;;
  296         A)
  297             sarmsupport=1
  298             ;;
  299         N)
  300             if [[ -z $OPTARG ]]; then
  301                 echo "Please specify a database name"
  302                 help
  303                 exit 4
  304             fi
  305             smysqldbname=$OPTARG
  306             ;;
  307         :)
  308             echo "Option -$OPTARG requires a value"
  309             help
  310             exit 8
  311             ;;
  312         *)
  313             if [[ $OPTERR == 1 && ${optspec:0:1} != : ]]; then
  314                 echo "Unknown option: -$OPTARG"
  315                 help
  316                 exit 7
  317             fi
  318             ;;
  319     esac
  320 done
  321 [[ -z $version ]] && version="$(awk -F\' /"define\('FOG_VERSION'[,](.*)"/'{print $4}' ../packages/web/lib/fog/system.class.php | tr -d '[[:space:]]')"
  322 [[ -z $OS ]] && OS=$(uname -s)
  323 if [[ $OS =~ ^[^Ll][^Ii][^Nn][^Uu][^Xx] ]]; then
  324     echo "We do not currently support Installation on non-Linux Operating Systems"
  325     exit 2 # Fail OS Check
  326 else
  327     if [[ -f /etc/os-release ]]; then
  328         [[ -z $linuxReleaseName ]] && linuxReleaseName=$(sed -n 's/^NAME=\(.*\)/\1/p' /etc/os-release | tr -d '"')
  329         [[ -z $OSVersion ]] && OSVersion=$(sed -n 's/^VERSION_ID=\([^.]*\).*/\1/p' /etc/os-release | tr -d '"')
  330     elif [[ -f /etc/redhat-release ]]; then
  331         [[ -z $linuxReleaseName ]] && linuxReleaseName=$(cat /etc/redhat-release | awk '{print $1}')
  332         [[ -z $OSVersion ]] && OSVersion=$(cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*// | awk -F. '{print $1}')
  333     elif [[ -f /etc/debian_version ]]; then
  334         [[ -z $linuxReleaseName ]] && linuxReleaseName='Debian'
  335         [[ -z $OSVersion ]] && OSVersion=$(cat /etc/debian_version)
  336     fi
  337 fi
  338 [[ ! -d ./error_logs/ ]] && mkdir -p ./error_logs >/dev/null 2>&1
  339 echo "Installing LSB_Release as needed"
  340 dots "Attempting to get release information"
  341 command -v lsb_release >$workingdir/error_logs/fog_error_${version}.log 2>&1
  342 exitcode=$?
  343 if [[ ! $exitcode -eq 0 ]]; then
  344     case $linuxReleaseName in
  345         *[Bb][Ii][Aa][Nn]*|*[Uu][Bb][Uu][Nn][Tt][Uu]*|*[Mm][Ii][Nn][Tt]*)
  346             apt-get -yq install lsb-release >>$workingdir/error_logs/fog_error_${version}.log 2>&1
  347             ;;
  348         *[Cc][Ee][Nn][Tt][Oo][Ss]*|*[Rr][Ee][Dd]*[Hh][Aa][Tt]*|*[Ff][Ee][Dd][Oo][Rr][Aa]*)
  349             command -v dnf >>$workingdir/error_logs/fog_error_${version}.log 2>&1
  350             exitcode=$?
  351             case $exitcode in
  352                 0)
  353                     dnf -y install redhat-lsb-core >>$workingdir/error_logs/fog_error_${version}.log 2>&1
  354                     ;;
  355                 *)
  356                     yum -y install redhat-lsb-core >>$workingdir/error_logs/fog_error_${version}.log 2>&1
  357                     ;;
  358             esac
  359             ;;
  360         *[Aa][Rr][Cc][Hh]*)
  361             pacman -Sy --noconfirm lsb-release >>$workingdir/error_logs/fog_error_${version}.log 2>&1
  362             ;;
  363     esac
  364 fi
  365 [[ -z $OSVersion ]] && OSVersion=$(lsb_release -r| awk -F'[^0-9]*' /^[Rr]elease\([^.]*\).*/'{print $2}')
  366 echo "Done"
  367 . ../lib/common/config.sh
  368 [[ -z $dnsaddress ]] && dnsaddress=""
  369 [[ -z $username ]] && username=""
  370 [[ -z $password ]] && password=""
  371 [[ -z $osid ]] && osid=""
  372 [[ -z $osname ]] && osname=""
  373 [[ -z $dodhcp ]] && dodhcp=""
  374 [[ -z $bldhcp ]] && bldhcp=""
  375 [[ -z $installtype ]] && installtype=""
  376 [[ -z $interface ]] && interface=""
  377 [[ -z $ipaddress  ]] && ipaddress=""
  378 [[ -z $hostname  ]] && hostname=""
  379 [[ -z $routeraddress ]] && routeraddress=""
  380 [[ -z $plainrouter ]] && plainrouter=""
  381 [[ -z $blexports ]] && blexports=1
  382 [[ -z $installlang ]] && installlang=0
  383 [[ -z $bluseralreadyexists ]] && bluseralreadyexists=0
  384 [[ -z $guessdefaults ]] && guessdefaults=1
  385 [[ -z $doupdate ]] && doupdate=1
  386 [[ -z $ignorehtmldoc ]] && ignorehtmldoc=0
  387 [[ -z $httpproto ]] && httpproto="http"
  388 [[ -z $armsupport ]] && armsupport=0
  389 [[ -z $mysqldbname ]] && mysqldbname="fog"
  390 [[ -z $fogpriorconfig ]] && fogpriorconfig="$fogprogramdir/.fogsettings"
  391 #clearScreen
  392 if [[ -z $* || $* != +(-h|-?|--help|--uninstall) ]]; then
  393     echo > "$workingdir/error_logs/foginstall.log"
  394     exec &> >(tee -a "$workingdir/error_logs/foginstall.log")
  395 fi
  396 displayBanner
  397 echo -e "   Version: $version Installer/Updater\n"
  398 checkSELinux
  399 checkFirewall
  400 case $doupdate in
  401     1)
  402         if [[ -f $fogpriorconfig ]]; then
  403             echo -e "\n * Found FOG Settings from previous install at: $fogprogramdir/.fogsettings\n"
  404             echo -n " * Performing upgrade using these settings"
  405             . "$fogpriorconfig"
  406             doOSSpecificIncludes
  407             [[ -n $sblexports ]] && blexports=$sblexports
  408             [[ -n $snoTftpBuild ]] && noTftpBuild=$snoTftpBuild
  409             [[ -n $sbootfilename ]] && bootfilename=$sbootfilename
  410             [[ -n $sbackupPath ]] && backupPath=$sbackupPath
  411             [[ -n $swebroot ]] && webroot=$swebroot
  412             [[ -n $sdocroot ]] && docroot=$sdocroot
  413             [[ -n $signorehtmldoc ]] && ignorehtmldoc=$signorehtmldoc
  414             [[ -n $scopybackold ]] && copybackold=$scopybackold
  415         fi
  416         ;;
  417     *)
  418         echo -e "\n * FOG Installer will NOT attempt to upgrade from\n    previous version of FOG."
  419         ;;
  420 esac
  421 # evaluation of command line options
  422 [[ -n $shttpproto ]] && httpproto=$shttpproto
  423 [[ -n $sstartrange ]] && startrange=$sstartrange
  424 [[ -n $sendrange ]] && endrange=$sendrange
  425 [[ -n $ssslpath ]] && sslpath=$ssslpath
  426 [[ -n $srecreateCA ]] && recreateCA=$srecreateCA
  427 [[ -n $srecreateKeys ]] && recreateKeys=$srecreateKeys
  428 [[ -n $sarmsupport ]] && armsupport=$sarmsupport
  429 
  430 [[ -f $fogpriorconfig ]] && grep -l webroot $fogpriorconfig >>$workingdir/error_logs/fog_error_${version}.log 2>&1
  431 case $? in
  432     0)
  433         if [[ -n $webroot ]]; then
  434             webroot=${webroot#'/'}
  435             webroot=${webroot%'/'}
  436             [[ -z $webroot ]] && webroot="/" || webroot="/${webroot}/"
  437         fi
  438         ;;
  439     *)
  440         [[ -z $webroot ]] && webroot="/fog/"
  441         ;;
  442 esac
  443 if [[ -z $backupPath ]]; then
  444     backupPath="/home/"
  445     backupPath="${backupPath%'/'}"
  446     backupPath="${backupPath#'/'}"
  447     backupPath="/$backupPath/"
  448 fi
  449 [[ -z $bootfilename ]] && bootfilename="undionly.kpxe"
  450 [[ -n $smysqldbname ]] && mysqldbname=$smysqldbname
  451 
  452 [[ ! $doupdate -eq 1 || ! $fogupdateloaded -eq 1 ]] && . ../lib/common/input.sh
  453 # ask user input for newly added options like hostname etc.
  454 . ../lib/common/newinput.sh
  455 echo
  456 echo "   ######################################################################"
  457 echo "   #     FOG now has everything it needs for this setup, but please     #"
  458 echo "   #   understand that this script will overwrite any setting you may   #"
  459 echo "   #   have setup for services like DHCP, apache, pxe, tftp, and NFS.   #"
  460 echo "   ######################################################################"
  461 echo "   # It is not recommended that you install this on a production system #"
  462 echo "   #        as this script modifies many of your system settings.       #"
  463 echo "   ######################################################################"
  464 echo "   #             This script should be run by the root user.            #"
  465 echo "   #      It will prepend the running with sudo if root is not set      #"
  466 echo "   ######################################################################"
  467 echo "   #            Please see our wiki for more information at:            #"
  468 echo "   ######################################################################"
  469 echo "   #             https://wiki.fogproject.org/wiki/index.php             #"
  470 echo "   ######################################################################"
  471 echo
  472 echo " * Here are the settings FOG will use:"
  473 echo " * Base Linux: $osname"
  474 echo " * Detected Linux Distribution: $linuxReleaseName"
  475 echo " * Interface: $interface"
  476 echo " * Server IP Address: $ipaddress"
  477 echo " * Server Subnet Mask: $submask"
  478 echo " * Server Hostname: $hostname"
  479 case $installtype in
  480     N)
  481         echo " * Installation Type: Normal Server"
  482         echo " * Internationalization: $installlang"
  483         echo " * Image Storage Location: $storageLocation"
  484         case $bldhcp in
  485             1)
  486                 echo " * Using FOG DHCP: Yes"
  487                 echo " * DHCP router Address: $plainrouter"
  488                 ;;
  489             *)
  490                 echo " * Using FOG DHCP: No"
  491                 echo " * DHCP will NOT be setup but you must setup your"
  492                 echo " | current DHCP server to use FOG for PXE services."
  493                 echo
  494                 echo " * On a Linux DHCP server you must set: next-server and filename"
  495                 echo
  496                 echo " * On a Windows DHCP server you must set options 066 and 067"
  497                 echo
  498                 echo " * Option 066/next-server is the IP of the FOG Server: (e.g. $ipaddress)"
  499                 echo " * Option 067/filename is the bootfile: (e.g. $bootfilename)"
  500                 ;;
  501         esac
  502         ;;
  503     S)
  504         echo " * Installation Type: Storage Node"
  505         echo " * Node IP Address: $ipaddress"
  506         echo " * MySQL Database Host: $snmysqlhost"
  507         echo " * MySQL Database User: $snmysqluser"
  508         ;;
  509 esac
  510 echo
  511 while [[ -z $blGo ]]; do
  512     echo
  513     [[ -n $autoaccept ]] && blGo="y"
  514     if [[ -z $autoaccept ]]; then
  515         echo -n " * Are you sure you wish to continue (Y/N) "
  516         read blGo
  517     fi
  518     echo
  519     case $blGo in
  520         [Yy]|[Yy][Ee][Ss])
  521             echo " * Installation Started"
  522             echo
  523             checkInternetConnection
  524             if [[ $ignorehtmldoc -eq 1 ]]; then
  525                 [[ -z $newpackagelist ]] && newpackagelist=""
  526                 for z in $packages; do
  527                     [[ $z != htmldoc ]] && newpackagelist="$newpackagelist $z"
  528                 done
  529                 packages="$(echo $newpackagelist)"
  530             fi
  531             if [[ $bldhcp == 0 ]]; then
  532                 [[ -z $newpackagelist ]] && newpackagelist=""
  533                 for z in $packages; do
  534                     [[ $z != $dhcpname ]] && newpackagelist="$newpackagelist $z"
  535                 done
  536                 packages="$(echo $newpackagelist)"
  537             fi
  538             case $installtype in
  539                 [Ss])
  540                     packages=$(echo $packages | sed -e 's/[-a-zA-Z]*dhcp[-a-zA-Z]*//g')
  541                     ;;
  542             esac
  543             installPackages
  544             echo
  545             echo " * Confirming package installation"
  546             echo
  547             confirmPackageInstallation
  548             echo
  549             echo " * Configuring services"
  550             echo
  551             if [[ -z $storageLocation ]]; then
  552                 case $autoaccept in
  553                     [Yy]|[Yy][Ee][Ss])
  554                         storageLocation="/images"
  555                         ;;
  556                     *)
  557                         echo
  558                         echo -n " * What is the storage location for your images directory? (/images) "
  559                         read storageLocation
  560                         [[ -z $storageLocation ]] && storageLocation="/images"
  561                         while [[ ! -d $storageLocation && $storageLocation != "/images" ]]; do
  562                             echo -n " * Please enter a valid directory for your storage location (/images) "
  563                             read storageLocation
  564                             [[ -z $storageLocation ]] && storageLocation="/images"
  565                         done
  566                         ;;
  567                 esac
  568             fi
  569             configureUsers
  570             case $installtype in
  571                 [Ss])
  572                     checkDatabaseConnection
  573                     backupReports
  574                     configureMinHttpd
  575                     configureStorage
  576                     configureDHCP
  577                     configureTFTPandPXE
  578                     configureFTP
  579                     configureSnapins
  580                     configureUDPCast
  581                     installInitScript
  582                     installFOGServices
  583                     configureFOGService
  584                     configureNFS
  585                     writeUpdateFile
  586                     linkOptFogDir
  587                     if [[ $bluseralreadyexists == 1 ]]; then
  588                         echo
  589                         echo "\n * Upgrade complete\n"
  590                         echo
  591                     else
  592                         registerStorageNode
  593                         updateStorageNodeCredentials
  594                         [[ -n $snmysqlhost ]] && fogserver=$snmysqlhost || fogserver="fog-server"
  595                         echo
  596                         echo " * Setup complete"
  597                         echo
  598                         echo
  599                         echo " * You still need to setup this node in the fog management "
  600                         echo " | portal. You will need the username and password listed"
  601                         echo " | below."
  602                         echo
  603                         echo " * Management Server URL:"
  604                         echo "   ${httpproto}://${fogserver}${webroot}"
  605                         echo
  606                         echo "   You will need this, write this down!"
  607                         echo "   IP Address:          $ipaddress"
  608                         echo "   Interface:           $interface"
  609                         echo "   Management Username: $username"
  610                         echo "   Management Password: $password"
  611                         echo
  612                     fi
  613                     ;;
  614                 [Nn])
  615                     configureMySql
  616                     backupReports
  617                     configureHttpd
  618                     backupDB
  619                     updateDB
  620                     configureStorage
  621                     configureDHCP
  622                     configureTFTPandPXE
  623                     configureFTP
  624                     configureSnapins
  625                     configureUDPCast
  626                     installInitScript
  627                     installFOGServices
  628                     configureFOGService
  629                     configureNFS
  630                     writeUpdateFile
  631                     linkOptFogDir
  632                     updateStorageNodeCredentials
  633                     echo
  634                     echo " * Setup complete"
  635                     echo
  636                     echo "   You can now login to the FOG Management Portal using"
  637                     echo "   the information listed below.  The login information"
  638                     echo "   is only if this is the first install."
  639                     echo
  640                     echo "   This can be done by opening a web browser and going to:"
  641                     echo
  642                     echo "   ${httpproto}://${ipaddress}${webroot}management"
  643                     echo
  644                     echo "   Default User Information"
  645                     echo "   Username: fog"
  646                     echo "   Password: password"
  647                     echo
  648                     ;;
  649             esac
  650             [[ -d $webdirdest/maintenance ]] && rm -rf $webdirdest/maintenance
  651             ;;
  652         [Nn]|[Nn][Oo])
  653             echo " * FOG installer exited by user request"
  654             exit 0
  655             ;;
  656         *)
  657             echo
  658             echo " * Sorry, answer not recognized"
  659             echo
  660             exit 1
  661             ;;
  662     esac
  663 done
  664 if [[ -n "${backupconfig}" ]]; then
  665     echo " * Changed configurations:"
  666     echo
  667     echo "   The FOG installer changed configuration files and created the"
  668     echo "   following backup files from your origional files:"
  669     for conffile in ${backupconfig}; do
  670         echo "   * ${conffile} <=> ${conffile}.${timestamp}"
  671     done
  672     echo
  673 fi