Upgrading to VCL 2.5

VCL 2.5 is the second release to include an upgrade script. All you need to
upgrade VCL is the script. It will download and validate the VCL software and
then upgrade your system. The script can be used to upgrade all three parts of
VCL (database, web portal, and management node) or to upgrade each part
individually.

Running the upgrade script with no arguments will step you through upgrading
all three parts of VCL.


./vcl-upgrade.sh


Alternatively, any combination of the three parts of VCL can be upgraded by
passing arguments to the script. If upgrading the management node part of VCL,
it will also prompt you to agree to the installation of various system level
requirements needed for the code to run. The database upgrade portion does not
have to be run on the actual database server. The following are the arguments
available:

   vcl-upgrade.sh [-h|--help] [-d|--database] [-w|--web] [-m|--managementnode]
           [--dbhost <hostname>] [--dbadminuser <username>]
           [--dbadminpass <password>]

   -d|--database - upgrade database components
           --dbhost may optionally be specified if not localhost

   -w|--web - upgrade web server components

   -m|--managementnode - upgrade management node (vcld) components

   --dbhost <hostname> - hostname of database server (default=localhost)

   --dbname <name> - name of VCL database on database server (default=vcl)

   --dbadminuser <username> - admin username for database; must have access
           to modify database schema and dump data for backup (default=root)

   --dbadminpass <password> - password for dbadminuser (default=[no password])




MANUAL UPGRADE INSTRUCTIONS

The recommended method of upgrading VCL is to use the upgrade script. See above
for additional information. If manual installation is required, instructions
are listed below.

 1. Shutdown the httpd and vcld services

    service httpd stop
    service vcld stop

 2. Create a backup of the VCL database. This will provide a restore point if
    necessary.

    mysqldump vcl > ~/vcl-pre2.5-upgrade.sql

 3. Updates the database schema.

    mysql vcl < /root/apache-VCL-2.5/mysql/update-vcl.sql

 4. Possibly move old web code. If /var/www/html/vcl is a directory, rename it
    to /var/www/html/vcl-2.4.2. These instructions assume that you installed the
    VCL web code at /var/www/html/vcl. If you installed it elsewhere, replace
    /var/www/html/vcl with your vcl web root.

    mv /var/www/html/vcl /var/www/html/vcl-2.4.2

 5. Disable access to the old web code

    echo "Require all denied" > /var/www/html/vcl-2.4.2/.htaccess

 6. Copy the new code in place

    cp -ar /root/apache-VCL-2.5/web /var/www/html/vcl-2.5
    ln -sfn /var/www/html/vcl-2.5 /var/www/html/vcl

 7. Copy your 2.4.2 config files

    cd /var/www/html/vcl-2.4.2/.ht-inc
    cp conf.php secrets.php pubkey.pem keys.pem /var/www/html/vcl/.ht-inc

 8. If you are using SELinux, set the correct context:

    chcon -R -t httpd_sys_content_t /var/www/html/vcl-2.5
    chcon -t httpd_sys_rw_content_t /var/www/html/vcl-2.5/.ht-inc/maintenance
    chcon -t httpd_sys_rw_content_t /var/www/html/vcl-2.5/.ht-inc/cryptkey

 9. Update conf.php: the following item needs to be removed from the conf.php
    file:

    (don't forget to edit conf.php in the *new* location)
    vim /var/www/html/vcl/.ht-inc/conf.php

    define("MAXVMLIMIT", "100");

10. Update secrets.php: $cryptkey in secrets.php needs to be generated using
    openssl. Generate the value and set it in secrets.php:

    openssl rand 32 | base64
    vim /var/www/html/vcl/.ht-inc/secrets.php
 
    $cryptkey = 'xxxxxxxxxxxxxxxxxxxxxxxxx'; # set this to output of
                                             # "openssl rand 32 | base64"

11. Make the maintenance and cryptkey directories writable by the web server
    user. Normally this is the apache user, if using a different user change
    below command accordingly.

    chown apache /var/www/html/vcl/.ht-inc/maintenance
    chown apache /var/www/html/vcl/.ht-inc/cryptkey

12. Start httpd service

    service httpd start

13. Check testsetup.php: Check that everything is correct by viewing the
    testsetup.php script in your browser. This script is located in the same
    directory as the index.php script. I.e.

    https://your.site.url/vcl/testsetup.php

14. Copy old management node code:
    If /usr/local/vcl is a directory, copy it to /usr/local/vcl-2.4.2, rename
    /usr/local/vcl to /usr/local/vcl-2.5, and create a symlink.
    If /usr/local/vcl is a symlink to vcl-2.4.2, copy /usr/local/vcl-2.4.2 to
    /usr/local/vcl-2.5 and update the symlink.

    (for directory)
    cp -ar /usr/local/vcl /usr/local/vcl-2.4.2
    mv /usr/local/vcl /usr/local/vcl-2.5
    ln -s /usr/local/vcl-2.5 /usr/local/vcl

    (for symlink)
    cp -ar /usr/local/vcl-2.4.2 /usr/local/vcl-2.5
    ln -sfn /usr/local/vcl-2.5 /usr/local/vcl

15. Copy the new management node code over the old code:

    /bin/cp -ar /root/apache-VCL-2.5/managementnode/* /usr/local/vcl-2.5

16. Run install_perl_libs.pl to add any new perl library requirements:

    /usr/local/vcl/bin/install_perl_libs.pl

17. Start vcld service

    service vcld start

18. Make some test reservations and watch the vcld.log to verify everything is
    working correctly.

    tail -f /var/log/vcld.log
