Update vmcreate1.sh
This commit is contained in:
@@ -33,6 +33,7 @@ if [[ $# -eq 0 && -v $file && ! -f $file ]]; then
|
|||||||
N) read -p "Enter file name: " file;;
|
N) read -p "Enter file name: " file;;
|
||||||
*) echo "Use '-f' flag for help"; exit 0;;
|
*) echo "Use '-f' flag for help"; exit 0;;
|
||||||
esac
|
esac
|
||||||
|
if [ ! -f hosts ]; then echo "File 'hosts' does not exist. Exiting."; exit 0; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Если заданы аргументы И файл
|
# Если заданы аргументы И файл
|
||||||
@@ -46,7 +47,10 @@ if [ $# -ne 0 ] then
|
|||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
echo -n "$arg " >> ./hosts.tmp
|
echo -n "$arg " >> ./hosts.tmp
|
||||||
echo hostname_generate $arg >> hosts.tmp
|
echo -n "vm" >> ./hosts.tmp
|
||||||
|
printf "%05d\n" "$(echo -n $arg | cut -d '.' -f 3)" >> ./hosts.tmp
|
||||||
|
printf "%05d\n" "$(echo -n $arg | cut -d '.' -f 4)" >> ./hosts.tmp
|
||||||
|
echo >> ./hosts.tmp
|
||||||
else
|
else
|
||||||
echo "Argument $arg is not valid IP address (10.10.*.*). Using next argument."
|
echo "Argument $arg is not valid IP address (10.10.*.*). Using next argument."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user