diff --git a/vmcreate.sh b/vmcreate.sh index 4e43b76..328e24c 100644 --- a/vmcreate.sh +++ b/vmcreate.sh @@ -5,10 +5,11 @@ # ИЗУЧИТЬ!!!! /usr/share/pve-docs/examples/guest-example-hookscript.pl storage="syno-tigra" -path="/mnt/pve/$storage/snippets/" +path="/mnt/pve/${storage}/snippets/" node=3 size=50 remove=false +template="user.yaml" harule="" pubkey="" @@ -31,6 +32,7 @@ show_help () { echo "-n - specify target node NUMBER to migrate VM to after creating. Default is '3'" echo "-t - add additional proxmox tag. Default is only pve node number." echo "-f - get IP addresses and Hostnames from 'flilename'." + echo "-s - specify custom snippet template. Default is 'user.yaml'" echo "-R - REMOVE specified VMs, snippets and HA rule (if specified). Be careful! It's a production cluster!" echo echo "If file not specified, script will use arguments as a list of IP addresses." @@ -134,6 +136,7 @@ while getopts "a:f:hk:u:p:d:n:t:R" opt; do d) size=${OPTARG};; n) node=${OPTARG};; t) tag=${OPTARG};; + s) template=${OPTARG};; R) remove=true;; \?) echo "Invalid option."; show_help; exit 1;; esac @@ -141,6 +144,8 @@ done if [ $tag ]; then tag=",${tag}"; fi +if [ ! -f $template ]; then echo "Specified snippet template does not exist. Aborting."; exit 10; fi + if [ $harule ]; then hostcheck "$harule" if [ $? -ne 0 ]; then echo "HArule should contain only letters, numbers and dashes. Aborting."; exit 1; fi