david/scripts-archive
david
/
scripts-archive
Archived
1
0
Fork 0
This repository has been archived on 2022-04-16. You can view files and clone it, but cannot push or open issues or pull requests.
scripts-archive/clonebackup/clone.sh

44 lines
924 B
Bash
Executable File

#!/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