Update vmcreate1.sh

This commit is contained in:
2025-10-24 13:14:41 +00:00
parent 7e564db9fa
commit aaa54a0e2a

View File

@@ -12,16 +12,33 @@ show_help()
make_file (){
if [ $# -eq 0 ] then
do touch hosts.tmp
touch hosts.tmp
for arg in "$@"; do
ipcheck "$arg"
if [ $? -eq 0 ] then
echo -n "$arg " >> ./hosts.tmp
echo $arg | cut -d '.' -f 3,4 | sed 's/\.//' >> hosts.tmp
done
fi
}
ip_check (){
function ip_check() {
# Функция написана гуглом
local ip=$1
local stat=1
oldIFS=$IFS
# Check if the IP matches the general IPv4 pattern
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
# Split the IP into octets
IFS='.' read -r -a octets <<< "$ip"
# Check if each octet is within the valid range (0-255)
if [[ ${octets[0]} -le 255 && ${octets[1]} -le 255 \
&& ${octets[2]} -le 255 && ${octets[3]} -le 255 ]]; then
stat=0
fi
fi
return $stat
IFS=$oldIFS
}
hostame_generate(){