Commit 6b9f274b authored by Dietmar Maurer's avatar Dietmar Maurer

spice-example-sh: add parameter parser

As suggested by Michael in the forum.
parent 82599a65
......@@ -2,13 +2,60 @@
# needs pve-manager >= 3.1-44
USERNAME=root@pam
PASSWORD=yoursecretpassword
usage() {
echo "Usage: $0 [-u <string>] [-p <string>] vmid [node [proxy]]"
echo
echo "-u username. Default root@pam"
echo "-p password. Default ''"
echo
echo "vmid: id for VM"
echo "node: Proxmox cluster node name"
echo "proxy: DNS or IP (use <node> as default)"
exit 1
}
PASSWORD=""
USERNAME=""
while getopts ":u:p:" o; do
case "${o}" in
u)
USERNAME=${OPTARG}
;;
p)
PASSWORD=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z $PASSWORD ]; then
PASSWORD=""
fi
if [ -z $USERNAME ]; then
USERNAME=root@pam
fi
DEFAULTHOST=$(hostname -f)
# select VM
VMID=100
[ -z $1 ] && usage
VMID=$1
#[ -z $2 ] && usage
NODE=${2:-$DEFAULTHOST}
if [ -z $3 ]; then
PROXY=$NODE
else
PROXY=$3
fi
NODE=anodename
PROXY=anodename.domain.tld
NODE=${NODE%%\.*}
DATA=`curl -k -d "username=$USERNAME&password=$PASSWORD" https://$PROXY:8006/api2/json/access/ticket`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment