| #!/bin/bash |
| |
| function xapi_plugin_location { |
| for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/" |
| do |
| if [ -d $PLUGIN_DIR ] |
| then |
| echo $PLUGIN_DIR |
| return 0 |
| fi |
| done |
| return 1 |
| } |
| |
| function zip_snapshot_location { |
| echo $1 | sed "s:\.git$::;s:$:/zipball/$2:g" |
| } |
| |
| function create_directory_for_kernels { |
| mkdir -p "/boot/guest" |
| } |
| |
| function extract_remote_zipball { |
| local ZIPBALL_URL=$1 |
| |
| local LOCAL_ZIPBALL=$(mktemp) |
| local EXTRACTED_FILES=$(mktemp -d) |
| |
| ( |
| wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate |
| unzip -q -o $LOCAL_ZIPBALL -d $EXTRACTED_FILES |
| rm -f $LOCAL_ZIPBALL |
| ) >&2 |
| |
| echo "$EXTRACTED_FILES" |
| } |
| |
| function find_xapi_plugins_dir { |
| find $1 -path '*/xapi.d/plugins' -type d -print |
| } |
| |
| function install_xapi_plugins_from_zipball { |
| local XAPI_PLUGIN_DIR |
| local EXTRACTED_FILES |
| local EXTRACTED_PLUGINS_DIR |
| |
| XAPI_PLUGIN_DIR=$(xapi_plugin_location) |
| |
| EXTRACTED_FILES=$(extract_remote_zipball $1) |
| EXTRACTED_PLUGINS_DIR=$(find_xapi_plugins_dir $EXTRACTED_FILES) |
| |
| cp -pr $EXTRACTED_PLUGINS_DIR/* $XAPI_PLUGIN_DIR |
| rm -rf $EXTRACTED_FILES |
| chmod a+x ${XAPI_PLUGIN_DIR}* |
| } |