| 1 |
e2ac9a14
|
Paolo Dongilli
|
#!/bin/bash
|
| 2 |
|
|
|
| 3 |
|
|
myNic="$(ls /sys/class/net/ -1 | grep -v lo | grep -v wlan)"
|
| 4 |
|
|
|
| 5 |
1ecf0067
|
Marco Marinello
|
if [ -e /root/reboot ]; then
|
| 6 |
c8e6fde9
|
Marco Marinello
|
rm /root/reboot
|
| 7 |
|
|
touch /root/join
|
| 8 |
|
|
systemctl reboot
|
| 9 |
1ecf0067
|
Marco Marinello
|
exit 0
|
| 10 |
e2ac9a14
|
Paolo Dongilli
|
fi
|
| 11 |
|
|
|
| 12 |
a1471122
|
Donato Florio
|
|
| 13 |
1ecf0067
|
Marco Marinello
|
if [ -e /root/cluster ]; then
|
| 14 |
c8e6fde9
|
Marco Marinello
|
clusterJoin="$(cat /root/cluster)"
|
| 15 |
a1471122
|
Donato Florio
|
fi
|
| 16 |
|
|
|
| 17 |
|
|
|
| 18 |
1ecf0067
|
Marco Marinello
|
if [ -e /root/join ]; then
|
| 19 |
474b38cb
|
Marco Marinello
|
# Stop the display manager to output on tty7
|
| 20 |
|
|
systemctl stop lightdm
|
| 21 |
63d48e7f
|
Marco Marinello
|
# Change root password
|
| 22 |
|
|
if [ -e /root/new_root_pw ] ; then
|
| 23 |
|
|
echo "root:$(cat /root/new_root_pw)" | chpasswd -e
|
| 24 |
|
|
fi
|
| 25 |
c8e6fde9
|
Marco Marinello
|
# Following dhclient was necessary inside a virtual(box) environment. Not sure if needed anymore. In case it can be removed or commented.
|
| 26 |
|
|
dhclient $myNic
|
| 27 |
|
|
screen -d -m -S XY
|
| 28 |
474b38cb
|
Marco Marinello
|
screen -S XY -X stuff "exec 2>&1 > /dev/tty7\n"
|
| 29 |
c8e6fde9
|
Marco Marinello
|
screen -S XY -X stuff "fuss-client -av $clusterJoin && rm /root/join ; reboot\n"
|
| 30 |
e2ac9a14
|
Paolo Dongilli
|
else
|
| 31 |
96a09728
|
Paolo Dongilli
|
rm /etc/rc.local
|
| 32 |
|
|
rm /root/clientScript
|
| 33 |
|
|
rm -fr /root/.ssh/id_rsa*
|
| 34 |
|
|
rm /root/.ssh/known_hosts
|
| 35 |
|
|
sed -i '/clonezilla/d' /root/.ssh/authorized_keys
|
| 36 |
|
|
rm /root/cluster
|
| 37 |
e2ac9a14
|
Paolo Dongilli
|
fi
|