#!/bin/bash # -------------------------------------------------------------------------- # # Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # # # # Licensed under the Apache License, Version 2.0 (the "License"); you may # # not use this file except in compliance with the License. You may obtain # # a copy of the License at # # # # http://www.apache.org/licenses/LICENSE-2.0 # # # # Unless required by applicable law or agreed to in writing, software # # distributed under the License is distributed on an "AS IS" BASIS, # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # # limitations under the License. # #--------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # Install program for OpenNebula. It will install it relative to # $ONE_LOCATION if defined with the -d option, otherwise it'll be installed # under /. In this case you may specified the oneadmin user/group, so you do # not need run the OpenNebula daemon with root priviledges #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # COMMAND LINE PARSING #------------------------------------------------------------------------------- usage() { echo echo "Usage: install.sh [-u install_user] [-g install_group] [-k keep conf]" echo " [-d ONE_LOCATION] [-c occi|ec2] [-r] [-h]" echo echo "-u: user that will run opennebula, defults to user executing install.sh" echo "-g: group of the user that will run opennebula, defults to user" echo " executing install.sh" echo "-k: keep configuration files of existing OpenNebula installation, useful" echo " when upgrading. This flag should not be set when installing" echo " OpenNebula for the first time" echo "-d: target installation directory, if not defined it'd be root. Must be" echo " an absolute path." echo "-c: install client utilities: OpenNebula cli, occi and ec2 client files" echo "-s: install OpenNebula Sunstone" echo "-r: remove Opennebula, only useful if -d was not specified, otherwise" echo " rm -rf \$ONE_LOCATION would do the job" echo "-l: creates symlinks instead of copying files, useful for development" echo "-h: prints this help" } #------------------------------------------------------------------------------- TEMP_OPT=`getopt -o hkrlcsu:g:d: -n 'install.sh' -- "$@"` if [ $? != 0 ] ; then usage exit 1 fi eval set -- "$TEMP_OPT" INSTALL_ETC="yes" UNINSTALL="no" LINK="no" CLIENT="no" SUNSTONE="no" ONEADMIN_USER=`id -u` ONEADMIN_GROUP=`id -g` SRC_DIR=$PWD while true ; do case "$1" in -h) usage; exit 0;; -k) INSTALL_ETC="no" ; shift ;; -r) UNINSTALL="yes" ; shift ;; -l) LINK="yes" ; shift ;; -c) CLIENT="yes"; INSTALL_ETC="no" ; shift ;; -s) SUNSTONE="yes"; INSTALL_ETC="no" ; shift ;; -u) ONEADMIN_USER="$2" ; shift 2;; -g) ONEADMIN_GROUP="$2"; shift 2;; -d) ROOT="$2" ; shift 2 ;; --) shift ; break ;; *) usage; exit 1 ;; esac done #------------------------------------------------------------------------------- # Definition of locations #------------------------------------------------------------------------------- if [ -z "$ROOT" ] ; then BIN_LOCATION="/usr/bin" LIB_LOCATION="/usr/lib/one" ETC_LOCATION="/etc/one" LOG_LOCATION="/var/log/one" VAR_LOCATION="/var/lib/one" SUNSTONE_LOCATION="$LIB_LOCATION/sunstone" IMAGES_LOCATION="$VAR_LOCATION/images" RUN_LOCATION="/var/run/one" LOCK_LOCATION="/var/lock/one" INCLUDE_LOCATION="/usr/include" SHARE_LOCATION="/usr/share/one" MAN_LOCATION="/usr/share/man/man8" if [ "$CLIENT" = "yes" ]; then MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION" DELETE_DIRS="" CHOWN_DIRS="" elif [ "$SUNSTONE" = "yes" ]; then MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $SUNSTONE_LOCATION" DELETE_DIRS="$MAKE_DIRS" CHOWN_DIRS="" else MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \ $INCLUDE_LOCATION $SHARE_LOCATION \ $LOG_LOCATION $RUN_LOCATION $LOCK_LOCATION \ $IMAGES_LOCATION $MAN_LOCATION" DELETE_DIRS="$LIB_LOCATION $ETC_LOCATION $LOG_LOCATION $VAR_LOCATION \ $RUN_LOCATION $SHARE_DIRS" CHOWN_DIRS="$LOG_LOCATION $VAR_LOCATION $RUN_LOCATION $LOCK_LOCATION" fi else BIN_LOCATION="$ROOT/bin" LIB_LOCATION="$ROOT/lib" ETC_LOCATION="$ROOT/etc" VAR_LOCATION="$ROOT/var" SUNSTONE_LOCATION="$LIB_LOCATION/sunstone" IMAGES_LOCATION="$VAR_LOCATION/images" INCLUDE_LOCATION="$ROOT/include" SHARE_LOCATION="$ROOT/share" MAN_LOCATION="$ROOT/share/man/man8" if [ "$CLIENT" = "yes" ]; then MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION" DELETE_DIRS="$MAKE_DIRS" elif [ "$SUNSTONE" = "yes" ]; then MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $SUNSTONE_LOCATION" DELETE_DIRS="$MAKE_DIRS" else MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \ $INCLUDE_LOCATION $SHARE_LOCATION $IMAGES_LOCATION \ $MAN_LOCATION" DELETE_DIRS="$MAKE_DIRS" CHOWN_DIRS="$ROOT" fi CHOWN_DIRS="$ROOT" fi SHARE_DIRS="$SHARE_LOCATION/examples \ $SHARE_LOCATION/examples/tm \ $SHARE_LOCATION/hooks" ETC_DIRS="$ETC_LOCATION/im_kvm \ $ETC_LOCATION/im_xen \ $ETC_LOCATION/im_ec2 \ $ETC_LOCATION/vmm_ec2 \ $ETC_LOCATION/vmm_ssh \ $ETC_LOCATION/vmm_sh \ $ETC_LOCATION/tm_nfs \ $ETC_LOCATION/tm_ssh \ $ETC_LOCATION/tm_dummy \ $ETC_LOCATION/tm_lvm \ $ETC_LOCATION/hm \ $ETC_LOCATION/auth \ $ETC_LOCATION/ec2query_templates \ $ETC_LOCATION/occi_templates" LIB_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/OpenNebula \ $LIB_LOCATION/ruby/cloud/ \ $LIB_LOCATION/ruby/cloud/econe \ $LIB_LOCATION/ruby/cloud/econe/views \ $LIB_LOCATION/ruby/cloud/occi \ $LIB_LOCATION/tm_commands \ $LIB_LOCATION/tm_commands/nfs \ $LIB_LOCATION/tm_commands/ssh \ $LIB_LOCATION/tm_commands/dummy \ $LIB_LOCATION/tm_commands/lvm \ $LIB_LOCATION/mads \ $LIB_LOCATION/remotes \ $LIB_LOCATION/remotes/im \ $LIB_LOCATION/remotes/im/kvm.d \ $LIB_LOCATION/remotes/im/xen.d \ $LIB_LOCATION/remotes/im/ganglia.d \ $LIB_LOCATION/remotes/vmm/xen \ $LIB_LOCATION/remotes/vmm/kvm \ $LIB_LOCATION/remotes/image \ $LIB_LOCATION/remotes/image/fs \ $LIB_LOCATION/sh" VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/im \ $VAR_LOCATION/remotes/im/kvm.d \ $VAR_LOCATION/remotes/im/xen.d \ $VAR_LOCATION/remotes/im/ganglia.d \ $VAR_LOCATION/remotes/vmm/xen \ $VAR_LOCATION/remotes/vmm/kvm \ $VAR_LOCATION/remotes/image \ $VAR_LOCATION/remotes/image/fs" SUNSTONE_DIRS="$SUNSTONE_LOCATION/models \ $SUNSTONE_LOCATION/models/OpenNebulaJSON \ $SUNSTONE_LOCATION/public \ $SUNSTONE_LOCATION/public/js \ $SUNSTONE_LOCATION/public/js/plugins \ $SUNSTONE_LOCATION/public/css \ $SUNSTONE_LOCATION/public/vendor \ $SUNSTONE_LOCATION/public/vendor/jQueryLayout \ $SUNSTONE_LOCATION/public/vendor/dataTables \ $SUNSTONE_LOCATION/public/vendor/jQueryUI \ $SUNSTONE_LOCATION/public/vendor/jQuery \ $SUNSTONE_LOCATION/public/vendor/jGrowl \ $SUNSTONE_LOCATION/public/images \ $SUNSTONE_LOCATION/templates" LIB_ECO_CLIENT_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/OpenNebula \ $LIB_LOCATION/ruby/cloud/ \ $LIB_LOCATION/ruby/cloud/econe" LIB_OCCI_CLIENT_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/OpenNebula \ $LIB_LOCATION/ruby/cloud/occi" LIB_OCA_CLIENT_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/OpenNebula" LIB_CLI_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/OpenNebula" if [ "$CLIENT" = "yes" ]; then MAKE_DIRS="$MAKE_DIRS $LIB_ECO_CLIENT_DIRS $LIB_OCCI_CLIENT_DIRS \ $LIB_CLI_DIRS" elif [ "$SUNSTONE" = "yes" ]; then MAKE_DIRS="$MAKE_DIRS $SUNSTONE_DIRS $LIB_OCA_CLIENT_DIRS" else MAKE_DIRS="$MAKE_DIRS $SHARE_DIRS $ETC_DIRS $LIB_DIRS $VAR_DIRS $SUNSTONE_DIRS" fi #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # FILE DEFINITION, WHAT IS GOING TO BE INSTALLED AND WHERE #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- INSTALL_FILES=( BIN_FILES:$BIN_LOCATION INCLUDE_FILES:$INCLUDE_LOCATION LIB_FILES:$LIB_LOCATION RUBY_LIB_FILES:$LIB_LOCATION/ruby RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula MAD_RUBY_LIB_FILES:$LIB_LOCATION/ruby MAD_RUBY_LIB_FILES:$LIB_LOCATION/remotes MAD_RUBY_LIB_FILES:$VAR_LOCATION/remotes MAD_SH_LIB_FILES:$LIB_LOCATION/sh MAD_SH_LIB_FILES:$LIB_LOCATION/remotes MAD_SH_LIB_FILES:$VAR_LOCATION/remotes MADS_LIB_FILES:$LIB_LOCATION/mads IM_PROBES_FILES:$VAR_LOCATION/remotes/im IM_PROBES_KVM_FILES:$VAR_LOCATION/remotes/im/kvm.d IM_PROBES_XEN_FILES:$VAR_LOCATION/remotes/im/xen.d IM_PROBES_GANGLIA_FILES:$VAR_LOCATION/remotes/im/ganglia.d VMM_SSH_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm VMM_SSH_XEN_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen VMM_SSH_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll VMM_SSH_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/xen/poll VMM_SSH_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll_local VMM_SSH_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/xen/poll_local IM_PROBES_FILES:$LIB_LOCATION/remotes/im IM_PROBES_KVM_FILES:$LIB_LOCATION/remotes/im/kvm.d IM_PROBES_XEN_FILES:$LIB_LOCATION/remotes/im/xen.d IM_PROBES_GANGLIA_FILES:$LIB_LOCATION/remotes/im/ganglia.d VMM_SSH_KVM_SCRIPTS:$LIB_LOCATION/remotes/vmm/kvm VMM_SSH_XEN_SCRIPTS:$LIB_LOCATION/remotes/vmm/xen VMM_SSH_XEN_KVM_POLL:$LIB_LOCATION/remotes/vmm/kvm/poll VMM_SSH_XEN_KVM_POLL:$LIB_LOCATION/remotes/vmm/xen/poll VMM_SSH_GANGLIA_POLL:$LIB_LOCATION/remotes/vmm/kvm/poll_local VMM_SSH_GANGLIA_POLL:$LIB_LOCATION/remotes/vmm/xen/poll_local NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm IMAGE_DRIVER_FS_SCRIPTS:$LIB_LOCATION/remotes/image/fs IMAGE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/image/fs EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm HOOK_SHARE_FILES:$SHARE_LOCATION/hooks COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views ECO_BIN_FILES:$BIN_LOCATION OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi OCCI_BIN_FILES:$BIN_LOCATION MAN_FILES:$MAN_LOCATION ) INSTALL_CLIENT_FILES=( COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud ECO_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/econe ECO_BIN_CLIENT_FILES:$BIN_LOCATION COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud OCCI_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/occi OCCI_BIN_CLIENT_FILES:$BIN_LOCATION CLI_BIN_FILES:$BIN_LOCATION CLI_LIB_FILES:$LIB_LOCATION/ruby RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula ) INSTALL_SUNSTONE_RUBY_FILES=( SUNSTONE_RUBY_LIB_FILES:$LIB_LOCATION/ruby RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula ) INSTALL_SUNSTONE_FILES=( SUNSTONE_FILES:$SUNSTONE_LOCATION SUNSTONE_BIN_FILES:$BIN_LOCATION SUNSTONE_MODELS_FILES:$SUNSTONE_LOCATION/models SUNSTONE_MODELS_JSON_FILES:$SUNSTONE_LOCATION/models/OpenNebulaJSON SUNSTONE_TEMPLATE_FILES:$SUNSTONE_LOCATION/templates SUNSTONE_PUBLIC_JS_FILES:$SUNSTONE_LOCATION/public/js SUNSTONE_PUBLIC_JS_PLUGINS_FILES:$SUNSTONE_LOCATION/public/js/plugins SUNSTONE_PUBLIC_CSS_FILES:$SUNSTONE_LOCATION/public/css SUNSTONE_PUBLIC_VENDOR_DATATABLES:$SUNSTONE_LOCATION/public/vendor/dataTables SUNSTONE_PUBLIC_VENDOR_JGROWL:$SUNSTONE_LOCATION/public/vendor/jGrowl SUNSTONE_PUBLIC_VENDOR_JQUERY:$SUNSTONE_LOCATION/public/vendor/jQuery SUNSTONE_PUBLIC_VENDOR_JQUERYUI:$SUNSTONE_LOCATION/public/vendor/jQueryUI SUNSTONE_PUBLIC_VENDOR_JQUERYLAYOUT:$SUNSTONE_LOCATION/public/vendor/jQueryLayout SUNSTONE_PUBLIC_IMAGES_FILES:$SUNSTONE_LOCATION/public/images ) INSTALL_ETC_FILES=( ETC_FILES:$ETC_LOCATION VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2 VMM_SSH_ETC_FILES:$ETC_LOCATION/vmm_ssh VMM_SH_ETC_FILES:$ETC_LOCATION/vmm_sh IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2 TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm HM_ETC_FILES:$ETC_LOCATION/hm AUTH_ETC_FILES:$ETC_LOCATION/auth ECO_ETC_FILES:$ETC_LOCATION ECO_ETC_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates OCCI_ETC_FILES:$ETC_LOCATION OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates SUNSTONE_ETC_FILES:$ETC_LOCATION ) #------------------------------------------------------------------------------- # Binary files, to be installed under $BIN_LOCATION #------------------------------------------------------------------------------- BIN_FILES="src/nebula/oned \ src/scheduler/src/sched/mm_sched \ src/cli/onevm \ src/cli/onehost \ src/cli/onevnet \ src/cli/oneuser \ src/cli/oneimage \ src/cli/onecluster \ src/cli/onetemplate \ share/scripts/one \ src/authm_mad/oneauth" #------------------------------------------------------------------------------- # C/C++ OpenNebula API Library & Development files # Include files, to be installed under $INCLUDE_LOCATION # Library files, to be installed under $LIB_LOCATION #------------------------------------------------------------------------------- INCLUDE_FILES="" LIB_FILES="" #------------------------------------------------------------------------------- # Ruby library files, to be installed under $LIB_LOCATION/ruby #------------------------------------------------------------------------------- RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \ src/mad/ruby/CommandManager.rb \ src/mad/ruby/OpenNebulaDriver.rb \ src/mad/ruby/VirtualMachineDriver.rb \ src/mad/ruby/Ganglia.rb \ src/cli/client_utilities.rb \ src/cli/command_parse.rb \ src/oca/ruby/OpenNebula.rb \ src/tm_mad/TMScript.rb \ src/authm_mad/one_usage.rb \ src/authm_mad/quota.rb \ src/authm_mad/simple_auth.rb \ src/authm_mad/simple_permissions.rb \ src/authm_mad/ssh_auth.rb" RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \ src/oca/ruby/OpenNebula/HostPool.rb \ src/oca/ruby/OpenNebula/Pool.rb \ src/oca/ruby/OpenNebula/User.rb \ src/oca/ruby/OpenNebula/UserPool.rb \ src/oca/ruby/OpenNebula/VirtualMachine.rb \ src/oca/ruby/OpenNebula/VirtualMachinePool.rb \ src/oca/ruby/OpenNebula/VirtualNetwork.rb \ src/oca/ruby/OpenNebula/VirtualNetworkPool.rb \ src/oca/ruby/OpenNebula/Image.rb \ src/oca/ruby/OpenNebula/ImagePool.rb \ src/oca/ruby/OpenNebula/Cluster.rb \ src/oca/ruby/OpenNebula/ClusterPool.rb \ src/oca/ruby/OpenNebula/Template.rb \ src/oca/ruby/OpenNebula/TemplatePool.rb \ src/oca/ruby/OpenNebula/XMLUtils.rb" #----------------------------------------------------------------------------- # MAD Script library files, to be installed under $LIB_LOCATION/