diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-10-19 09:45:43 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-10-19 09:45:43 +0000 |
commit | 688d54df37e4ceaec38ca2eeb501680ee26459d1 (patch) | |
tree | fc6dadec8caba48daf1a93793aac927bbff376c6 /main/util-vserver/setup-vs-guest | |
parent | d451866fd59af0b3c653dd94c0ee135b1e2d9ece (diff) | |
download | aports-688d54df37e4ceaec38ca2eeb501680ee26459d1.tar.bz2 aports-688d54df37e4ceaec38ca2eeb501680ee26459d1.tar.xz |
main/util-vserver: upgrade to 0.30.216_pre2994
also add supporrt for creating 32bit guests on x86_64 hosts
Diffstat (limited to 'main/util-vserver/setup-vs-guest')
-rw-r--r-- | main/util-vserver/setup-vs-guest | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/main/util-vserver/setup-vs-guest b/main/util-vserver/setup-vs-guest index 0de3069ba..8a4130669 100644 --- a/main/util-vserver/setup-vs-guest +++ b/main/util-vserver/setup-vs-guest @@ -153,7 +153,7 @@ valid_hostname() { # last_ipv4_addr_mask() { local _iface=$1 - ip addr show dev $_iface | awk '$1 == "inet" {print $2}' | tail -n1 + ip addr show dev $_iface | sort | awk '$1 == "inet" {print $2}' | tail -n1 } valid_ip_and_prefix() { @@ -235,8 +235,19 @@ ask_context() { done } +ask_guest_arch() { + # get guest arch + while true; do + ask "Enter guest machine architecture (i686 or x86_64):" $_arch + case "$resp" in + i[3-6]86|x86_64) break;; + esac + echo "Only i[3-6]86 and x86_64 is supported" + done +} + ask_template() { - local temp + local temp= apk_arch= arch_opt= # get template while true; do ask "Enter template file (or empty for generate a new):" \ @@ -246,11 +257,18 @@ ask_template() { fi echo "Can not read $resp" done + if [ "$_guest_arch" != "$_arch" ]; then + case "$_guest_arch" in + i?86) apk_arch=x86;; + *) apk_arch=$_guest_arch;; + esac + arch_opt="-a $apk_arch" + fi temp=$resp if [ -z "$temp" ]; then - temp=/vservers/template.tar.gz + temp=/vservers/template-$_guest_arch.tar.gz echo "Generating template..." - if setup-vs-template -q -o $temp; then + if setup-vs-template $arch_opt -q -o $temp; then echo "ok" else echo "Failed to create template" @@ -265,6 +283,8 @@ usage() { exit 1 } +_arch="$(uname -m)" + while getopts "h" opt; do case "$opt" in h) usage;; @@ -289,6 +309,11 @@ while true; do ask_context _context=$resp + if [ "$_arch" = "x86_64" ]; then + ask_guest_arch + _guest_arch=$resp + fi + ask_template _template=$resp @@ -296,10 +321,15 @@ while true; do --hostname $_hostname \ $_ifaceopts \ --context $_context \ + $arch_opt \ -m template -- -t "$_template" -d alpine \ && cp /etc/resolv.conf /vservers/$_hostname/etc/ \ && cp /etc/apk/repositories /vservers/$_hostname/etc/apk/ \ || exit 1 + if [ "$_arch" != "$_guest_arch" ]; then + echo "linux_32bit" >> /etc/vservers/$_hostname/personality + echo "$_guest_arch" > /etc/vservers/$_hostname/uts/machine + fi shift [ $# -le 0 ] && exit 0 |