Commit 163e2d36 authored by Paolo Dongilli's avatar Paolo Dongilli
Browse files

Latest version of script by Donato Florio

parent 0e55cfde
......@@ -11,6 +11,7 @@
# Last modified 12-13 May 2020 --> automatic root partition selection + EFI stuff
# Last modified 19 May 2020 --> little modification of the "dialog" interface
# Last modified 04 June 2020 --> little change to allow rejoin without cloning (just comment line "ocs-sr ..."
# Last modified 24 March 2021 --> modified the parts gathering info of disk and partitions
#
# PRT 1 ---------------------------
......@@ -25,13 +26,8 @@ getNetStuff(){
}
getDisk(){
for i in $(lsblk -d -n -o NAME | grep -Ev '(loop|sr|dvd|cd)')
do
if [ $(cat /sys/block/$i/removable) -eq 0 ];then
myDevice="${myDevice} $i"
fi
done
myDevice="$(lsblk -l -n | grep disk | awk '{print $1}')"
if [ $(echo $myDevice | wc -w) -gt 1 ];then
echo "ATTENZIONE! Questo computer sembra provvisto di più di un disco!"
echo ""
......@@ -39,21 +35,15 @@ getDisk(){
echo "multidisco. Contattare il tecnico informatico."
echo ""
echo "Per sicurezza il computer verrà spento tra 10 secondi."
sleep 10
shutdown -h now
sleep 10
shutdown -h now
else
diskVar="$(echo $myDevice | tr -d [:blank:])"
fi
# SSD of HP g450 laptops
if [ $diskVar == "nvme0n1" ];then
rootPartition="p$rootPartition"
fi
# FINE g450
fi
}
getRootPartitionFuss(){
for i in $(blkid | grep -v "squash" | nl | grep ext | awk '{print $2}' | tr -d ":")
for i in $(lsblk -lp | grep part | awk '{print $1}')
do
mount $i /mnt
if [ -d "/mnt/etc/fuss-client" ];then
......@@ -61,7 +51,7 @@ getRootPartitionFuss(){
fi
umount /mnt
done
echo "$(blkid | sort | grep -v "squash" | nl | grep ext | grep "$fussDir" | awk '{print $1}')"
echo "$fussDir"
}
getImages(){
......@@ -79,7 +69,6 @@ getImages(){
}
getDisk
rootDisk="/dev/$diskVar"
mountPoint="/mnt"
computerList="/home/partimag/computerList.txt"
macAddress=$(getNetStuff 2)
......@@ -108,14 +97,14 @@ fi
imageName=$(cat $computerList | grep "$macAddress" | awk '{print $3}')
# Comment the following line to rejoin clients without cloning (migration 2020)
# Comment the following line to rejoin clients without cloning (migration 2021)
ocs-sr -b -g auto -e1 auto -e2 -k1 -r -j2 -scr -p true restoredisk $imageName $diskVar
# --------------------------------------------------------------------------------
rootPartition=$(getRootPartitionFuss)
# # PRT 2 ---------------------------
mount $rootDisk$rootPartition $mountPoint
mount $rootPartition $mountPoint
# Check for EFI partition. If present mount it and install grub files ----------
......@@ -142,8 +131,6 @@ do
fi
done
# ### Here I insert the part for the joining preparation of the machine
# Verify whether the machine has to be joined to the domain or not.
......@@ -174,5 +161,4 @@ fi
# ### END of the preparation stuff
reboot
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment