fe586b1cbe
Fixes bug 1037516 This patch creates a directory os-guest-kernels inside the local SR, and sets up /boot/guest to be a symlink to that directory. This way OpenStack won't pollute Dom0's filesystem. Change-Id: If8dfe24355bd782a401fed0f2c4b423efd9c11ba
68 lines
1.6 KiB
Bash
68 lines
1.6 KiB
Bash
#!/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 {
|
|
if [ -d "/boot/guest" ]; then
|
|
echo "INFO: /boot/guest directory already exists, using that" >&2
|
|
else
|
|
local LOCALPATH="$(get_local_sr_path)/os-guest-kernels"
|
|
mkdir -p $LOCALPATH
|
|
ln -s $LOCALPATH /boot/guest
|
|
fi
|
|
}
|
|
|
|
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}*
|
|
}
|
|
|
|
function get_local_sr {
|
|
xe sr-list name-label="Local storage" --minimal
|
|
}
|
|
|
|
function get_local_sr_path {
|
|
echo "/var/run/sr-mount/$(get_local_sr)"
|
|
}
|