«
Previous
|
Next
»
Revision e2ac9a14
Added by Paolo Dongilli over 5 years ago
- ID e2ac9a1472beed9fcab19695a99794ac4c738d38
- Child a1471122
CartellaPerClient-Via-Clonezilla.ssh/id_rsa | ||
---|---|---|
1 |
-----BEGIN RSA PRIVATE KEY----- |
|
2 |
MIIEogIBAAKCAQEAxUgKLKJTcAakRIcHqbh4XbpdKSv+OPzVwBi0/hZ1Sa9tjaND |
|
3 |
gmyIzqTzaeRjIfGCSPqNePutvG/shcAcLG+fX+50Mqm8xLn9gMRf7ty/ojWSaTDn |
|
4 |
tdxapcHMQ6vNu5CxRrLOLgtSN8molM+XPsjzuMbX7qOmOoLulpQwqKRnarYiZKcQ |
|
5 |
lzyKSjrzdmm9g6FKvWnBlgc/3QP2r3jxs2D+beE9QooXbGmyiyG+1DEus1U2/vUA |
|
6 |
xLrF/xsZ7cCSUTWMm3zubSTyKCW0bUn33I1KnUlh7QTvHxWiVjCVUVGqOY2O8KOE |
|
7 |
rf4pDDOm75e0xlnlCoeoLKu3nPfZXS9gKWcpFwIDAQABAoIBAA2JePFBHjqUqhbt |
|
8 |
sQ/rUY8U56mYlDQy3TP2Pg0lW1z4BatvZYWAjw6m8PD2M/szSD5buvNvSaehgnhX |
|
9 |
C1fdPPFnOl/zl7lkDcoVL4QDb77gsDA5o9ytxyaSmsKV+mMBdbilMlKkgjrDwqab |
|
10 |
bARp45dtRYnhftmK/HYmqwQXa+U9hUfKMbLjumQksbpHBOd14CSCeMYsXWO6Y1Fq |
|
11 |
3bAUn5gG6hmehKFIdQCYRZ/15jG/Ci+XfmIW2LC3x+AUEmPii1k+vr6AyUkDDunD |
|
12 |
3heWlxrFj2TB/YTFysGBscsY/8fFWyE7T5vzVsmrWlpnW86foixliNQyKwOs6SSz |
|
13 |
IxQ3K6ECgYEA8ef0JSXCFwcHit7APSDyh6fzsOBwvH03Dlvs+AjRcRE4V2VFSQsu |
|
14 |
Ecv577ePmfz3WVgQe8zVCTLsX68rUeoIPnpfW24rqHPltPbU6ODzcOLuZJ1t+9cl |
|
15 |
/2q/1jlY82vEy96+Nae1RI45z5JHnpCSZ95Flku6r9wBsfbssNcMgIcCgYEA0MaB |
|
16 |
iUvwcY/gXBH0k+JTPwxuiObvg8R1sWctEn1JRB30UZixlETSTAlfW2xbGL7zBJxh |
|
17 |
IjlZpzCwQl1Tlpe9Qoc8qCidMTyvH5RbOMxQFz7JTea1Y/Pk9gQQaL9ZJ7Pugphj |
|
18 |
hkkeqvBG6z7uKRxdY43Y6cK2qxX1I7issfopBvECgYBf1T9wc/vnOX6wcjyAOww5 |
|
19 |
17x/5vpigcyM4LgJLx0iCOtkHBeNr2Mp47/5SqQWIhQvjebB1MzU3xqrcW7c/bUU |
|
20 |
Y1BhnUyoaHmo7lw8gdmPcCd3LrMCoSJJhJXJHWDy1k/ZYD3EbdMu/JVEeTPsSmPl |
|
21 |
yDWTLB8iSitVwHfWOuuWAwKBgDbyB2V69uzsUL/qedPx3LbbLrwZCzBCpDbsUJBt |
|
22 |
KLskpwhSh2neMvqP/Oiyu8bnek3cWjQHo/C8f6b3qOgZR1YbAXvANJ6gufY1tUxd |
|
23 |
eTak75XxAgwsRDX7G9Z1haFNWZhFQuw0kj2qvv9qsINhU7K/wjbDaA/e14VvNQQi |
|
24 |
MmoBAoGAOER5lSRUoDpRctB5zgWkug92MdPLbL52R2X+JI1pJ6nHNOTXtaHeNhPn |
|
25 |
zTraPMBj2i9Ivic9fP2yCYFNuZydGymbeq6w6m5/qv33WZTLXFPADxVV9Zj1VdnC |
|
26 |
BUm7u+3SNXSRRHQEZHMzJKlBzk0xKEZ5V8XAJcf3kOhzBOZsmiE= |
|
27 |
-----END RSA PRIVATE KEY----- |
CartellaPerClient-Via-Clonezilla.ssh/id_rsa.pub | ||
---|---|---|
1 |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFSAosolNwBqREhwepuHhdul0pK/44/NXAGLT+FnVJr22No0OCbIjOpPNp5GMh8YJI+o14+628b+yFwBwsb59f7nQyqbzEuf2AxF/u3L+iNZJpMOe13FqlwcxDq827kLFGss4uC1I3yaiUz5c+yPO4xtfuo6Y6gu6WlDCopGdqtiJkpxCXPIpKOvN2ab2DoUq9acGWBz/dA/avePGzYP5t4T1CihdsabKLIb7UMS6zVTb+9QDEusX/GxntwJJRNYybfO5tJPIoJbRtSffcjUqdSWHtBO8fFaJWMJVRUao5jY7wo4St/ikMM6bvl7TGWeUKh6gsq7ec99ldL2ApZykX root@g450ddd |
ListaPc.txt | ||
---|---|---|
1 |
alfredo 83:dd:1d:37:40:d6 devuan-img |
|
2 |
zorro 08:00:27:ab:5a:a2 fuss9-64bit-sept-2018-grubSec-img join |
|
3 |
bubba 83:dd:1d:37:40:d4 devuan-img |
|
4 |
mirco 83:d2:1d:37:40:d4 devuan-img |
|
5 |
pippo 83:dd:1d:37:40:e4 devuan-img |
|
6 |
tozzi e3:e7:49:44:f7:11 ProBook-Modello-2019-img |
|
7 |
g450-ugly e4:e7:49:44:f7:11 G450-Prova-img join |
authorized_keys-da-APPENDARE-a-root-del-Fuss-Server | ||
---|---|---|
1 |
command="if [[ \"$SSH_ORIGINAL_COMMAND\" =~ ^scp[[:space:]]-f ]] || [[ \"$SSH_ORIGINAL_COMMAND\" =~ ^add_client_principal ]] || [[ \"$SSH_ORIGINAL_COMMAND\" =~ rm[[:space:]]/root/ ]]; then $SSH_ORIGINAL_COMMAND; else echo \"Access Denied $SSH_ORIGINAL_COMMAND\"; fi" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFSAosolNwBqREhwepuHhdul0pK/44/NXAGLT+FnVJr22No0OCbIjOpPNp5GMh8YJI+o14+628b+yFwBwsb59f7nQyqbzEuf2AxF/u3L+iNZJpMOe13FqlwcxDq827kLFGss4uC1I3yaiUz5c+yPO4xtfuo6Y6gu6WlDCopGdqtiJkpxCXPIpKOvN2ab2DoUq9acGWBz/dA/avePGzYP5t4T1CihdsabKLIb7UMS6zVTb+9QDEusX/GxntwJJRNYybfO5tJPIoJbRtSffcjUqdSWHtBO8fFaJWMJVRUao5jY7wo4St/ikMM6bvl7TGWeUKh6gsq7ec99ldL2ApZykX root@g450ddd |
clientScripts/clientScript | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
|
|
3 |
myNic="$(ls /sys/class/net/ -1 | grep -v lo | grep -v wlan)" |
|
4 |
|
|
5 |
if [ -e /root/reboot ];then |
|
6 |
rm /root/reboot |
|
7 |
touch /root/join |
|
8 |
shutdown -r now |
|
9 |
fi |
|
10 |
|
|
11 |
if [ -e /root/join ];then |
|
12 |
dhclient $myNic |
|
13 |
screen -d -m -S XY |
|
14 |
screen -S XY -X stuff "fuss-client -av && rm /root/join ; reboot\n" |
|
15 |
else |
|
16 |
rm /etc/rc.local |
|
17 |
rm /root/clientScript |
|
18 |
rm -fr /root/.ssh |
|
19 |
|
|
20 |
fi |
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
clientScripts/rc.local | ||
---|---|---|
1 |
#!/bin/bash -e |
|
2 |
su -c /root/clientScript root || exit 1 |
|
3 |
exit 0 |
default | ||
---|---|---|
1 |
# BEGIN ANSIBLE MANAGED (default) |
|
2 |
DEFAULT menu.c32 |
|
3 |
# END ANSIBLE MANAGED (default) |
|
4 |
# BEGIN ANSIBLE MANAGED (clonezilla) |
|
5 |
timeout 300 |
|
6 |
label Clonezilla-unattended |
|
7 |
MENU LABEL Clonezilla Automatico (Ramdisk) |
|
8 |
KERNEL clonezilla/live/vmlinuz |
|
9 |
APPEND initrd=clonezilla/live/initrd.img boot=live username=clonezilla union=overlay config components quiet noswap edd=on nomodeset nodmraid locales= keyboard-layouts=NONE ocs_live_batch=no net.ifnames=0 nosplash noprompt keyboard-layouts=it locales=it_IT.UTF-8 ocs_prerun1="sshfs clonezilla@proxy:/srv/clonezilla /home/partimag" ocs_prerun2="screen -S XY '/home/partimag/script' " fetch=tftp://proxy/clonezilla/live/filesystem.squashfs |
|
10 |
# END ANSIBLE MANAGED (clonezilla) |
|
11 |
|
|
12 |
label Clonezilla-Manuale |
|
13 |
MENU LABEL Clonezilla Manuale (Ramdisk) |
|
14 |
KERNEL clonezilla/live/vmlinuz |
|
15 |
APPEND initrd=clonezilla/live/initrd.img boot=live username=clonezilla union=overlay config components quiet noswap edd=on nomodeset nodmraid locales= keyboard-layouts=NONE ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch=no net.ifnames=0 nosplash noprompt keyboard-layouts=it locales=it_IT.UTF-8 ocs_repository="ssh://clonezilla@proxy/srv/clonezilla" fetch=tftp://proxy/clonezilla/live/filesystem.squashfs |
|
16 |
# END ANSIBLE MANAGED (clonezilla) |
installazioneAutomatizzata.sh | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
|
|
3 |
DATUM="$(date +%d-%b-%Y-ore-%H-%M)" |
|
4 |
|
|
5 |
|
|
6 |
if [ -e /root/.ssh/authorized_keys ];then |
|
7 |
cp /root/.ssh/authorized_keys /root/.ssh/authorized_keys.BKP-$DATUM |
|
8 |
fi |
|
9 |
|
|
10 |
grep root@g450ddd /root/.ssh/authorized_keys >/dev/null |
|
11 |
|
|
12 |
if [ $? -eq 0 ]; then |
|
13 |
echo "authorized keys already there" |
|
14 |
else |
|
15 |
cat authorized_keys-da-APPENDARE-a-root-del-Fuss-Server >> /root/.ssh/authorized_keys |
|
16 |
fi |
|
17 |
|
|
18 |
cp -r CartellaPerClient-Via-Clonezilla.ssh /srv/clonezilla/.ssh |
|
19 |
|
|
20 |
chown -R clonezilla. /srv/clonezilla/.ssh |
|
21 |
|
|
22 |
chmod 400 /srv/clonezilla/.ssh/id_rsa* |
|
23 |
|
|
24 |
cp -r clientScripts /srv/clonezilla |
|
25 |
|
|
26 |
chmod -R 770 /srv/clonezilla/clientScripts |
|
27 |
|
|
28 |
|
|
29 |
if [ -e /srv/tftp/pxelinux.cfg/default ];then |
|
30 |
mv /srv/tftp/pxelinux.cfg/default /srv/tftp/pxelinux.cfg/default.BKP-$DATUM |
|
31 |
fi |
|
32 |
|
|
33 |
cp default /srv/tftp/pxelinux.cfg |
|
34 |
|
|
35 |
if [ -e /srv/clonezilla/ListaPc.txt ];then |
|
36 |
mv /srv/clonezilla/ListaPc.txt /srv/clonezilla/ListaPc.txt.BKP-$DATUM |
|
37 |
fi |
|
38 |
|
|
39 |
cp ListaPc.txt /srv/clonezilla |
|
40 |
|
|
41 |
if [ -e /srv/clonezilla/script ];then |
|
42 |
mv /srv/clonezilla/script /srv/clonezilla/script.BKP-$DATUM |
|
43 |
fi |
|
44 |
|
|
45 |
cp script /srv/clonezilla |
|
46 |
|
|
47 |
chmod 770 /srv/clonezilla/script |
|
48 |
|
|
49 |
chown -R clonezilla. /srv/clonezilla/* |
|
50 |
|
|
51 |
exit 0 |
script | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
# |
|
3 |
# Script for automated cloning and renaming of Fuss 9 client computers |
|
4 |
# using mac-address as unique identifier. |
|
5 |
# Donato Florio 11 April 2019 |
|
6 |
# |
|
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 |
|
9 |
# |
|
10 |
# PRT 1 --------------------------- |
|
11 |
|
|
12 |
|
|
13 |
# La funzione getNetStuff serve per recuperare il nome della NIC in uso sul sistema attuale. |
|
14 |
getNetStuff(){ |
|
15 |
if [ $1 -eq 1 ];then |
|
16 |
ls /sys/class/net/ -1 | grep -v lo | grep -v wlan |
|
17 |
else |
|
18 |
cat /sys/class/net/$(getNetStuff 1)/address |
|
19 |
fi |
|
20 |
} |
|
21 |
|
|
22 |
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." |
|
32 |
sleep 10 |
|
33 |
shutdown -h now |
|
34 |
else |
|
35 |
diskVar="$(ls /sys/block -1 | grep -Ev '(loop|sr|dvd|cd)')" |
|
36 |
fi |
|
37 |
|
|
38 |
# SSD portatili HP g450 |
|
39 |
if [ $diskVar == "nvme0n1" ];then |
|
40 |
rootPartition="p$rootPartition" |
|
41 |
fi |
|
42 |
# FINE g450 |
|
43 |
} |
|
44 |
|
|
45 |
rootPartition=2 |
|
46 |
getDisk |
|
47 |
rootDisk="/dev/$diskVar" |
|
48 |
mountPoint="/mnt" |
|
49 |
computerList="/home/partimag/ListaPc.txt" |
|
50 |
macAddress=$(getNetStuff 2) |
|
51 |
imageName=$(cat $computerList | grep "$macAddress" | awk '{print $3}') |
|
52 |
|
|
53 |
ocs-sr -b -g auto -e1 auto -e2 -r -j2 -scr -p true restoredisk $imageName $diskVar |
|
54 |
|
|
55 |
# # PRT 2 --------------------------- |
|
56 |
mount $rootDisk$rootPartition $mountPoint |
|
57 |
|
|
58 |
currentName="$(cat $mountPoint/etc/hostname)" |
|
59 |
newName="$(grep "$macAddress" $computerList | awk '{print $1}')" |
|
60 |
|
|
61 |
echo "SETTING HOSTNAME" |
|
62 |
|
|
63 |
for i in hostname hosts mailname |
|
64 |
|
|
65 |
do |
|
66 |
if [ -e $mountPoint/etc/$i ]; then |
|
67 |
sed -ie "s/$currentName/$newName/g" $mountPoint/etc/$i |
|
68 |
else |
|
69 |
echo "The file $i is not present on this system" |
|
70 |
fi |
|
71 |
done |
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
# ### Here I insert the part for the joining preparation of the machine |
|
76 |
|
|
77 |
# Veriy whether the machine has to be joined to the domain or not. |
|
78 |
# If so the .ssh keys are needed and also a script ..... |
|
79 |
|
|
80 |
joinVar="$(cat $computerList | grep "$macAddress" | awk '{print $4}')" |
|
81 |
|
|
82 |
if [ "$joinVar" == "join" ];then |
|
83 |
rsync -a /home/partimag/.ssh/ /mnt/root/.ssh/ |
|
84 |
cp /root/.ssh/known_hosts /mnt/root/.ssh/known_hosts |
|
85 |
cp /home/partimag/clientScripts/rc.local /mnt/etc/ |
|
86 |
chmod 770 /mnt/etc/rc.local |
|
87 |
cp /home/partimag/clientScripts/clientScript /mnt/root/ |
|
88 |
chmod 770 /mnt/root/clientScript |
|
89 |
touch /mnt/root/reboot |
|
90 |
fi |
|
91 |
# ### END of the preparation stuff |
|
92 |
|
|
93 |
|
|
94 |
reboot |
|
95 |
|
|
96 |
|
Also available in: Unified diff
Initial Commit