[lxc-devel] [PATCH] templates: improve option parsing
TAMUKI Shoichi
tamuki at linet.gr.jp
Thu Feb 6 08:33:48 UTC 2014
Long options may be abbreviated, as long as the abbreviation is not
ambiguous. Previously, if abbreviated options are specified, the
parsing will succeed but do nothing. The option handling behaves
properly now.
Also, changed the file mode of lxc-archlinux.in 100755 to 100644.
Signed-off-by: TAMUKI Shoichi <tamuki at linet.gr.jp>
---
templates/lxc-alpine.in | 5 +++--
templates/lxc-altlinux.in | 31 ++++++++++++++++---------------
templates/lxc-archlinux.in | 27 ++++++++++++++-------------
templates/lxc-busybox.in | 17 +++++++++--------
templates/lxc-centos.in | 23 ++++++++++++-----------
templates/lxc-cirros.in | 27 ++++++++++++++-------------
templates/lxc-debian.in | 23 ++++++++++++-----------
templates/lxc-download.in | 34 +++++++++++++++++-----------------
templates/lxc-fedora.in | 25 +++++++++++++------------
templates/lxc-gentoo.in | 41 +++++++++++++++++++++--------------------
templates/lxc-openmandriva.in | 33 +++++++++++++++++----------------
templates/lxc-opensuse.in | 19 ++++++++++---------
templates/lxc-oracle.in | 27 ++++++++++++++-------------
templates/lxc-plamo.in | 21 +++++++++++----------
templates/lxc-sshd.in | 19 ++++++++++---------
templates/lxc-ubuntu-cloud.in | 38 +++++++++++++++++++-------------------
templates/lxc-ubuntu.in | 39 ++++++++++++++++++++-------------------
17 files changed, 232 insertions(+), 217 deletions(-)
mode change 100755 => 100644 templates/lxc-archlinux.in
diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in
index 232f54b..d1ae9f3 100644
--- a/templates/lxc-alpine.in
+++ b/templates/lxc-alpine.in
@@ -1,8 +1,9 @@
#!/bin/bash
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
diff --git a/templates/lxc-altlinux.in b/templates/lxc-altlinux.in
index 385465c..4cbe392 100644
--- a/templates/lxc-altlinux.in
+++ b/templates/lxc-altlinux.in
@@ -25,8 +25,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -378,19 +379,19 @@ eval set -- "$options"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) path=$2; shift 2;;
- --rootfs) rootfs_path=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -P|--profile) profile=$2; shift 2;;
- -c|--clean) clean=$2; shift 2;;
- -R|--release) release=$2; shift 2;;
- -4|--ipv4) ipv4=$2; shift 2;;
- -6|--ipv6) ipv6=$2; shift 2;;
- -g|--gw) gw=$2; shift 2;;
- -d|--dns) dns=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 0;;
+ -p|--pa*) path=$2; shift 2;;
+ --ro*) rootfs_path=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -P|--pr*) profile=$2; shift 2;;
+ -c|--c*) clean=$2; shift 2;;
+ -R|--re*) release=$2; shift 2;;
+ -4|--ipv4) ipv4=$2; shift 2;;
+ -6|--ipv6) ipv6=$2; shift 2;;
+ -g|--g*) gw=$2; shift 2;;
+ -d|--d*) dns=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-archlinux.in b/templates/lxc-archlinux.in
old mode 100755
new mode 100644
index d394816..6bebcc0
--- a/templates/lxc-archlinux.in
+++ b/templates/lxc-archlinux.in
@@ -26,8 +26,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -235,17 +236,17 @@ eval set -- "${options}"
while true
do
case "${1}" in
- -h|--help) usage ${0} && exit 0;;
- -p|--path) path=${2}; shift 2;;
- -n|--name) name=${2}; shift 2;;
- --rootfs) rootfs_path=${2}; shift 2;;
- -P|--packages) additional_packages=${2}; shift 2;;
- -e|--enable_units) enable_units=${2}; shift 2;;
- -c|--config) pacman_config=${2}; shift 2;;
- -a|--arch) arch=${2}; shift 2;;
- -t|--network_type) lxc_network_type=${2}; shift 2;;
- -l|--network_link) lxc_network_link=${2}; shift 2;;
- -r|--root_passwd) root_passwd=${2}; shift 2;;
+ -h|--h*) usage ${0} && exit 0;;
+ -p|--pat*) path=${2}; shift 2;;
+ -n|--na*) name=${2}; shift 2;;
+ --rootf*) rootfs_path=${2}; shift 2;;
+ -P|--pac*) additional_packages=${2}; shift 2;;
+ -e|--e*) enable_units=${2}; shift 2;;
+ -c|--c*) pacman_config=${2}; shift 2;;
+ -a|--a*) arch=${2}; shift 2;;
+ -t|--network_t*) lxc_network_type=${2}; shift 2;;
+ -l|--network_l*) lxc_network_link=${2}; shift 2;;
+ -r|--root_*) root_passwd=${2}; shift 2;;
--) shift 1; break ;;
*) break ;;
esac
diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
index f4aa6c4..a422454 100644
--- a/templates/lxc-busybox.in
+++ b/templates/lxc-busybox.in
@@ -21,8 +21,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -324,12 +325,12 @@ eval set -- "$options"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) path=$2; shift 2;;
- --rootfs) rootfs=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 0;;
+ -p|--p*) path=$2; shift 2;;
+ --r*) rootfs=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-centos.in b/templates/lxc-centos.in
index 1fce0e3..0e57023 100644
--- a/templates/lxc-centos.in
+++ b/templates/lxc-centos.in
@@ -73,8 +73,9 @@ lxc_network_link=lxcbr0
# should be able to use EITHER. Give preference to /etc/os-release for now.
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -650,15 +651,15 @@ eval set -- "$options"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) path=$2; shift 2;;
- --rootfs) rootfs=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -c|--clean) clean=$2; shift 2;;
- -R|--release) release=$2; shift 2;;
- --repo) repo="$2"; shift 2;;
- -a|--arch) newarch=$2; shift 2;;
- --fqdn) utsname=$2; shift 2;;
+ -h|--h*) usage $0 && exit 0;;
+ -p|--p*) path=$2; shift 2;;
+ --ro*) rootfs=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -c|--c*) clean=$2; shift 2;;
+ -R|--rel*) release=$2; shift 2;;
+ --rep*) repo="$2"; shift 2;;
+ -a|--a*) newarch=$2; shift 2;;
+ --f*) utsname=$2; shift 2;;
--) shift 1; break ;;
*) break ;;
esac
diff --git a/templates/lxc-cirros.in b/templates/lxc-cirros.in
index 519013f..b15e049 100644
--- a/templates/lxc-cirros.in
+++ b/templates/lxc-cirros.in
@@ -22,8 +22,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -229,17 +230,17 @@ create_main() {
while [ $# -ne 0 ]; do
cur=$1; next=$2;
case "$cur" in
- -a|--arch) arch="$next"; shift;;
- -h|--help) Usage ; return 0;;
- -n|--name) name="$next"; shift;;
- -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
- -S|--auth-key) authkey_f="$next"; shift;;
- -p|--path) path=$next; shift;;
- -v|--version) version=$next; shift;;
- -u|--userdata) userdata_f="$next"; shift;;
- --tarball) tarball="$next"; shift;;
- --source) dsource="$next"; shift;;
- --rootfs) rootfs_d="$next"; shift;;
+ -a|--ar*) arch="$next"; shift;;
+ -h|--h*) Usage ; return 0;;
+ -n|--n*) name="$next"; shift;;
+ -v|--verb*) VERBOSITY=$((${VERBOSITY}+1));;
+ -S|--au*) authkey_f="$next"; shift;;
+ -p|--p*) path=$next; shift;;
+ -v|--vers*) version=$next; shift;;
+ -u|--u*) userdata_f="$next"; shift;;
+ --t*) tarball="$next"; shift;;
+ --s*) dsource="$next"; shift;;
+ --r*) rootfs_d="$next"; shift;;
--) shift; break;;
esac
shift;
diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index 376e30d..da7d720 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -21,8 +21,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -351,15 +352,15 @@ hostarch=$arch
while true
do
case "$1" in
- -h|--help) usage $0 && exit 1;;
- -p|--path) path=$2; shift 2;;
- --rootfs) rootfs=$2; shift 2;;
- -a|--arch) arch=$2; shift 2;;
- -r|--release) release=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -c|--clean) clean=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 1;;
+ -p|--p*) path=$2; shift 2;;
+ --ro*) rootfs=$2; shift 2;;
+ -a|--a*) arch=$2; shift 2;;
+ -r|--re*) release=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -c|--c*) clean=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-download.in b/templates/lxc-download.in
index 2a6e51d..e0bda3a 100644
--- a/templates/lxc-download.in
+++ b/templates/lxc-download.in
@@ -194,23 +194,23 @@ eval set -- "$options"
while :; do
case "$1" in
- -h|--help) usage && exit 1;;
- -l|--list) DOWNLOAD_LIST_IMAGES="true"; shift 1;;
- -d|--dist) DOWNLOAD_DIST=$2; shift 2;;
- -r|--release) DOWNLOAD_RELEASE=$2; shift 2;;
- -a|--arch) DOWNLOAD_ARCH=$2; shift 2;;
- --variant) DOWNLOAD_VARIANT=$2; shift 2;;
- --server) DOWNLOAD_SERVER=$2; shift 2;;
- --keyid) DOWNLOAD_KEYID=$2; shift 2;;
- --no-validate) DOWNLOAD_VALIDATE="false"; shift 1;;
- --flush-cache) DOWNLOAD_FLUSH_CACHE="true"; shift 1;;
- --force-cache) DOWNLOAD_FORCE_CACHE="true"; shift 1;;
- --name) LXC_NAME=$2; shift 2;;
- --path) LXC_PATH=$2; shift 2;;
- --rootfs) LXC_ROOTFS=$2; shift 2;;
- --mapped-uid) LXC_MAPPED_UID=$2; shift 2;;
- --mapped-gid) LXC_MAPPED_GID=$2; shift 2;;
- *) break;;
+ -h|--h*) usage && exit 1;;
+ -l|--l*) DOWNLOAD_LIST_IMAGES="true"; shift 1;;
+ -d|--d*) DOWNLOAD_DIST=$2; shift 2;;
+ -r|--re*) DOWNLOAD_RELEASE=$2; shift 2;;
+ -a|--a*) DOWNLOAD_ARCH=$2; shift 2;;
+ --v*) DOWNLOAD_VARIANT=$2; shift 2;;
+ --s*) DOWNLOAD_SERVER=$2; shift 2;;
+ --k*) DOWNLOAD_KEYID=$2; shift 2;;
+ --no*) DOWNLOAD_VALIDATE="false"; shift 1;;
+ --fl*) DOWNLOAD_FLUSH_CACHE="true"; shift 1;;
+ --fo*) DOWNLOAD_FORCE_CACHE="true"; shift 1;;
+ --na*) LXC_NAME=$2; shift 2;;
+ --p*) LXC_PATH=$2; shift 2;;
+ --ro*) LXC_ROOTFS=$2; shift 2;;
+ --mapped-u*) LXC_MAPPED_UID=$2; shift 2;;
+ --mapped-g*) LXC_MAPPED_GID=$2; shift 2;;
+ *) break;;
esac
done
diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index b8a2339..bb1b7eb 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -73,8 +73,9 @@ lxc_network_link=lxcbr0
# should be able to use EITHER. Give preference to /etc/os-release for now.
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -1130,16 +1131,16 @@ eval set -- "$options"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) path=$2; shift 2;;
- --rootfs) rootfs=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -c|--clean) clean=$2; shift 2;;
- -R|--release) release=$2; shift 2;;
- -a|--arch) newarch=$2; shift 2;;
- --fqdn) utsname=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 0;;
+ -p|--p*) path=$2; shift 2;;
+ --ro*) rootfs=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -c|--c*) clean=$2; shift 2;;
+ -R|--re*) release=$2; shift 2;;
+ -a|--a*) newarch=$2; shift 2;;
+ --f*) utsname=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-gentoo.in b/templates/lxc-gentoo.in
index ae67898..d9bbe4e 100644
--- a/templates/lxc-gentoo.in
+++ b/templates/lxc-gentoo.in
@@ -14,8 +14,9 @@
#
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -746,24 +747,24 @@ eval set -- "$options"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- --rootfs) rootfs=$2; shift 2;;
- -p|--path) path=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -a|--arch) arch=$2; shift 2;;
- -F|--flush-cache) flush_cache=1; shift 1;;
- -c|--cache-only) cache_only=1; shitf 1;;
- -P|--private-portage) private_portage=1; shift 1;;
- -v|--variant) variant=$2; shift 2;;
- --portage-dir) portage_dir=$2; shift 2;;
- -t|--tarball) tarball=$2; shift 2;;
- -S|--auth-key) auth_key=$2; shift 2;;
- -u|--user) user=$2; shift 2;;
- -w|--password) forced_password=1; password=$2; shift 2;;
- -s|--settings) settings=$2; shift 2;;
- -m|--mirror) mirror=$2; shift 2;;
- --tty) [[ $2 -lt 6 ]] && tty=$2; shift 2;;
- --autologin) autologin=1; shift 1;;
+ -h|--h*) usage $0 && exit 0;;
+ --r*) rootfs=$2; shift 2;;
+ -p|--pat*) path=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -a|--ar*) arch=$2; shift 2;;
+ -F|--f*) flush_cache=1; shift 1;;
+ -c|--c*) cache_only=1; shitf 1;;
+ -P|--pr*) private_portage=1; shift 1;;
+ -v|--v*) variant=$2; shift 2;;
+ --po*) portage_dir=$2; shift 2;;
+ -t|--ta*) tarball=$2; shift 2;;
+ -S|--auth*) auth_key=$2; shift 2;;
+ -u|--u*) user=$2; shift 2;;
+ -w|--pas*) forced_password=1; password=$2; shift 2;;
+ -s|--s*) settings=$2; shift 2;;
+ -m|--m*) mirror=$2; shift 2;;
+ --tt*) [[ $2 -lt 6 ]] && tty=$2; shift 2;;
+ --auto*) autologin=1; shift 1;;
--) shift 1; break ;;
*) break ;;
esac
diff --git a/templates/lxc-openmandriva.in b/templates/lxc-openmandriva.in
index e5d2b1c..d701e77 100644
--- a/templates/lxc-openmandriva.in
+++ b/templates/lxc-openmandriva.in
@@ -27,8 +27,9 @@
#
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -368,20 +369,20 @@ fi
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) path=$2; shift 2;;
- --rootfs) rootfs_path=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -P|--profile) profile=$2; shift 2;;
- -c|--clean) clean=$2; shift 2;;
- -R|--release) release=$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;;
- -d|--dns) dns=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 0;;
+ -p|--pa*) path=$2; shift 2;;
+ --ro*) rootfs_path=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -P|--pr*) profile=$2; shift 2;;
+ -c|--c*) clean=$2; shift 2;;
+ -R|--re*) release=$2; shift 2;;
+ -a|--a*) arch=$2; shift 2;;
+ -4|--ipv4) ipv4=$2; shift 2;;
+ -6|--ipv6) ipv6=$2; shift 2;;
+ -g|--g*) gw=$2; shift 2;;
+ -d|--d*) dns=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-opensuse.in b/templates/lxc-opensuse.in
index fb21864..af6d734 100644
--- a/templates/lxc-opensuse.in
+++ b/templates/lxc-opensuse.in
@@ -26,8 +26,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -364,13 +365,13 @@ eval set -- "$options"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) path=$2; shift 2;;
- --rootfs) rootfs=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -c|--clean) clean=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 0;;
+ -p|--p*) path=$2; shift 2;;
+ --r*) rootfs=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -c|--c*) clean=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-oracle.in b/templates/lxc-oracle.in
index c114ad8..15e7905 100644
--- a/templates/lxc-oracle.in
+++ b/templates/lxc-oracle.in
@@ -28,8 +28,9 @@
#
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -645,17 +646,17 @@ eval set -- "$options"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) cfg_dir=$2; shift 2;;
- --rootfs) container_rootfs=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -a|--arch) arch=$2; shift 2;;
- -R|--release) container_release_version=$2; shift 2;;
- -r|--rpms) user_pkgs=$2; shift 2;;
- -u|--url) repourl=$2; shift 2;;
- -t|--templatefs) template_rootfs=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 0;;
+ -p|--p*) cfg_dir=$2; shift 2;;
+ --ro*) container_rootfs=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -a|--a*) arch=$2; shift 2;;
+ -R|--re*) container_release_version=$2; shift 2;;
+ -r|--rp*) user_pkgs=$2; shift 2;;
+ -u|--u*) repourl=$2; shift 2;;
+ -t|--t*) template_rootfs=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-plamo.in b/templates/lxc-plamo.in
index e9f681e..55dd1e7 100644
--- a/templates/lxc-plamo.in
+++ b/templates/lxc-plamo.in
@@ -29,8 +29,9 @@
# lxc-ubuntu script
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -318,14 +319,14 @@ fi
eval set -- "$options"
while true ; do
case "$1" in
- -h|--help) usage && exit 0 ;;
- -p|--path) path=$2 ; shift 2 ;;
- -n|--name) name=$2 ; shift 2 ;;
- --rootfs) rootfs=$2 ; shift 2 ;;
- -c|--clean) clean=1 ; shift 1 ;;
- -r|--release) release=$2 ; shift 2 ;;
- -b|--bindhome) bindhome=$2 ; shift 2 ;;
- -a|--arch) arch=$2 ; shift 2 ;;
+ -h|--h*) usage && exit 0 ;;
+ -p|--p*) path=$2 ; shift 2 ;;
+ -n|--n*) name=$2 ; shift 2 ;;
+ --ro*) rootfs=$2 ; shift 2 ;;
+ -c|--c*) clean=1 ; shift 1 ;;
+ -r|--re*) release=$2 ; shift 2 ;;
+ -b|--b*) bindhome=$2 ; shift 2 ;;
+ -a|--a*) arch=$2 ; shift 2 ;;
--) shift 1 ; break ;;
*) break ;;
esac
diff --git a/templates/lxc-sshd.in b/templates/lxc-sshd.in
index 397a388..276e087 100644
--- a/templates/lxc-sshd.in
+++ b/templates/lxc-sshd.in
@@ -21,8 +21,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -196,13 +197,13 @@ eval set -- "$options"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) path=$2; shift 2;;
- --rootfs) rootfs=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -S|--auth-key) auth_key=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 0;;
+ -p|--p*) path=$2; shift 2;;
+ --r*) rootfs=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -S|--a*) auth_key=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in
index 07cb87d..cb17bd8 100644
--- a/templates/lxc-ubuntu-cloud.in
+++ b/templates/lxc-ubuntu-cloud.in
@@ -201,25 +201,25 @@ cloneargs=()
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- -p|--path) path=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -F|--flush-cache) flushcache=1; shift 1;;
- -r|--release) release=$2; shift 2;;
- -a|--arch) arch=$2; shift 2;;
- -T|--tarball) tarball=$2; shift 2;;
- -d|--debug) debug=1; shift 1;;
- -s|--stream) stream=$2; shift 2;;
- --rootfs) rootfs=$2; shift 2;;
- -L|--no?locales) cloneargs[${#cloneargs[@]}]="--no-locales"; shift 1;;
- -i|--hostid) cloneargs[${#cloneargs[@]}]="--hostid=$2"; shift 2;;
- -u|--userdata) cloneargs[${#cloneargs[@]}]="--userdata=$2"; shift 2;;
- -C|--cloud) cloneargs[${#cloneargs[@]}]="--cloud"; shift 1;;
- -S|--auth-key) cloneargs[${#cloneargs[@]}]="--auth-key=$2"; shift 2;;
- --mapped-uid) mapped_uid=$2; shift 2;;
- --mapped-gid) mapped_gid=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--he*) usage $0 && exit 0;;
+ -p|--p*) path=$2; shift 2;;
+ -n|--na*) name=$2; shift 2;;
+ -F|--f*) flushcache=1; shift 1;;
+ -r|--re*) release=$2; shift 2;;
+ -a|--ar*) arch=$2; shift 2;;
+ -T|--t*) tarball=$2; shift 2;;
+ -d|--d*) debug=1; shift 1;;
+ -s|--s*) stream=$2; shift 2;;
+ --ro*) rootfs=$2; shift 2;;
+ -L|--no*) cloneargs[${#cloneargs[@]}]="--no-locales"; shift 1;;
+ -i|--ho*) cloneargs[${#cloneargs[@]}]="--hostid=$2"; shift 2;;
+ -u|--u*) cloneargs[${#cloneargs[@]}]="--userdata=$2"; shift 2;;
+ -C|--c*) cloneargs[${#cloneargs[@]}]="--cloud"; shift 1;;
+ -S|--au*) cloneargs[${#cloneargs[@]}]="--auth-key=$2"; shift 2;;
+ --mapped-u*) mapped_uid=$2; shift 2;;
+ --mapped-g*) mapped_gid=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in
index b7f9777..4245529 100644
--- a/templates/lxc-ubuntu.in
+++ b/templates/lxc-ubuntu.in
@@ -25,8 +25,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Detect use under userns (unsupported)
-for arg in $*; do
- if [ "$arg" == "--mapped-uid" ]; then
+for arg in "$@"; do
+ [ "$arg" == "--" ] && break
+ if [ "$arg" == "--mapped-uid" -o "$arg" == "--mapped-gid" ]; then
echo "This template can't be used for unprivileged containers." 1>&2
echo "You may want to try the \"download\" template instead." 1>&2
exit 1
@@ -683,23 +684,23 @@ password="ubuntu"
while true
do
case "$1" in
- -h|--help) usage $0 && exit 0;;
- --rootfs) rootfs=$2; shift 2;;
- -p|--path) path=$2; shift 2;;
- -n|--name) name=$2; shift 2;;
- -u|--user) user=$2; shift 2;;
- --password) password=$2; shift 2;;
- -F|--flush-cache) flushcache=1; shift 1;;
- -r|--release) release=$2; shift 2;;
- --packages) packages=$2; shift 2;;
- -b|--bindhome) bindhome=$2; shift 2;;
- -a|--arch) arch=$2; shift 2;;
- -S|--auth-key) auth_key=$2; shift 2;;
- -d|--debug) debug=1; shift 1;;
- --mirror) MIRROR=$2; shift 2;;
- --security-mirror) SECURITY_MIRROR=$2; shift 2;;
- --) shift 1; break ;;
- *) break ;;
+ -h|--h*) usage $0 && exit 0;;
+ --ro*) rootfs=$2; shift 2;;
+ -p|--pat*) path=$2; shift 2;;
+ -n|--n*) name=$2; shift 2;;
+ -u|--u*) user=$2; shift 2;;
+ --pas*) password=$2; shift 2;;
+ -F|--f*) flushcache=1; shift 1;;
+ -r|--re*) release=$2; shift 2;;
+ --pac*) packages=$2; shift 2;;
+ -b|--b*) bindhome=$2; shift 2;;
+ -a|--ar*) arch=$2; shift 2;;
+ -S|--au*) auth_key=$2; shift 2;;
+ -d|--d*) debug=1; shift 1;;
+ --m*) MIRROR=$2; shift 2;;
+ --s*) SECURITY_MIRROR=$2; shift 2;;
+ --) shift 1; break ;;
+ *) break ;;
esac
done
--
1.8.4.4
More information about the lxc-devel
mailing list