-
Notifications
You must be signed in to change notification settings - Fork 4
/
change_hostname.sh
executable file
·70 lines (42 loc) · 1.31 KB
/
change_hostname.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
#!/usr/bin/env bash
#Petit script pour changer le nom du hostname
#zf170908.1551, zf210424.1909
#test si l'argument est vide
if [ -z "$1" ]
then
echo -e "\nSyntax: ~/just_change_name.sh machine_name\n\n"
exit
fi
# modifie le hostname
echo ---------- install change hostname
sudo cp ~/deploy-proxmox/zhost.sh /root
sudo cp ~/deploy-proxmox/dns_add.sh /root
sudo sed -i "s/THEHOST=\"toto\"/THEHOST=\"$1\"/" /root/zhost.sh
sudo cp ~/deploy-proxmox/zhost.service /etc/systemd/system
sudo chown root:root /etc/systemd/system/zhost.service
sudo systemctl daemon-reload
sudo systemctl enable zhost.service
#sudo systemctl restart zhost.service
#sudo systemctl disable zhost.service
#sudo /root/zhost.sh
/usr/bin/timedatectl set-timezone Europe/Zurich
sudo rm /etc/machine-id
sudo systemd-machine-id-setup
#sudo dhclient -r
#sudo rm /var/lib/dhcp/dhclient.leases
sudo reboot
exit
#test si l'argument est vide
if [ -z "$1" ]
then
echo -e "\nSyntax: change_hostname.sh machine_name\n\n"
exit
fi
# modifie le hostname
echo ---------- install change hostname
sudo cp zhost.sh /root
sudo sed -i "s/THEHOST=\"toto\"/THEHOST=\"$1\"/" /root/zhost.sh
sudo cp zhost.service /etc/systemd/system
sudo chown root:root /etc/systemd/system/zhost.service
sudo systemctl daemon-reload
sudo systemctl enable zhost.service