optarg_check $opt "$1"
arch=$1
shift
- ;;
+ ;;
--)
break;;
--*=*)
apk_arch=$arch
case "$arch" in
- i[3-6]86)
- apk_arch=x86;;
- x86)
- lxc_arch=i686;;
- x86_64|"") ;;
- *) die "unsupported architecture: $arch";;
+ i[3-6]86)
+ apk_arch=x86
+ ;;
+ x86)
+ lxc_arch=i686
+ ;;
+ x86_64|"")
+ ;;
+ *)
+ die "unsupported architecture: $arch"
+ ;;
esac
: ${APK:=apk}
echo "Checking cache download in $cache/rootfs ... "
if [ ! -e "$cache/rootfs" ]; then
- echo $cache/rootfs
+ echo $cache/rootfs
create_chroot_openmandriva
if [ $? -ne 0 ]; then
echo "Failed to download 'openmandriva basesystem-minimal'"
if [ "$DISTRIB_ID" = "OpenMandrivaLinux" ]; then
release=openmandriva2013.0
elif [ "$DISTRIB_ID" = "RosaDesktop.Fresh" ]; then
- release=rosa2012.1
+ release=rosa2012.1
else
- echo "This is not an OpenMandriva or ROSA release"
+ echo "This is not an OpenMandriva or ROSA release"
exit 1
fi
fi
-P|--profile) profile=$2; shift 2;;
-c|--clean) clean=$2; shift 2;;
-R|--release) release=$2; shift 2;;
- -a|--arch) arch=$2; shift 2;;
+ -a|--arch) arch=$2; shift 2;;
-4|--ipv4) ipv4=$2; shift 2;;
-6|--ipv6) ipv6=$2; shift 2;;
-g|--gw) gw=$2; shift 2;;
name=$3
if grep -q "^lxc.network.type" $path/config; then
- TYPE=$(sed '/^#/d; /lxc.network.type/!d; s/.*=[ \t]*//' $path/config)
- grep -q "^lxc.network.ipv4" $path/config
- IPV4_NOT_CONFIGURED=$?
-
- if [ ! grep -q "^lxc.network.*.gateway" $path/config ]; then
- [ $IPV4_NOT_CONFIGURED -eq 0 ] && IPV4=$(sed '/^#/d; /lxc.network.ipv4/!d; /gateway/d; s/.*=[ \t]*//; s/\([[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\).*/\1/' $path/config)
- if [ "$TYPE" = "veth" -o "$TYPE" = "macvlan" ]; then
- if [ $IPV4_NOT_CONFIGURED -eq 0 -a "$IPV4" != "0.0.0.0" ]; then
- # set default route
- IP=$(/sbin/ip route | awk '/default/ { print $3 }')
- echo "lxc.network.ipv4.gateway = $IP " >> $path/config
- else
- # set network as dhcp
- sed -i -e 's/BOOTPROTO=.*/BOOTPROTO=dhcp/' $rootfs/etc/sysconfig/network/ifcfg-eth0
- fi
- fi
- fi
- if [ "$TYPE" != "empty" ]; then
- echo "#remove next line if host DNS configuration should not be available to container" >> $path/config
- echo "lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro 0 0" >> $path/config
- fi
+ TYPE=$(sed '/^#/d; /lxc.network.type/!d; s/.*=[ \t]*//' $path/config)
+ grep -q "^lxc.network.ipv4" $path/config
+ IPV4_NOT_CONFIGURED=$?
+
+ if [ ! grep -q "^lxc.network.*.gateway" $path/config ]; then
+ [ $IPV4_NOT_CONFIGURED -eq 0 ] && IPV4=$(sed '/^#/d; /lxc.network.ipv4/!d; /gateway/d; s/.*=[ \t]*//; s/\([[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\).*/\1/' $path/config)
+ if [ "$TYPE" = "veth" -o "$TYPE" = "macvlan" ]; then
+ if [ $IPV4_NOT_CONFIGURED -eq 0 -a "$IPV4" != "0.0.0.0" ]; then
+ # set default route
+ IP=$(/sbin/ip route | awk '/default/ { print $3 }')
+ echo "lxc.network.ipv4.gateway = $IP " >> $path/config
+ else
+ # set network as dhcp
+ sed -i -e 's/BOOTPROTO=.*/BOOTPROTO=dhcp/' $rootfs/etc/sysconfig/network/ifcfg-eth0
+ fi
+ fi
+ fi
+ if [ "$TYPE" != "empty" ]; then
+ echo "#remove next line if host DNS configuration should not be available to container" >> $path/config
+ echo "lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro 0 0" >> $path/config
+ fi
else
- echo 'lxc.network.type = empty' >> $path/config
+ echo 'lxc.network.type = empty' >> $path/config
fi
grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config
if [ -e $container_rootfs/etc/selinux/config ]; then
sed -i 's|SELINUX=enforcing|SELINUX=disabled|' $container_rootfs/etc/selinux/config
else
- mkdir -p $container_rootfs/etc/selinux
+ mkdir -p $container_rootfs/etc/selinux
echo "SELINUX=disabled" >$container_rootfs/etc/selinux/config
fi
sed -i 's|session[ \t]*required[ \t]*pam_selinux.so[ \t]*close|#session required pam_selinux.so close|' $container_rootfs/etc/pam.d/login
EOF
ifconfig eth0 up
dhclient eth0 -cf /dhclient.conf
- echo "Container IP address:"
+ echo "Container IP address:"
ifconfig eth0 |grep inet
fi
"$CLONE_HOOK_FN" "${cloneargs[@]}" "$rootfs"
if [ $mapped_uid -ne -1 ]; then
- chown $mapped_uid $path/config
- chown -R $mapped_uid $STATE_DIR
- chown -R $mapped_uid $cache
+ chown $mapped_uid $path/config
+ chown -R $mapped_uid $STATE_DIR
+ chown -R $mapped_uid $cache
fi
echo "Container $name created."