-
Notifications
You must be signed in to change notification settings - Fork 4
/
zhost.sh.save
executable file
·82 lines (52 loc) · 1.85 KB
/
zhost.sh.save
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
80
81
#!/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, zf210423.1516
#THEIP=$(/sbin/ifconfig ens18 | /bin/grep "inet ad" | /usr/bin/cut -f2 -d: | /usr/bin/awk '{print $1}')
#THEIP=$(/sbin/ifconfig | /bin/grep "inet addr" | /bin/grep -v 127\.0 | /usr/bin/cut -f2 -d: | /usr/bin/awk '{print $1}')
#THEIP=127.0.0.1
THEHOST="toto"
/bin/hostname $THEHOST
#-$(echo $THEIP |/bin/sed "s/\./-/g")
# 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 "$THEIP $(hostname)" >> /etc/hosts
echo "$THEHOST" > /etc/hostname
/usr/sbin/dhclient -r
sleep 1
/usr/sbin/dhclient
sleep 3
THEIP=$(hostname -I)
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