-
Notifications
You must be signed in to change notification settings - Fork 4
/
zhost.sh
executable file
·80 lines (49 loc) · 1.63 KB
/
zhost.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
#Petit script pour changer le hostname avec l'adresse ip du dhcp, forcer le bon DNS et ajouter la machine dans le DNS
#zf171122.1619, zf191010.1140, zf210424.1904
THEIP=127.0.0.1
THEHOST="toto"
/bin/hostname $THEHOST
# change le hostname
echo "127.0.0.1 localhost" > /etc/hosts
echo "127.0.1.1 ubuntu" >> /etc/hosts
echo "# The following lines are desirable for IPv6 capable hosts" >> /etc/hosts
echo "::1 localhost ip6-localhost ip6-loopback" >> /etc/hosts
echo "ff02::1 ip6-allnodes" >> /etc/hosts
echo "ff02::2 ip6-allrouters" >> /etc/hosts
echo "$THEHOST" > /etc/hostname
echo "$THEIP $(hostname)" >> /etc/hosts
# ajoute la machine dans le DNS de Consul
sleep 1
THEIP=$(hostname -I)
sleep 1
/root/dns_add.sh $THEHOST $THEIP
exit
# force le bon DNS et interdit la modification par le DHCP !
chattr -i /etc/resolv.conf
echo "nameserver 10.92.103.53" > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "search node.consul epfl.ch" >> /etc/resolv.conf
chattr +i /etc/resolv.conf
# ajoute la machine dans le DNS de Consul
/root/dns_add.sh $THEHOST $THEIP
# change le message d'accueil sur la console
zcommand="pveversion"
tstcommand=`command -v $zcommand`
echo -e "
$THEIP
`host $THEIP`
" > /etc/issue
#echo $zcommand
#echo $tstcommand
if [ "$tstcommand" ]
then
echo -e "
------------------------------------------------------------------------------
Welcome to the Proxmox Virtual Environment. Please use your web browser to
configure this server - connect to:
https://$THEIP:8006/
hello zuzu
------------------------------------------------------------------------------
" >> /etc/issue
fi