Follow changes in removal script
This commit is contained in:
parent
9611e4ff9a
commit
df182d5a67
1 changed files with 21 additions and 13 deletions
|
@ -11,7 +11,7 @@ readonly api_url=https://192.168.51.81:8006/api2/json
|
||||||
## now, let us just use `node051` everywhere.
|
## now, let us just use `node051` everywhere.
|
||||||
readonly node=node051
|
readonly node=node051
|
||||||
|
|
||||||
readonly tmpdir=/tmp/proxmox-provision-$RANDOM
|
readonly tmpdir=/tmp/proxmox-remove-$RANDOM
|
||||||
mkdir $tmpdir
|
mkdir $tmpdir
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -23,18 +23,22 @@ vm_ids=
|
||||||
|
|
||||||
help () {
|
help () {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $0 [OPTION...] [ID...]
|
Usage: $0 [OPTION...] ID [ID...]
|
||||||
|
|
||||||
Authentication options:
|
Options:
|
||||||
--username STR Username, with provider (eg. niols@pve)
|
--username STR Username, with provider (eg. niols@pve)
|
||||||
--password STR Password
|
--password STR Password
|
||||||
|
|
||||||
If not provided via the command line, username and password will be looked for
|
|
||||||
in a '.proxmox' file in the current working directory, the username on the
|
|
||||||
first line, and the password on the second.
|
|
||||||
|
|
||||||
Others:
|
|
||||||
-h|-?|--help Show this help and exit
|
-h|-?|--help Show this help and exit
|
||||||
|
|
||||||
|
Options can also be provided by adding assignments to a '.proxmox' file in the
|
||||||
|
current working directory. For instance, it could contain:
|
||||||
|
|
||||||
|
cores=7
|
||||||
|
username=mireille@pve
|
||||||
|
debug=true
|
||||||
|
|
||||||
|
Command line options take precedence over options found in the '.proxmox' file.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +47,10 @@ die () { printf '\033[31m'; printf "$@"; printf '\033[0m\n'; exit 2; }
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
die_with_help () { printf '\033[31m'; printf "$@"; printf '\033[0m\n'; help; exit 2; }
|
die_with_help () { printf '\033[31m'; printf "$@"; printf '\033[0m\n'; help; exit 2; }
|
||||||
|
|
||||||
|
if [ -f .proxmox ]; then
|
||||||
|
. "$PWD"/.proxmox
|
||||||
|
fi
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
argument=$1
|
argument=$1
|
||||||
shift
|
shift
|
||||||
|
@ -58,12 +66,12 @@ while [ $# -gt 0 ]; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ -z "$vm_ids" ]; then
|
||||||
|
die_with_help "Required: at least one VM id.\n"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$username" ] || [ -z "$password" ]; then
|
if [ -z "$username" ] || [ -z "$password" ]; then
|
||||||
if [ -f .proxmox ]; then
|
die_with_help "Required: '--username' and '--password'.\n"
|
||||||
{ read -r username; read -r password; } < .proxmox
|
|
||||||
else
|
|
||||||
die_with_help "Required: '--username' and '--password'.\n"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Add table
Reference in a new issue