Revision a1471122
Added by Donato Florio over 5 years ago
script | ||
---|---|---|
5 | 5 |
# Donato Florio 11 April 2019 |
6 | 6 |
# |
7 | 7 |
# Last modified 02 May 2019 --> added modification to support cloning on nvme* devices (HP G450) |
8 |
# Last modified 07 May 2019 --> added various stuff for experimental autojoin |
|
8 |
# Last modified 07 May 2019 --> added various stuff for experimental autojoin to a domain |
|
9 |
# Last modified 21 June 2019 --> added various stuff for experimental join to a cluster |
|
10 |
# Last modified 01 July 2019 --> added ssh to script and changed disk detection method |
|
9 | 11 |
# |
10 | 12 |
# PRT 1 --------------------------- |
11 | 13 |
|
14 |
service ssh start |
|
12 | 15 |
|
13 |
# La funzione getNetStuff serve per recuperare il nome della NIC in uso sul sistema attuale. |
|
14 | 16 |
getNetStuff(){ |
15 | 17 |
if [ $1 -eq 1 ];then |
16 | 18 |
ls /sys/class/net/ -1 | grep -v lo | grep -v wlan |
... | ... | |
20 | 22 |
} |
21 | 23 |
|
22 | 24 |
getDisk(){ |
23 |
diskCount="$(ls /sys/block -1 | grep -Ev '(loop|sr|dvd|cd)' | wc -l)" |
|
24 |
|
|
25 |
if [ $diskCount -gt 1 ];then |
|
26 |
echo "ATTENZIONE! Questo computer sembra provvisto di più di un disco!" |
|
27 |
echo "" |
|
28 |
echo "La procedura automatica non prevede l'installazione su sistemi" |
|
29 |
echo "multidisco. Contattare il tecnico informatico." |
|
30 |
echo "" |
|
31 |
echo "Per sicurezza il computer verrà spento tra 10 secondi." |
|
25 |
for i in $(ls /sys/block/ | grep -Ev '(loop|sr|dvd|cd)') |
|
26 |
do |
|
27 |
if [ $(cat /sys/block/$i/removable) -eq 0 ];then |
|
28 |
myDevice="${myDevice} $i" |
|
29 |
fi |
|
30 |
done |
|
31 |
|
|
32 |
if [ $(echo $myDevice | wc -w) -gt 1 ];then |
|
33 |
echo "ATTENZIONE! Questo computer sembra provvisto di più di un disco!" |
|
34 |
echo "" |
|
35 |
echo "La procedura automatica non prevede l'installazione su sistemi" |
|
36 |
echo "multidisco. Contattare il tecnico informatico." |
|
37 |
echo "" |
|
38 |
echo "Per sicurezza il computer verrà spento tra 10 secondi." |
|
32 | 39 |
sleep 10 |
33 | 40 |
shutdown -h now |
34 | 41 |
else |
35 |
diskVar="$(ls /sys/block -1 | grep -Ev '(loop|sr|dvd|cd)')"
|
|
42 |
diskVar="$(echo $myDevice | tr -d [:blank:])"
|
|
36 | 43 |
fi |
37 | 44 |
|
38 |
# SSD portatili HP g450
|
|
45 |
# SSD of HP g450 laptops
|
|
39 | 46 |
if [ $diskVar == "nvme0n1" ];then |
40 | 47 |
rootPartition="p$rootPartition" |
41 | 48 |
fi |
... | ... | |
46 | 53 |
getDisk |
47 | 54 |
rootDisk="/dev/$diskVar" |
48 | 55 |
mountPoint="/mnt" |
49 |
computerList="/home/partimag/ListaPc.txt"
|
|
56 |
computerList="/home/partimag/computerList.txt"
|
|
50 | 57 |
macAddress=$(getNetStuff 2) |
51 | 58 |
imageName=$(cat $computerList | grep "$macAddress" | awk '{print $3}') |
52 | 59 |
|
... | ... | |
74 | 81 |
|
75 | 82 |
# ### Here I insert the part for the joining preparation of the machine |
76 | 83 |
|
77 |
# Veriy whether the machine has to be joined to the domain or not. |
|
84 |
# Verify whether the machine has to be joined to the domain or not.
|
|
78 | 85 |
# If so the .ssh keys are needed and also a script ..... |
79 | 86 |
|
80 |
joinVar="$(cat $computerList | grep "$macAddress" | awk '{print $4}')" |
|
87 |
joinVar="$(cat $computerList | grep "$macAddress" | awk '{print $4}')" |
|
88 |
|
|
89 |
clusterVar="$(cat $computerList | grep "$macAddress" | awk '{print $5}')" |
|
81 | 90 |
|
82 | 91 |
if [ "$joinVar" == "join" ];then |
83 | 92 |
rsync -a /home/partimag/.ssh/ /mnt/root/.ssh/ |
... | ... | |
88 | 97 |
chmod 770 /mnt/root/clientScript |
89 | 98 |
touch /mnt/root/reboot |
90 | 99 |
fi |
100 |
|
|
101 |
if [ "$clusterVar" != "" ];then |
|
102 |
clusterJoin="-g $clusterVar" |
|
103 |
echo "$clusterJoin" > /mnt/root/cluster |
|
104 |
fi |
|
105 |
|
|
106 |
|
|
107 |
|
|
91 | 108 |
# ### END of the preparation stuff |
92 | 109 |
|
93 | 110 |
|
Also available in: Unified diff
Various modifications.