-
Notifications
You must be signed in to change notification settings - Fork 4
/
newhost
executable file
·44 lines (36 loc) · 1.24 KB
/
newhost
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
#!/bin/bash
clear
# _____ _
# | _ | | |
# __ _ _ __ _ __ ___ | |/' | _ __ ___ __| |
# / _` | '__| '_ ` _ \| /| || '__/ _ \/ _` |
# | (_| | | | | | | | \ |_/ /| | | __/ (_| |
# \__,_|_| |_| |_| |_|\___(_)_| \___|\__,_|
base64 -d <<<"H4sIAAAAAAAAA22NQQoAIQhF957CXQ0MeKHgdxAPP1+tWUSKEs+nqV4DESdTlbvtOfSDeeo8k7kb
iyNr7D9gW7opJl8tQINOOoN3jeOkFmBJwuq56PVd5VCnZovHSt/XB/DCEXqgKkJ0PEHj6SWpyAe/
8We1GwEAAA==" | gunzip
echo -e "\e[31;1m ***** arm0.red Security *****\e[0m"
echo -e "\e[31;1m ***** Change Hostname v1.0 *****\e[0m"
echo ""
# Assign existing hostname to $hostn
hostn=$(cat /etc/hostname)
# Display existing hostname
echo -e "\e[31;1m Existing hostname is: \e[0m"
echo "$hostn"
# Ask for new hostname $newhost
echo -e "\e[31;1m Enter new hostname: \e[0m"
read newhost
# Change hostname using hostnamectl
sudo hostnamectl set-hostname $newhost
# Display new hostname
echo -e "\e[31;1m Your new hostname is: \e[0m"
echo "$newhost"
# Press a key to reboot
echo -e "\e[31;1m A REBOOT IS REQUIRED. \e[0m"
read -r -p "Do you want to reboot now? [y/N] " response
if [[ $response =~ ^([Yy][eE][sS]|[yY])+$ ]]
then
sudo systemctl reboot
else
echo -e "\e[1;32mDone.\e[0m"
fi