getopt must be executed outside of the get_api5_arguments function,
because there $@ will be overridden.
vol_id may return an error on old distributions (dapper) in that case we
just... err... well... ignore the error and forget to set up the swap
partition in fstab?? :)
Reviewed-by: iustinp
fi
get_api5_arguments() {
- TEMP=`getopt -o o:n:i:b:s: -n '$0' -- "$@"`
- if [ $? != 0 ] ; then log_error "Terminating..."; exit 1 ; fi
+ GETOPT_RESULT=$*
# Note the quotes around `$TEMP': they are essential!
- eval set -- "$TEMP"
+ eval set -- "$GETOPT_RESULT"
while true; do
case "$1" in
-i|-n) instance=$2; shift 2;;
if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
OS_API_VERSION=5
- get_api5_arguments
+ GETOPT_RESULT=`getopt -o o:n:i:b:s: -n '$0' -- "$@"`
+ if [ $? != 0 ] ; then log_error "Terminating..."; exit 1 ; fi
+ get_api5_arguments $GETOPT_RESULT
elif [ "$OS_API_VERSION" = "10" ]; then
get_api10_arguments
else
if [ -n "$swapdev" ]; then
mkswap $swapdev
- swap_uuid=$($VOL_ID -u $swapdev )
+ swap_uuid=$($VOL_ID -u $swapdev || true )
fi
TMPDIR=`mktemp -d` || exit 1
proc /proc proc defaults 0 0
EOF
-[ -n "$swapdev" ] && cat >> $TMPDIR/etc/fstab <<EOF
+[ -n "$swapdev" -a -n "$swap_uuid" ] && cat >> $TMPDIR/etc/fstab <<EOF
UUID=$swap_uuid swap swap defaults 0 0
EOF