|
|
|
@ -147,7 +147,7 @@ function vmware_context {
|
|
|
|
|
function get_new_context {
|
|
|
|
|
local dev_context=$(blkid -l -t LABEL="CONTEXT" -o device)
|
|
|
|
|
if [ -e "${dev_context}" ]; then
|
|
|
|
|
MOUNT_DIR=$(mktemp -d "${RUNTIME_DIR}/mount.XXXXXX" 2>/dev/null)
|
|
|
|
|
mount_dir
|
|
|
|
|
if ! [ -d "${MOUNT_DIR}" ]; then
|
|
|
|
|
log err 'Error: Failed to create mountpoint' 2
|
|
|
|
|
exit 1
|
|
|
|
@ -160,11 +160,14 @@ function get_new_context {
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local fn_mnt_context="${MOUNT_DIR}/context.sh"
|
|
|
|
|
if [ -f "${fn_mnt_context}" ]; then
|
|
|
|
|
log debug "Found context ${fn_mnt_context}"
|
|
|
|
|
cp "${fn_mnt_context}" "${CONTEXT_NEW}"
|
|
|
|
|
fi
|
|
|
|
|
context_sh $MOUNT_DIR
|
|
|
|
|
|
|
|
|
|
elif find '/context' -mindepth 1 -print -quit 2>/dev/null | grep -q .; then
|
|
|
|
|
mount_dir
|
|
|
|
|
cp '/context/*' "${MOUNT_DIR}"
|
|
|
|
|
context_sh "${MOUNT_DIR}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif vmware_context ; then
|
|
|
|
|
log debug "Reading context via vmtoolsd"
|
|
|
|
@ -185,6 +188,19 @@ function get_new_context {
|
|
|
|
|
chmod 0400 "${CONTEXT_NEW}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function mount_dir
|
|
|
|
|
{
|
|
|
|
|
MOUNT_DIR=$(mktemp -d "${RUNTIME_DIR}/mount.XXXXXX" 2>/dev/null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function context_sh {
|
|
|
|
|
local fn_mnt_context="${1}/context.sh"
|
|
|
|
|
if [ -f "${fn_mnt_context}" ]; then
|
|
|
|
|
log debug "Found context ${fn_mnt_context}"
|
|
|
|
|
cp "${fn_mnt_context}" "${CONTEXT_NEW}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function check_context {
|
|
|
|
|
local _f_new=$1
|
|
|
|
|
local _f_old=$2
|
|
|
|
@ -244,7 +260,7 @@ function cleanup {
|
|
|
|
|
if [ -d "${MOUNT_DIR}" ]; then
|
|
|
|
|
log debug "Unmounting ${MOUNT_DIR}"
|
|
|
|
|
umount -l "${MOUNT_DIR}"
|
|
|
|
|
rmdir "${MOUNT_DIR}"
|
|
|
|
|
rm -r "${MOUNT_DIR}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# remove remporary files
|
|
|
|
|