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
|
systemctl reboot
|
9
|
exit 0
|
10
|
fi
|
11
|
|
12
|
|
13
|
if [ -e /root/cluster ]; then
|
14
|
clusterJoin="$(cat /root/cluster)"
|
15
|
fi
|
16
|
|
17
|
|
18
|
if [ -e /root/join ]; then
|
19
|
# Stop the display manager to output on tty7
|
20
|
systemctl stop lightdm
|
21
|
# Change root password
|
22
|
if [ -e /root/new_root_pw ] ; then
|
23
|
echo "root:$(cat /root/new_root_pw)" | chpasswd -e
|
24
|
fi
|
25
|
# 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
|
screen -S XY -X stuff "exec 2>&1 > /dev/tty7\n"
|
29
|
screen -S XY -X stuff "fuss-client -av $clusterJoin && rm /root/join ; reboot\n"
|
30
|
else
|
31
|
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
|
fi
|
38
|
|