From 2e1598adb7208ab594773e1f3434d8d19a3ea3f5 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 18 Dec 2018 12:41:49 +0100 Subject: [PATCH] development: linuxcontainers marketplace fix --- src/datastore_mad/remotes/lxd_downloader.sh | 79 ++++++++++--------- .../remotes/linuxcontainers/monitor | 4 +- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/datastore_mad/remotes/lxd_downloader.sh b/src/datastore_mad/remotes/lxd_downloader.sh index 1859b9b8b3..6dca305115 100755 --- a/src/datastore_mad/remotes/lxd_downloader.sh +++ b/src/datastore_mad/remotes/lxd_downloader.sh @@ -49,7 +49,7 @@ CURL="curl -L" # This function returns the associated context packages version to the installed # OpenNebula version #------------------------------------------------------------------------------- -get_tag_name () { +function get_tag_name { local version=`oned -v | grep "is distributed" | awk '{print $2}' | tr -d .` if [ `echo $version | wc -c` -eq 4 ]; then @@ -96,7 +96,7 @@ url=`echo $MARKET_URL | grep -oP "^"lxd://"\K.*"` rootfs_url=`echo $url | cut -d '?' -f 1` arguments=`echo $url | cut -d '?' -f 2` -selected_tag=get_tag_name +selected_tag=`get_tag_name` #Create a shell variable for every argument (size=5219, format=raw...) for p in ${arguments//&/ }; do @@ -141,52 +141,58 @@ mkdir $TMP_DIR/$id case "$rootfs_url" in *ubuntu*|*debian*) terminal="/bin/bash" - read -r -d '' commands << EOT - export PATH=$PATH:/bin:/sbin - rm -f /etc/resolv.conf > /dev/null 2>&1 - echo "nameserver $DNS_SERVER" > /etc/resolv.conf - apt-get update > /dev/null - apt-get install curl -y > /dev/null 2>&1 - $CURL $CONTEXT_URL/v$selected_tag/one-context_$selected_tag-1.deb -Lsfo /root/context.deb - apt-get install /root/context.deb -y > /dev/null 2>&1 -EOT + commands=$(cat < /dev/null 2>&1 +echo "nameserver $DNS_SERVER" > /etc/resolv.conf + +apt-get update > /dev/null +apt-get install curl -y > /dev/null 2>&1 + +$CURL $CONTEXT_URL/v$selected_tag/one-context_$selected_tag-1.deb -Lsfo /root/context.deb +apt-get install /root/context.deb -y > /dev/null 2>&1 +EOC +) ;; *centos/6*) terminal="/bin/bash" - read -r -d '' commands << EOT - export PATH=$PATH:/bin:/sbin - echo "nameserver $DNS_SERVER" > /etc/resolv.conf - $CURL $CONTEXT_URL/v$selected_tag/one-context-$selected_tag-1.el6.noarch.rpm -Lsfo /root/context.rpm - yum install /root/context.rpm -y > /dev/null 2>&1 -EOT + commands=$(cat < /etc/resolv.conf + +$CURL $CONTEXT_URL/v$selected_tag/one-context-$selected_tag-1.el6.noarch.rpm -Lsfo /root/context.rpm +yum install /root/context.rpm -y > /dev/null 2>&1 +EOC +) ;; *centos/7*) terminal="/bin/bash" - read -r -d '' commands << EOT - echo "nameserver $DNS_SERVER" > /etc/resolv.conf - $CURL $CONTEXT_URL/v$selected_tag/one-context-$selected_tag-1.el7.noarch.rpm -Lsfo /root/context.rpm - yum install /root/context.rpm -y > /dev/null 2>&1 -EOT + commands=$(cat < /etc/resolv.conf + +$CURL $CONTEXT_URL/v$selected_tag/one-context-$selected_tag-1.el7.noarch.rpm -Lsfo /root/context.rpm +yum install /root/context.rpm -y > /dev/null 2>&1 +EOC +) ;; *alpine*) terminal="/bin/ash" - read -r -d '' commands << EOT - echo "nameserver $DNS_SERVER" > /etc/resolv.conf - $CURL $CONTEXT_URL/v$selected_tag/one-context-$selected_tag-r1.apk -Lsfo /root/context.apk - apk add --allow-untrusted /root/context.apk > /dev/null 2>&1 -EOT - ;; -*opensuse*) - terminal="/bin/sh" - read -r -d '' commands << EOT - echo "OpenSuse is not yet supported" > /root/opennebula_context.log -EOT + commands=$(cat < /etc/resolv.conf + +$CURL $CONTEXT_URL/v$selected_tag/one-context-$selected_tag-r1.apk -Lsfo /root/context.apk +apk add --allow-untrusted /root/context.apk > /dev/null 2>&1 +EOC +) ;; *) terminal="/bin/sh" - read -r -d '' commands << EOT - echo "This distro is not supported by OpenNebula context" > /root/opennebula_context.log -EOT + commands=$(cat < /root/opennebula_context.log +EOC +) ;; esac @@ -214,4 +220,3 @@ fi [ -f $output_qcow ] && rm -f $output_qcow > /dev/null 2>&1 exit 0 - diff --git a/src/market_mad/remotes/linuxcontainers/monitor b/src/market_mad/remotes/linuxcontainers/monitor index b331111863..e082bd6b6f 100755 --- a/src/market_mad/remotes/linuxcontainers/monitor +++ b/src/market_mad/remotes/linuxcontainers/monitor @@ -179,8 +179,8 @@ class LinuxContainersMarket # ./20181214_07:42/rootfs.tar.xz?size=5120&filesystem=ext4&format=raw # def app_url(path) - "lxd://#{@options[:url]}#{path}?size=#{@options[:sizemb]}&filesystem=" \ - "#{@options[:fs]}&format=#{@options[:format]}" + "\\\"lxd://#{@options[:url]}#{path}?size=#{@options[:sizemb]}&filesystem=" \ + "#{@options[:fs]}&format=#{@options[:format]}\\\"" end # Print variable in an APP template