From 775ee4259e2967975bce30c9ec5f8ea4c63cd63b Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 6 Jun 2016 18:27:49 +0200 Subject: [PATCH 1/3] Integrate fixes from @ehlers --- gns3server/modules/docker/resources/init.sh | 33 +++++++++------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/gns3server/modules/docker/resources/init.sh b/gns3server/modules/docker/resources/init.sh index 9ce22515..4f8d3304 100755 --- a/gns3server/modules/docker/resources/init.sh +++ b/gns3server/modules/docker/resources/init.sh @@ -24,20 +24,15 @@ PATH=/gns3/bin:/tmp/gns3/bin # bootstrap busybox commands if [ ! -d /tmp/gns3/bin ]; then - busybox mkdir -p /tmp/gns3/bin - /gns3/bin/busybox --install -s /tmp/gns3/bin + busybox mkdir -p /tmp/gns3/bin + /gns3/bin/busybox --install -s /tmp/gns3/bin fi # Restore file permission and mount volumes -for i in $(echo "$GNS3_VOLUMES" | tr ":" "\n") +echo "$GNS3_VOLUMES" | tr ":" "\n" | while read i do # Copy original files if destination is empty (first start) - if ! [ "$(ls -A /gns3volumes$i)" ]; then - for file in $(ls -A "$i") - do - cp -a "$i/$file" "/gns3volumes$i/$file" - done - fi + [ "$(ls -A "/gns3volumes$i")" ] || cp -a "$i/." "/gns3volumes$i" mount --bind "/gns3volumes$i" "$i" if [ -f "$i/.gns3_perms" ] @@ -53,28 +48,28 @@ done # /etc/hosts [ -s /etc/hosts ] || cat > /etc/hosts << __EOF__ -127.0.1.1 $HOSTNAME -127.0.0.1 localhost -::1 localhost ip6-localhost ip6-loopback -fe00::0 ip6-localnet -ff00::0 ip6-mcastprefix -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters +127.0.1.1 $HOSTNAME +127.0.0.1 localhost +::1 localhost ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters __EOF__ # configure loopback interface ip link set dev lo up # Wait for all eth available -while true +while true do grep $GNS3_MAX_ETHERNET /proc/net/dev > /dev/null && break sleep 0.5 -done +done # activate eth interfaces sed -n 's/^ *\(eth[0-9]*\):.*/\1/p' < /proc/net/dev | while read dev; do - ip link set dev $dev up + ip link set dev $dev up done # configure network interfaces From c829a250a93b72b865d115e7326f3a4d236f159e Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 7 Jun 2016 09:26:27 +0200 Subject: [PATCH 2/3] Revert "Integrate fixes from @ehlers" This reverts commit 775ee4259e2967975bce30c9ec5f8ea4c63cd63b. --- gns3server/modules/docker/resources/init.sh | 33 ++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/gns3server/modules/docker/resources/init.sh b/gns3server/modules/docker/resources/init.sh index 4f8d3304..9ce22515 100755 --- a/gns3server/modules/docker/resources/init.sh +++ b/gns3server/modules/docker/resources/init.sh @@ -24,15 +24,20 @@ PATH=/gns3/bin:/tmp/gns3/bin # bootstrap busybox commands if [ ! -d /tmp/gns3/bin ]; then - busybox mkdir -p /tmp/gns3/bin - /gns3/bin/busybox --install -s /tmp/gns3/bin + busybox mkdir -p /tmp/gns3/bin + /gns3/bin/busybox --install -s /tmp/gns3/bin fi # Restore file permission and mount volumes -echo "$GNS3_VOLUMES" | tr ":" "\n" | while read i +for i in $(echo "$GNS3_VOLUMES" | tr ":" "\n") do # Copy original files if destination is empty (first start) - [ "$(ls -A "/gns3volumes$i")" ] || cp -a "$i/." "/gns3volumes$i" + if ! [ "$(ls -A /gns3volumes$i)" ]; then + for file in $(ls -A "$i") + do + cp -a "$i/$file" "/gns3volumes$i/$file" + done + fi mount --bind "/gns3volumes$i" "$i" if [ -f "$i/.gns3_perms" ] @@ -48,28 +53,28 @@ done # /etc/hosts [ -s /etc/hosts ] || cat > /etc/hosts << __EOF__ -127.0.1.1 $HOSTNAME -127.0.0.1 localhost -::1 localhost ip6-localhost ip6-loopback -fe00::0 ip6-localnet -ff00::0 ip6-mcastprefix -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters +127.0.1.1 $HOSTNAME +127.0.0.1 localhost +::1 localhost ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters __EOF__ # configure loopback interface ip link set dev lo up # Wait for all eth available -while true +while true do grep $GNS3_MAX_ETHERNET /proc/net/dev > /dev/null && break sleep 0.5 -done +done # activate eth interfaces sed -n 's/^ *\(eth[0-9]*\):.*/\1/p' < /proc/net/dev | while read dev; do - ip link set dev $dev up + ip link set dev $dev up done # configure network interfaces From df7d26e4181a16484f27adcdcd67b15f489b662a Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 7 Jun 2016 09:27:37 +0200 Subject: [PATCH 3/3] Fix for copy VOLUMES by @ehlers --- gns3server/modules/docker/resources/init.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/gns3server/modules/docker/resources/init.sh b/gns3server/modules/docker/resources/init.sh index 9ce22515..43f31685 100755 --- a/gns3server/modules/docker/resources/init.sh +++ b/gns3server/modules/docker/resources/init.sh @@ -29,15 +29,10 @@ if [ ! -d /tmp/gns3/bin ]; then fi # Restore file permission and mount volumes -for i in $(echo "$GNS3_VOLUMES" | tr ":" "\n") +echo "$GNS3_VOLUMES" | tr ":" "\n" | while read i do # Copy original files if destination is empty (first start) - if ! [ "$(ls -A /gns3volumes$i)" ]; then - for file in $(ls -A "$i") - do - cp -a "$i/$file" "/gns3volumes$i/$file" - done - fi + [ "$(ls -A "/gns3volumes$i")" ] || cp -a "$i/." "/gns3volumes$i" mount --bind "/gns3volumes$i" "$i" if [ -f "$i/.gns3_perms" ]