#!/bin/bash # get mac address net=192.168.19. ifs="eth0 eth1 eth2 eth3 eth4" # get the configuration with ip string=$(ip addr | grep "inet $net") set -- $ifs for var in "$@"; do if [[ $string == "" ]]; then echo "error: no interface configured to $net, exiting" exit 1 else if [[ $string == *$var* ]]; then macstring=$(ip addr show eth0 | grep ether) fi fi done # get mac address mac=${macstring:15:17} #echo "MAC Address: $mac" # get the hostname from the list hostnamestring=$(cat mac2hostname.lst | grep $mac) hostname=${hostnamestring:18} #echo "Hostname: $hostname" # generate imagename imagename=$hostname"_$(echo $(date "+%d_%m_%C%y"))" #echo "Imagename: $imagename" echo $imagename # starting clonezilla imaging process /opt/drbl/sbin/ocs-sr -q2 -j2 -gs -z1 -i 0 -p reboot savedisk "$imagename" "sda" # also possible "sda sdb" # end of script exit 0