From 006a184f225f1ba893dd40d104e9a29a0c254a06 Mon Sep 17 00:00:00 2001 From: Dmitry Badovsky Date: Fri, 24 Oct 2025 13:49:12 +0000 Subject: [PATCH] Update vmcreate1.sh --- vmcreate1.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vmcreate1.sh b/vmcreate1.sh index 31705ad..ae9046e 100644 --- a/vmcreate1.sh +++ b/vmcreate1.sh @@ -10,6 +10,7 @@ show_help() echo "\nIf file not specified, script will use arguments as a list of IP addresses." echo "In this case Hostname will be inherited from 2 last IP octets. Example for 10.10.35.20: 'vm035020'." + # Обрабатываем опции while getopts "a:f:h" opt; do case $opt in @@ -20,10 +21,10 @@ while getopts "a:f:h" opt; do esac done -if [ -f $file ]; then echo "File $file does not exist."; exit 1 +if [ -v $file && ! -f $file ]; then echo "File $file does not exist. Use default 'hosts' file?"; exit 1 -# Если нет аргументов, то создаем временный файл -if [ $# -eq 0 ] then +# Если заданы аргументы, то создаем временный файл +if [ $# -ne 0 ] then touch hosts.tmp for arg in "$@"; do ipcheck "$arg"