forked from Fediversity/Fediversity
Support more configuration in the .proxmox
file
This commit is contained in:
parent
a7c6ceb111
commit
9611e4ff9a
1 changed files with 24 additions and 17 deletions
|
@ -28,24 +28,27 @@ debug=false
|
|||
|
||||
help () {
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTION...] [ID...]
|
||||
Usage: $0 [OPTION...] ID [ID...]
|
||||
|
||||
Authentication options:
|
||||
--username STR Username, with provider (eg. niols@pve)
|
||||
--password STR Password
|
||||
Options:
|
||||
--username STR Username, with provider (eg. niols@pve; required)
|
||||
--password STR Password (required)
|
||||
|
||||
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.
|
||||
|
||||
Other options:
|
||||
--sockets INT Number of sockets (default: $sockets)
|
||||
--cores INT Number of cores (default: $cores)
|
||||
--memory INT Memory (default: $memory)
|
||||
--debug Run this script in debug mode
|
||||
--sockets INT Number of sockets (default: $sockets)
|
||||
|
||||
Others:
|
||||
--debug Run this script in debug mode (default: $debug)
|
||||
-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
|
||||
}
|
||||
|
||||
|
@ -57,6 +60,10 @@ die_with_help () { printf '\033[31m'; printf "$@"; printf '\033[0m\n'; help; exi
|
|||
# shellcheck disable=SC2059
|
||||
debug () { if $debug; then printf >&2 '\033[37m'; printf >&2 "$@"; printf >&2 '\033[0m\n'; fi }
|
||||
|
||||
if [ -f .proxmox ]; then
|
||||
. "$PWD"/.proxmox
|
||||
fi
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
argument=$1
|
||||
shift
|
||||
|
@ -78,12 +85,12 @@ while [ $# -gt 0 ]; do
|
|||
esac
|
||||
done
|
||||
|
||||
if [ -z "$username" ] || [ -z "$password" ]; then
|
||||
if [ -f .proxmox ]; then
|
||||
{ read -r username; read -r password; } < .proxmox
|
||||
else
|
||||
die_with_help "Required: '--username' and '--password'.\n"
|
||||
if [ -z "$vm_ids" ]; then
|
||||
die_with_help "Required: at least one VM id.\n"
|
||||
fi
|
||||
|
||||
if [ -z "$username" ] || [ -z "$password" ]; then
|
||||
die_with_help "Required: '--username' and '--password'.\n"
|
||||
fi
|
||||
|
||||
readonly sockets
|
||||
|
|
Loading…
Add table
Reference in a new issue